Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions docs/commands/device-output/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@ Commands for device output operations in PostScript.

This category contains PostScript operators for device output.

== Status
== Commands

This category is ready for command documentation to be added. Commands in this category include operators from the PostScript Language Reference Manual.
[cols="1,3"]
|===
| Command | Description

See other completed categories for documentation examples:
* link:/commands/references/[Path Construction]
* link:/commands/references/[Painting]
* link:/commands/references/[Transformations]
* link:/commands/references/[Font & Text]
| link:/commands/references/showpage/[`showpage`]
| Output the page and reinitialize graphics state (Level 1)

| link:/commands/references/copypage/[`copypage`]
| Output the page without reinitializing graphics state (Level 1; page retention changes in Level 3)

| link:/commands/references/nulldevice/[`nulldevice`]
| Discard graphical output (Level 1)
|===

== See Also

Expand Down
3 changes: 3 additions & 0 deletions docs/commands/font-text/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ PostScript provides comprehensive font and text capabilities including font sele

| link:/commands/references/cshow/[`cshow`]
| Show with per-character control (Level 2)

| link:/commands/references/xyshow/[`xyshow`]
| Show with explicit x/y displacements (Level 2)
|===

=== Text Measurement
Expand Down
4 changes: 4 additions & 0 deletions docs/commands/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ link:/commands/references/[View all array/string commands →]

link:/commands/references/[View all dictionary commands →]

=== Relational and Boolean

link:/commands/relational-boolean/[View all relational and boolean commands →]

=== Control Flow

link:/commands/references/[View all control flow commands →]
Expand Down
65 changes: 65 additions & 0 deletions docs/commands/references/and.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
layout: default
title: and
parent: Command Reference
nav_order: 7
---
= and

Compute logical or bitwise AND.

== Description

With two booleans, `and` returns true only when both operands are true. With two integers, it applies bitwise AND to their binary representations and returns an integer.

Both operands must have the same type: boolean or integer. Reals and mixed boolean/integer operands cause `typecheck`. This consumes two already evaluated operands; it does not short-circuit execution.

== Syntax

[source,postscript]
----
bool1 bool2 and bool3
int1 int2 and int3
----

=== Stack Effect

Stack entries are shown from bottom to top; earlier operands are unchanged.

[cols="1,3"]
|===
|State |Operand stack

|Before
|`bool1 bool2` or `int1 int2`

|After
|`bool3` or `int3`
|===

== Examples

[source,postscript]
----
true false and % false
true true and % true
12 10 and % 8 (1100 AND 1010 = 1000)
----

== Related Commands

* link:/commands/references/or/[`or`] - Logical and bitwise operation
* link:/commands/references/xor/[`xor`] - Logical and bitwise operation
* link:/commands/references/not/[`not`] - Logical and bitwise operation

== PostScript Level

*Available in*: PostScript Level 1 and higher (LanguageLevel 1).

== Error Conditions

`stackunderflow`::
The operand stack contains fewer than two operands.

`typecheck`::
Operands are neither two booleans nor two integers.
64 changes: 64 additions & 0 deletions docs/commands/references/copypage.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
layout: default
title: copypage
parent: Command Reference
nav_order: 2
---
= copypage

Output the current page without reinitializing the graphics state.

== Description

In Levels 1 and 2, `copypage` outputs the current page while retaining its marks and graphics state, so further drawing can be added to the same image.

In Level 3, it behaves like `showpage` except that it does not reinitialize the graphics state: under normal page-device behavior, the page is output and erased. Do not rely on earlier marks remaining when running in Level 3. Page-device procedures can customize output behavior.

== Syntax

[source,postscript]
----
- copypage -
----

=== Stack Effect

Stack entries are shown from bottom to top; earlier operands are unchanged.

[cols="1,3"]
|===
|State |Operand stack

|Before
|No operands required

|After
|Unchanged
|===

== Examples

[source,postscript]
----
/Helvetica findfont 12 scalefont setfont
72 720 moveto (Original) show
copypage
72 700 moveto (Additional line) show
showpage
% Levels 1/2: the second output contains both lines.
% Level 3: the second output contains only the additional line.
----

== Related Commands

* link:/commands/references/showpage/[`showpage`] - Output and reinitialize the graphics state
* link:/commands/references/nulldevice/[`nulldevice`] - Discard graphical output

== PostScript Level

*Available in*: PostScript Level 1 and higher (LanguageLevel 1).

== Error Conditions

