src/swipl-devel/packages/xpce/man/refmanual/md/terminal_block.md

class terminal_block {#class-terminal_block}

One command a client ran in a terminal_image, as its OSC 133 semantic prompt marks describe it: the prompt (A), the line the user edited (B), the output of running it (C) and the end of that output (D, or the prompt after it). The terminal builds them as the marks arrive and keeps them in <-blocks, oldest first. Subclass of object.

A block is what lets the window be addressed by what it was used for rather than by row and column: <-content hands over the command or its output as a string, ->select and ->copy put either on the clipboard, ->scroll_to brings it back into view and ->fold takes its output off the display.

A command can take more than one line to type. The client asks for each of them separately -- a Prolog term is read a line at a time until its full stop -- and marks all but the first with A;k=s, the secondary prompt. Those lines are one command and one block, anchored to the line it started on.

The commandline editor of SWI-Prolog emits the marks by default; see el_set/2 prompt_marks(Boolean) in library(editline). A client that marks nothing produces no blocks.

Lifetime {#class-terminal_block-lifetime}

->remove is the one thing that changes the buffer rather than reading it: everything else here only says what is already there.

A block outlives the marks it was made from but not the text it points at. Its positions are lines of the scrollback, so a line pushed out of the buffer takes with it the marks that named it, and a block with nothing left is dropped from <-blocks with its <-terminal set to @nil. A block still held elsewhere is then harmless: every method that needs text fails.

<-prompt, <-input, <-output and <-end report positions in the flat character space of the terminal, which composes with <-contents, <-find, ->selection and ->scroll_to -- but see Character indices in the documentation of class terminal_image: those indices shift as output pushes lines out of the scrollback. <-id is the handle that outlives them.

@see class terminal_image

Instance variables {#class-terminal_block-instvars}

Send methods {#class-terminal_block-send}

Get methods {#class-terminal_block-get}



Try the rswipl package in your browser

Any scripts or data that you put into this service are public.

rswipl documentation built on Sept. 26, 2026, 1:07 a.m.