`undefined`::
In Level 2 and higher, copypage was called from a BeginPage or EndPage procedure. Errors from page-device procedures can also propagate.
69 changes: 69 additions & 0 deletions docs/commands/references/eq.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
layout: default
title: eq
parent: Command Reference
nav_order: 1
---
= eq

Test two objects for equality.

== Description

Returns `true` when the two operands are equal, and `false` otherwise.

Integers and reals compare by numeric value. Strings compare by their bytes, and names compare by their spelling; a name and a string with the same characters are equal. Other differing types are unequal, rather than causing `typecheck`.

Arrays and dictionaries compare by shared object identity, not by matching contents. Literal/executable attributes do not affect equality. String contents must be readable.

== Syntax

[source,postscript]
----
any1 any2 eq bool
----

=== Stack Effect

Stack entries are shown from bottom to top; earlier operands are unchanged.

[cols="1,3"]
|===
|State |Operand stack

|Before
|`any1 any2`

|After
|`bool`
|===

== Examples

[source,postscript]
----
7 7.0 eq % true
(cat) (cat) eq % true
/cat /cat eq % true
/cat (cat) eq % true
7 (7) eq % false
[1 2] dup eq % true
[1 2] [1 2] eq % false
----

== Related Commands

* link:/commands/references/ne/[`ne`] - Complementary equality test
* link:/commands/references/lt/[`lt`] - Ordered comparison

== PostScript Level

*Available in*: PostScript Level 1 and higher (LanguageLevel 1).

== Error Conditions

`invalidaccess`::
A string needed for comparison does not permit reading.

`stackunderflow`::
The operand stack contains fewer than two operands.
61 changes: 61 additions & 0 deletions docs/commands/references/false.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
layout: default
title: "false"
parent: Command Reference
nav_order: 12
---
= false

Push the boolean value `false`.

== Description

Executing the name `false` pushes the boolean value `false` onto the operand stack. It takes no operands. Strictly speaking, this is a name in `systemdict` associated with a boolean object, rather than an operator.

Booleans are distinct from integers: `true` is not the number 1, and `false` is not the number 0. Use booleans as conditions for `if` and `ifelse`.

== Syntax

[source,postscript]
----
- false false
----

=== Stack Effect

Stack entries are shown from bottom to top; earlier operands are unchanged.

[cols="1,3"]
|===
|State |Operand stack

|Before
|No operands required

|After
|`false`
|===

== Examples

[source,postscript]
----
false type % booleantype
false not % true
false { (yes) } { (no) } ifelse % (no)
----

== Related Commands

* link:/commands/references/true/[`true`] - The other boolean value
* link:/commands/references/not/[`not`] - Negate a boolean
* link:/commands/references/ifelse/[`ifelse`] - Select a branch

== PostScript Level

*Available in*: PostScript Level 1 and higher (LanguageLevel 1).

== Error Conditions

`stackoverflow`::
The operand stack has no room for another object.
70 changes: 70 additions & 0 deletions docs/commands/references/ge.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
layout: default
title: ge
parent: Command Reference
nav_order: 3
---
= ge

Test whether the first operand is greater than or equal to the second.

== Description

Returns a boolean indicating whether the first operand is greater than or equal to the second. Both operands must be numbers or both must be strings. Integers and reals may be mixed.

Strings are ordered lexicographically by unsigned byte values, with the first differing byte deciding the order. If one string is a prefix of the other, the shorter string comes first. This is case-sensitive byte ordering, not locale-aware sorting. Names are not accepted, even though names can be compared with strings by `eq` and `ne`.

== Syntax

[source,postscript]
----
num1 num2 ge bool
string1 string2 ge bool
----

=== Stack Effect

Stack entries are shown from bottom to top; earlier operands are unchanged.

[cols="1,3"]
|===
|State |Operand stack

|Before
|`num1 num2` or `string1 string2`

|After
|`bool`
|===

== Examples

[source,postscript]
----
5 5.0 ge % true
(cat) (car) ge % true
2 3 ge % false
----

== Related Commands

* link:/commands/references/eq/[`eq`] - Compare values
* link:/commands/references/ne/[`ne`] - Compare values
* link:/commands/references/gt/[`gt`] - Compare values
* link:/commands/references/le/[`le`] - Compare values
* link:/commands/references/lt/[`lt`] - Compare values

== PostScript Level

*Available in*: PostScript Level 1 and higher (LanguageLevel 1).

== Error Conditions

`invalidaccess`::
A string needed for comparison does not permit reading.

`stackunderflow`::
The operand stack contains fewer than two operands.

`typecheck`::
Operands are neither two numbers nor two strings.
Loading
Loading