aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/tedit/display/screen
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /pkg/utilities/nttools/tedit/display/screen
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'pkg/utilities/nttools/tedit/display/screen')
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/README211
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/kbegin.x40
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/kcompile.x148
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/kconvert.x61
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/kdoline.x96
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/kend.x49
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/kget.x96
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/khelp.x61
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/kpushbk.x11
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/mkpkg32
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/psbeep.x9
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/psbegin.x59
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/psend.x48
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/psfill.x135
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/psheight.x12
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/psintersect.x27
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/psscreen.x14
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/pssendcap.x74
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/pssetcur.x117
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/psslide.x182
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/pssynch.x12
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/pswidth.x12
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/pswrite.x79
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/pswrtcells.x114
-rw-r--r--pkg/utilities/nttools/tedit/display/screen/screen.com18
25 files changed, 1717 insertions, 0 deletions
diff --git a/pkg/utilities/nttools/tedit/display/screen/README b/pkg/utilities/nttools/tedit/display/screen/README
new file mode 100644
index 00000000..6a29f82f
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/README
@@ -0,0 +1,211 @@
+The procedures in this directory implement the lowest level of the
+screen handling routines in the display library. Procedures not
+described in this file are not part of the public interface and should
+not be called by user programs. All the capabilities of the curses
+procedures are layered on top of the procedures in this directory.
+These procedures provide less functionality than the curses routines,
+but can be faster, at the expense of more complications in the user
+program. The procedures in this directory are portable. They are
+written in SPP and they do all their I/O through the IRAF VOS. They
+use the termcap and edcap files so that this library can be used with
+a variety of terminals and the editing commands can be tailored to the
+user's preferences. There are two sets of subroutines in this
+directory. The first set is the keyboard subroutines, prefixed by the
+letter "k", which read the keyboard and translate control key
+sequences to a single character. The second set is the screen
+sunroutines, prefixed by the letters "ps", which write to the
+terminal.
+
+The keyboard subroutines read input from the keyboard, translating
+command key sequences into a single number. The command key sequences
+are read from the edcap file. This is a file located either in the
+user's home directory or the dev$ directory whose name is the value of
+the editor environment variable with an extension of ".ed". See the
+files in the dev$ directory for an example of the file format. The
+keyboard subroutines are initialized by a call to the following
+subroutine:
+
+procedure k_begin (cmdlist)
+
+char cmdlist[ARB] # i: List of editing commands
+
+This subroutine puts the terminal in raw mode, reads the edcap file,
+and sends the keyboard initialization sequence to the terminal. Its
+argument is a list of command names taken from the edcap file that you
+want your program to recognize. The first character in the string is a
+command separator, used to separate the commands in the string. The
+macro CMDSTR in <curses.h> defines the list of commands used by the
+curses routines. The screen initialization routine, ps_begin, must be
+called before k_begin is called. To terminate the keyboard interface,
+call the following subroutine:
+
+procedure k_end ()
+
+This procedure ends raw mode and sends the keyboard termination sequence
+to the terminal. The screen termination routine, ps_end, should be
+called after this routine is called. The following subroutine reads a
+single character from the terminal:
+
+int procedure k_get ()
+
+Command key sequences that were named in the command list passed to
+k_begin are returned as a single number. The value returned by the
+first command key sequence in the command list is K_BASE, the value
+returned by the second sequence is K_BASE+1, and so on. The macro
+K_BASE is defined in <curses.h>.
+
+The next keyboard subroutine returns a pointer to a character string
+containing the help text for the keyboard commands:
+
+procedure k_help (text)
+
+pointer text # o: Help text
+
+The help text string is formatted as a series of command descriptions.
+Each description starts with the name of the edcap command , followed
+by an equals sign, followed by the ascii representation of the key
+sequence which executes the command, and terminated by a newline
+character.The string is formatted as a series of command descriptions.
+Each description starts with the name of the edcap command , followed
+by an equals sign, followed by the ascii representation of the key
+sequence which executes the command, and terminated by a newline
+character.
+
+The following routine copies one of the command descriptions from the
+help text to an output string:
+
+procedure k_eseq (name, eseq, maxch)
+
+char name[ARB] # i: Name bound to command sequence
+char eseq[ARB] # o: String representation of command sequence
+int maxch # i: Maximum length of command sequence
+
+The input parameters are the name of the command sequence and the
+length of the output string. The name of the sequence should be
+the name passed as part of the command string to k_begin(). The output
+is the ascii represntation of the escape sequence of that command.
+
+The screen subroutines are used to send output to the terminal. They
+are based on the subroutines in Marc Rochkind's book, "Advanced C
+Programs for Displays". Several conventions are followed by these
+subroutines. The first is that while strings are passed as arrays of
+characters, individual characters are passed as integers. The second is
+that screen coordinates are passed row first, column second and that the
+coordinates of the upper left corner of the screen are (1, 1). The
+third is that areas on the screen are passed as rectangles, which are
+represented as arrays of four elements, where the four elements are the
+(top, left, bottom, right) corners of the rectangle. The initialization
+and termination routines for the screen subroutines are:
+
+procedure ps_begin ()
+procedure ps_end ()
+
+The first subroutine opens the terminal for I/O and reads the termcap
+file, the second closes the terminal. The calling program get the size
+of the screen by calling the subroutines:
+
+int procedure ps_height ()
+int procedure ps_width ()
+
+These subroutines return the number of screen rows and columns,
+respectively. The following subroutine flushes the output buffer:
+
+procedure ps_synch ()
+
+The user will not see any output sent by these subroutine to the
+terminal until this subroutine is called. To ring the terminal's bell,
+call the following subroutine:
+
+procedure ps_beep ()
+
+To move the cursor on the screen call the following subroutine:
+
+procedure ps_setcur (row, col)
+
+int row # i: Cursor row
+int col # i: Cursor column
+
+To write a string to the screen call the following subroutine:
+
+procedure ps_write (row, col, ncols, str, att)
+
+int row # i: Starting row
+int col # i: Starting column
+int ncols # i: Number of columns to write
+char str[ARB] # i: String to write
+int att # i: Attribute
+
+The number of columns is an upper limit on the number of characters to
+write, if the string is shorter than this, the actual number of
+characters on the screen will be displayed. If the string does not lie
+entirely on the screen, the string will be clipped at the screen boundary.
+The attribute determines whether the string is printed normally or in
+standout mode. The value should be set to either A_NORM or A_STANDOUT,
+which is defined in display.h. To write a string where the screen
+attribute may change from character to characater call the following
+subroutine:
+
+procedure ps_wrtcells (row, col, vector, ncols)
+
+int row # i: Starting row
+int col # i: Starting column
+char vector[ARB] # i: Vector to write
+int ncols # i: Number of columns to write
+
+The string to be written must be at least ncols long and each character
+to be displayed in standout mode should have A_STANDOUT added to its
+ascii code. This subroutine is used when the calling program keeps an
+array whose contents corresponds to the current screen display. To fill
+an area on the screen with a single character call the following
+subroutine:
+
+procedure ps_fill (source, ch, att)
+
+int source[RSIZE] # i: Rectangle
+int ch # i: Fill character
+int att # i: Fill attribute
+
+This subroutine can be used to clear part or all of the screen by
+setting the fill character to blank and the fill attribute to A_NORM.
+The macro RSIZE is equal to 4 and is defined in display.h. To move an
+area of the screen in any of the four directions call the following
+subroutine:
+
+bool procedure ps_slide (source, dir, dist)
+
+int source[RSIZE] # i: Rectangle
+int dir # i: Direction (from display.h)
+int dist # i: Distance (> 0)
+
+This subroutine can be used to scroll the screen up or down, delete one
+or more characters from a line, or move a line over so that a new
+character can be inserted. The direction is given as one of the four
+macros DIR_UP, DIR_DOWN, DIR_LEFT, and DIR_RIGHT, defined in <curses.h>.
+This subroutine may or may not be able to move the screen, depending on
+the capabilities defined in the terminal's termcap file. If the
+subroutine can move the area, it returns true and if it cannot, it
+returns false. In the latter case, it is the responsibility of the
+calling program to redraw the affected area of the screen in order to
+move the area.
+
+The include file display.h contains several macros the can be used to
+manipulate the rectangles passed to the screen subroutines. In order to
+access the elements of a rectangle the following macros can be used:
+
+RTOP(rect) # Top row of a rectangle
+RLEFT(rect) # Left column of a rectangle
+RBOT(rect) # Bottom row of a rectangle
+RRIGHT(rect) # Right column of a rectangle
+
+The dimensions of a rectangle can be computed by the following macros:
+
+RWIDTH(rect) # Number of columns in a rectangle
+RHEIGHT(rect) # Number of rows in a rectangle
+
+A program can set the elements in a rectangle with the following macros:
+
+RASG(newrect, top, left, bottom, right)
+RCPY(newrect, oldrect)
+
+The first macro assigns four scalars to the elements of a rectangle and
+the second macro copies the elements of one rectangle to another.
diff --git a/pkg/utilities/nttools/tedit/display/screen/kbegin.x b/pkg/utilities/nttools/tedit/display/screen/kbegin.x
new file mode 100644
index 00000000..0be12ab6
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/kbegin.x
@@ -0,0 +1,40 @@
+include <fset.h>
+include "../curses.h"
+
+# K_BEGIN -- Initialize keyboard
+#
+# B.Simon 23-Jan-89 Original
+
+procedure k_begin (cmdlist)
+
+char cmdlist[ARB] # i: List of editing commands
+#--
+include "screen.com"
+
+int klen
+int strlen()
+
+extern k_error
+
+begin
+ # NOTE: ps_begin must be called before calling this procedure
+
+ # Put terminal in raw mode
+
+ call fseti (ttyin, F_RAW, YES)
+
+ # Set up error exit routine
+
+ call onerror (k_error)
+
+ # Set up function key table and help screen
+
+ call k_compile (cmdlist)
+
+ # Send initialize keypad sequence to terminal
+
+ klen = strlen (ks)
+ if (klen > 0)
+ call ttywrite (ttyout, term, ks, klen, 1)
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/kcompile.x b/pkg/utilities/nttools/tedit/display/screen/kcompile.x
new file mode 100644
index 00000000..9ad162ec
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/kcompile.x
@@ -0,0 +1,148 @@
+include <ctype.h>
+include "../curses.h"
+
+define SYNTAX 1
+define K_CMDLEN 7
+
+# K_COMPILE -- Compile a file of editing key definitions (edcap)
+#
+# B.Simon 23-Jan-89 Original
+
+procedure k_compile (cmdlist)
+
+char cmdlist[ARB] # i: List of commands
+#--
+include "screen.com"
+
+char sep
+int ic, maxcmd, nkey, maxkey
+int hlength, hwidth, hstart, hleft, fd, tag
+pointer sp, label, escape, name
+
+bool streq()
+int k_capfile(), ps_width(), fscan(), nscan(), strdic(), gstrcpy()
+
+begin
+ # Allocate dynamic memory for strings
+
+ call smark (sp)
+ call salloc (label, SZ_FNAME, TY_CHAR)
+ call salloc (escape, SZ_FNAME, TY_CHAR)
+ call salloc (name, SZ_FNAME, TY_CHAR)
+
+ # Count the number of editing commands
+
+ maxcmd = 0
+ sep = cmdlist[1]
+ for (ic = 1; cmdlist[ic] != EOS; ic = ic + 1) {
+ if (cmdlist[ic] == sep && cmdlist[ic+1] != EOS)
+ maxcmd = maxcmd + 1
+ }
+
+ # Allocate dynamic memory for the function key table
+
+ nkey = 0
+ maxkey = K_CMDLEN * maxcmd
+ call calloc (keytab, 4*maxkey, TY_INT)
+
+ # Set up help text
+
+ hwidth = ps_width() / 2
+ hlength = maxcmd * hwidth
+ call calloc (htext, hlength+1, TY_CHAR)
+ hstart = htext
+ hleft = hlength
+
+ # Add each line from the edcap file to the table of function
+ # key sequences and the help screen
+
+ fd = k_capfile ()
+ while (fscan (fd) != EOF) {
+ call gargwrd (Memc[label], SZ_FNAME)
+ call gargwrd (Memc[escape], SZ_FNAME)
+ call gargwrd (Memc[name], SZ_FNAME)
+
+ # Proceess line only if all three elements of command are present
+ # and command is found in command list
+
+ if (nscan () == 3) {
+
+ if (streq (Memc[label], "EDIT_INIT"))
+ call k_convert (Memc[escape], ks, K_CMDLEN)
+ else if (streq (Memc[label], "EDIT_TERM"))
+ call k_convert (Memc[escape], ke, K_CMDLEN)
+
+ tag = strdic (Memc[label], Memc[label], SZ_FNAME, cmdlist)
+ if (tag > 0) {
+ tag = tag + K_BASE - 1
+
+ # Add escape sequence to function key table
+
+ call k_doline (Memc[escape], tag, maxkey,
+ nkey, Memi[keytab])
+
+ # Add label and name to help text
+
+ if (hleft > hwidth) {
+ hstart = gstrcpy (Memc[label], Memc[hstart], hleft) +
+ hstart
+
+ Memc[hstart] = '='
+ hstart = hstart + 1
+
+ hstart = gstrcpy (Memc[name], Memc[hstart], hleft) +
+ hstart
+
+ Memc[hstart] = '\n'
+ hstart = hstart + 1
+ hleft = hlength - (hstart - htext)
+ }
+ }
+ }
+ }
+
+ Memc[hstart] = EOS
+ call close (fd)
+ call sfree (sp)
+end
+
+# K_CAPFILE -- Open the editing capabilities file (edcap)
+
+int procedure k_capfile ()
+
+#--
+int fd
+pointer sp, editor, edcap
+
+int envgets(), access(), open()
+
+begin
+ # Allocate dynamic memory for strings
+
+ call smark (sp)
+ call salloc (editor, SZ_FNAME, TY_CHAR)
+ call salloc (edcap, SZ_FNAME, TY_CHAR)
+
+ # Get the name of the edcap file and open it
+
+ if (envgets ("editor", Memc[editor], SZ_FNAME) <= 0)
+ call error (SYNTAX, "Editor not found")
+
+ call sprintf (Memc[edcap], SZ_FNAME, "home$%s.ed")
+ call pargstr (Memc[editor])
+
+ if (access (Memc[edcap], READ_ONLY, 0) == NO) {
+
+ call sprintf (Memc[edcap], SZ_FNAME, "dev$%s.ed")
+ call pargstr (Memc[editor])
+
+ if (access (Memc[edcap], READ_ONLY, 0) == NO)
+ call error (SYNTAX, "Edcap file not found")
+
+ }
+
+ fd = open (Memc[edcap], READ_ONLY, TEXT_FILE)
+ call sfree (sp)
+
+ return (fd)
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/kconvert.x b/pkg/utilities/nttools/tedit/display/screen/kconvert.x
new file mode 100644
index 00000000..11e283fa
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/kconvert.x
@@ -0,0 +1,61 @@
+include <ctype.h>
+
+# K_CONVERT -- Convert a string with coded escape sequences to the real thing
+#
+# B.Simon 23-Jan-89 Original
+
+procedure k_convert (escstr, escseq, maxch)
+
+char escstr[ARB] # i: Escape sequence string
+char escseq[ARB] # o: Escape key sequence
+int maxch # i: Declared length of key sequence
+#--
+int ic, jc, index, num
+
+string echars "befnrt"
+string ecodes "\010\033\f\n\r\t"
+
+int stridx()
+
+begin
+ ic = 1
+ for (jc = 1; jc <= maxch; jc = jc + 1) {
+
+ # Exit when all characters in escape string have been processed
+
+ if (escstr[ic] == EOS)
+ break
+
+ # Convert escape sequence
+
+ if (escstr[ic] == '\\') {
+ ic = ic + 1
+ index = stridx (escstr[ic], echars)
+ if (index > 0) {
+ escseq[jc] = ecodes[index]
+ } else if (IS_DIGIT(escstr[ic])) {
+ for (num = 0; IS_DIGIT(escstr[ic]); ic = ic + 1)
+ num = 8 * num + TO_DIGIT(escstr[ic])
+ ic = ic - 1
+ escseq[jc] = num
+ } else {
+ escseq[jc] = escstr[ic]
+ }
+
+ # Convert control sequence
+
+ } else if (escstr[ic] == '^') {
+ ic = ic + 1
+ escseq[jc] = mod (int(escstr[ic]), 32)
+
+ # Copy ordinary character
+
+ } else {
+ escseq[jc] = escstr[ic]
+ }
+
+ ic = ic + 1
+ }
+
+ escseq[jc] = EOS
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/kdoline.x b/pkg/utilities/nttools/tedit/display/screen/kdoline.x
new file mode 100644
index 00000000..bcdf4a72
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/kdoline.x
@@ -0,0 +1,96 @@
+include <ctype.h>
+
+define SYNTAX 1
+define BOUNDS 2
+
+# K_DOLINE -- Add a line containing an escape sequence to the key table
+#
+# B.Simon 23-Jan-89 Original
+
+procedure k_doline (escstr, tag, maxtab, ntab, table)
+
+char escstr[ARB] # i: Key sequence
+int tag # i: Key tag
+int maxtab # i: Maximum number of entries
+int ntab # io: Current number of entries
+int table[4,ARB] # io: Key sequence table
+#--
+int ic, link, new, old
+pointer sp, escseq
+
+int strlen()
+
+string notctrl "Key sequence must begin with a control character"
+string isambig "Ambiguous key sequence"
+string toomany "Too many key definitions"
+
+begin
+ # Convert escape sequence
+
+ call smark (sp)
+ call salloc (escseq, SZ_FNAME, TY_CHAR)
+ call k_convert (escstr, Memc[escseq], SZ_FNAME)
+
+ # Don't process null sequences
+
+ if (Memc[escseq] == EOS)
+ return
+
+ # Check to see if escape sequence is valid
+
+ if (IS_PRINT(Memc[escseq]))
+ call error (SYNTAX, notctrl)
+
+ # Find first character in key sequence that is new
+
+ ic = 0
+ link = 0
+ for (new = 1; new != 0; new = table[link,old]) {
+ old = new
+ if (link == 1)
+ ic = ic + 1
+ if (Memc[escseq+ic] == table[3,old])
+ link = 1
+ else
+ link = 2
+ }
+
+ if (link == 1) {
+
+ # Redefinition of existing sequence
+
+ if (Memc[escseq+ic] != EOS)
+ call error (SYNTAX, isambig)
+ table[4,old] = tag
+
+ } else {
+
+ # New sequence
+
+ if (Memc[escseq+ic] == EOS)
+ call error (SYNTAX, isambig)
+
+ # Check for table overflow
+
+ if (strlen (Memc[escseq+ic]) + ntab > maxtab)
+ call error (BOUNDS, toomany)
+
+ # Insert remainder of key sequence in table
+
+ table[2,old] = ntab + 1
+ while (Memc[escseq+ic] != EOS) {
+ ntab = ntab + 1
+ table[1,ntab] = ntab + 1
+ table[2,ntab] = 0
+ table[3,ntab] = Memc[escseq+ic]
+ table[4,ntab] = 0
+ ic = ic + 1
+ }
+ table[1,ntab] = 0
+ table[4,ntab] = tag
+
+ }
+
+ call sfree (sp)
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/kend.x b/pkg/utilities/nttools/tedit/display/screen/kend.x
new file mode 100644
index 00000000..57130052
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/kend.x
@@ -0,0 +1,49 @@
+include <fset.h>
+
+# K_END -- Terminate keyboard
+#
+# B.Simon 23-Jan-89 Original
+
+procedure k_end ()
+
+#--
+include "screen.com"
+
+int klen
+int strlen()
+
+begin
+ # Restore keyboard to original state and end raw mode
+
+ if (ttyin != NULL) {
+ if (term != NULL) {
+ klen = strlen (ke)
+ if (klen > 0)
+ call ttywrite (ttyout, term, ke, klen, 1)
+ }
+ call fseti (ttyin, F_RAW, NO)
+ }
+
+ # Release dynamic memory
+
+ if (keytab != NULL)
+ call mfree (keytab, TY_INT)
+
+ if (htext != NULL)
+ call mfree (htext, TY_CHAR)
+
+end
+
+# K_ERROR -- Procedure called on error exit
+
+procedure k_error (status)
+
+int status # i: Error status
+#--
+
+begin
+ if (status != OK) {
+ call k_end
+ call ps_end
+ }
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/kget.x b/pkg/utilities/nttools/tedit/display/screen/kget.x
new file mode 100644
index 00000000..61364f9e
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/kget.x
@@ -0,0 +1,96 @@
+include <ctype.h>
+
+define CAN_ABORT NO
+define ABORT '\003'
+
+# K_GET -- Read a character, translating function keys
+
+int procedure k_get ()
+
+#--
+include "screen.com"
+
+int ch
+
+int first
+int k_cget(), k_lookup()
+
+string abortmsg "Task aborted by ^C"
+
+begin
+ if (keych != EOF) {
+ # Check for a pushed back character, returning it if found
+
+ ch = keych
+ keych = EOF
+
+ } else {
+ # Check character to see if it is the start of a control sequence
+ # If not, return the character without searching the table
+
+ first = k_cget ()
+
+ if (IS_PRINT(first))
+ ch = first
+ else if ((CAN_ABORT == YES) && (first == ABORT))
+ call error (1, abortmsg)
+ else
+ ch = k_lookup (first, Memi[keytab])
+ }
+
+ return (ch)
+
+end
+
+# K_LOOKUP -- Look up a function key sequence in a table
+
+int procedure k_lookup (first, table)
+
+int first # i: First character in the sequence
+int table[4,ARB] # i: Table of function key sequences
+#--
+include "screen.com"
+
+int key, new, old, link
+int k_cget()
+
+begin
+ # Search the table for the control sequence
+
+ link = 0
+ key = first
+
+ for (new = 1; new != 0; new = table[link,old]) {
+ old = new
+ if (link == 1)
+ key = k_cget ()
+ if (key == table[3,old])
+ link = 1
+ else
+ link = 2
+ }
+
+ # Return the control sequence tag if the sequence was found,
+ # otherwise return the first unrecognized key
+
+ if (link == 1)
+ key = table[4,old]
+
+ return (key)
+
+end
+
+# K_CGET -- Read a single character from the terminal
+
+int procedure k_cget ()
+
+#--
+include "screen.com"
+
+int ch
+int and(), getci()
+
+begin
+ ch = getci (ttyin, ch)
+ return (and (ch, 177B))
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/khelp.x b/pkg/utilities/nttools/tedit/display/screen/khelp.x
new file mode 100644
index 00000000..4b075f8a
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/khelp.x
@@ -0,0 +1,61 @@
+include <fset.h>
+
+# K_HELP -- Retrieve help text for function key sequences
+
+procedure k_help (text)
+
+pointer text # o: Help text
+#--
+include "screen.com"
+
+begin
+ text = htext
+end
+
+procedure k_eseq (name, eseq, maxch)
+
+char name[ARB] # i: Name bound to escape sequence
+char eseq[ARB] # o: String representation of escape sequence
+int maxch # i: Maximum length of escape sequence
+#--
+include "screen.com"
+
+bool match, in_name
+int ic
+pointer ch
+
+begin
+ ic = 1
+ match = true
+ in_name = true
+
+ for (ch = htext; Memc[ch] != EOS; ch = ch + 1) {
+ if (in_name) {
+ if (Memc[ch] == '=') {
+ match = match && name[ic] == EOS
+ in_name = false
+ ic = 1
+ } else if (match) {
+ if (Memc[ch] == name[ic]) {
+ ic = ic + 1
+ } else {
+ match = false
+ }
+ }
+
+ } else {
+ if (Memc[ch] == '\n') {
+ if (match)
+ break
+ ic = 1
+ match = true
+ in_name = true
+ } else if (match && ic <= maxch) {
+ eseq[ic] = Memc[ch]
+ ic = ic + 1
+ }
+ }
+ }
+ eseq[ic] = EOS
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/kpushbk.x b/pkg/utilities/nttools/tedit/display/screen/kpushbk.x
new file mode 100644
index 00000000..6e9c05c2
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/kpushbk.x
@@ -0,0 +1,11 @@
+# K_PUSHBK -- Push back a single character read from the keyboard
+
+procedure k_pushbk (ch)
+
+int ch # i: character to be pushed back
+#--
+include "screen.com"
+
+begin
+ keych = ch
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/mkpkg b/pkg/utilities/nttools/tedit/display/screen/mkpkg
new file mode 100644
index 00000000..dc062ae4
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/mkpkg
@@ -0,0 +1,32 @@
+# Update the display library.
+# Author: B.Simon 01-APR-91
+
+$checkout libpkg.a ../../
+$update libpkg.a
+$checkin libpkg.a ../../
+$exit
+
+libpkg.a:
+ kbegin.x <fset.h> "../curses.h" "screen.com"
+ kcompile.x <ctype.h> "../curses.h" "screen.com"
+ kconvert.x <ctype.h>
+ kdoline.x <ctype.h>
+ kend.x <fset.h> "screen.com"
+ kget.x <ctype.h> "screen.com"
+ khelp.x "screen.com"
+ kpushbk.x "screen.com"
+ psbegin.x <ttyset.h> "screen.com"
+ psbeep.x
+ psend.x "screen.com"
+ psfill.x <ctype.h> "../curses.h" "screen.com"
+ psheight.x "screen.com"
+ psintersect.x "../curses.h"
+ psscreen.x "screen.com"
+ pssendcap.x "screen.com"
+ pssetcur.x "screen.com"
+ psslide.x "../curses.h" "screen.com"
+ pssynch.x "screen.com"
+ pswidth.x "screen.com"
+ pswrite.x <ctype.h> "../curses.h" "screen.com"
+ pswrtcells.x <ctype.h> "../curses.h" "screen.com"
+ ;
diff --git a/pkg/utilities/nttools/tedit/display/screen/psbeep.x b/pkg/utilities/nttools/tedit/display/screen/psbeep.x
new file mode 100644
index 00000000..252991ba
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/psbeep.x
@@ -0,0 +1,9 @@
+# PS_BEEP -- Sound the bell
+#
+# B.Simon 19-Jan-89 Original
+
+procedure ps_beep ()
+
+begin
+ call ps_sendcap ("bl", 1)
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/psbegin.x b/pkg/utilities/nttools/tedit/display/screen/psbegin.x
new file mode 100644
index 00000000..2bf702cf
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/psbegin.x
@@ -0,0 +1,59 @@
+include <ttyset.h>
+include "../curses.h"
+
+# PS_BEGIN -- Initialize physical screen display
+#
+# B.Simon 18-Jan-89 Original
+# B.Simon 26-Sep-90 Updated to use screen buffer
+
+procedure ps_begin ()
+
+#--
+include "screen.com"
+
+char ch
+data ch / EOS /
+
+string nomove "Terminal does not support cursor movement (cm)"
+
+bool ttygetb()
+int ttopen(), ttystati()
+pointer ttyodes()
+
+begin
+ # Initialize global variables
+
+ ks[1] = EOS
+ ke[1] = EOS
+ keych = EOF
+
+ currow = GIANT
+ curcol = GIANT
+
+ keytab = NULL
+ termscr = NULL
+ htext = NULL
+
+ term = ttyodes ("terminal")
+ lines = ttystati (term, TTY_NLINES)
+ cols = ttystati (term, TTY_NCOLS)
+
+ if (! ttygetb (term, "cm")) {
+ call ttyclose (term)
+ call error (1, nomove)
+ }
+
+ ttyin = ttopen ("dev$tty", READ_ONLY)
+ ttyout = ttopen ("dev$tty", APPEND)
+
+ # Allocate memory for screen and fill with EOS
+
+ call malloc (termscr, lines*cols, TY_CHAR)
+ call amovkc (ch, Memc[termscr], lines*cols)
+
+ # Initialize display
+
+ call ps_sendcap ("ti", 1)
+ call ps_sendcap ("vs", 1)
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/psend.x b/pkg/utilities/nttools/tedit/display/screen/psend.x
new file mode 100644
index 00000000..1d86e6df
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/psend.x
@@ -0,0 +1,48 @@
+# PS_END -- Terminate physical display package
+#
+# B.Simon 18-Jan-89 Original
+# B.Simon 26-Sep-90 Updated to use screen buffer
+
+procedure ps_end()
+
+#--
+include "screen.com"
+
+char newline
+data newline / '\n' /
+
+begin
+ # Restore terminal to original state and release termcap structure
+
+ if (term != NULL) {
+ call ps_sendcap ("ve", 1)
+ call ps_sendcap ("te", 1)
+
+ if (ttyout != NULL) {
+ call ttygoto (ttyout, term, 1, lines)
+ call putc (ttyout, newline)
+ }
+ call ttyclose (term)
+ term = NULL
+ }
+
+ # Release screen memory
+
+ if (termscr != NULL) {
+ call mfree (termscr, TY_CHAR)
+ termscr = NULL
+ }
+
+ # Close terminal descriptor
+
+ if (ttyin != NULL) {
+ call close (ttyin)
+ ttyin = NULL
+ }
+
+ if (ttyout != NULL) {
+ call close (ttyout)
+ ttyout = NULL
+ }
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/psfill.x b/pkg/utilities/nttools/tedit/display/screen/psfill.x
new file mode 100644
index 00000000..2ceee221
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/psfill.x
@@ -0,0 +1,135 @@
+include <ctype.h>
+include "../curses.h"
+
+# PS_FILL -- Fill a rectangle with a single character and attribute
+#
+# B.Simon 19-Jan-89 Original
+# B.Simon 26-Sep-90 Updated to use screen buffer
+# B.Simon 31-Oct-90 Changed to skip correct lines
+
+procedure ps_fill (source, ch, att)
+
+int source[RSIZE] # i: Rectangle
+int ch # i: Fill character
+int att # i: Fill attribute
+#--
+include "screen.com"
+
+bool canclear, bufflag
+char blank, fill, cell
+int dest[RSIZE]
+int ncols, nrows, irow, icol
+pointer sp, buf, scr
+
+data blank / ' ' /
+
+bool ps_intersect(), ttygetb()
+pointer ps_screen()
+
+begin
+ # Clip the rectangle to the screen boundary
+ # If the rectangle is entirely off the screen, return
+
+ if (! ps_intersect (source, lines, cols, dest))
+ return
+
+
+ # Check for the special cases:
+ # Clear entire screen (cl) and clear to end of screen (cd)
+
+ canclear = (ch == ' ' && att == A_NORM)
+ ncols = RWIDTH(dest)
+ nrows = RHEIGHT(dest)
+
+ if (canclear && ncols == cols && nrows == lines) {
+ if (ttygetb (term, "cl")) {
+ call ps_updcur (1, 1)
+ call ps_sendcap ("cl", nrows)
+ call amovkc (blank, Memc[termscr], lines*cols)
+ return
+ }
+ }
+
+ if (canclear && ncols == cols && RBOT(dest) == lines) {
+ if (ttygetb (term, "cd")) {
+ call ps_setcur (RTOP(dest), 1)
+ call ps_sendcap ("cd", nrows)
+ scr = ps_screen (RTOP(dest), 1)
+ call amovkc (blank, Memc[scr], nrows*cols)
+ return
+ }
+ }
+
+ # Write the rectangle a line at a time
+
+ call smark (sp)
+ call salloc (buf, cols, TY_CHAR)
+
+ if (IS_PRINT(ch))
+ fill = ch
+ else
+ fill = blank
+
+ cell = fill + att
+ bufflag = false
+
+ canclear = canclear && ttygetb (term, "ce")
+
+ do irow = RTOP(dest), RBOT(dest) {
+
+ # Check to see if line is already correct
+ # If so, skip to the next line
+
+ scr = ps_screen (irow, RLEFT(dest))
+
+ for (icol = 1; icol <= ncols; icol = icol + 1) {
+ if (Memc[scr+icol-1] != cell)
+ break
+ }
+
+ if (icol > ncols)
+ next
+
+ # Move cursor to beginning of line and set attribute
+
+ call ps_setcur (irow, RLEFT(dest))
+
+ if (att != A_NORM)
+ call ps_sendcap ("so", 1)
+
+ # Special case: clear to end of line
+
+ if (canclear && RRIGHT(dest) == cols) {
+ call ps_sendcap ("ce", 1)
+ call amovkc (blank, Memc[scr], ncols)
+
+ } else {
+
+ # Fill buffer with character and write to terminal
+
+ if (! bufflag) {
+ bufflag = true
+ call amovkc (fill, Memc[buf], ncols)
+ }
+
+ # Don't write to lower right corner if screen will scroll
+
+ if (irow == lines && RRIGHT(dest) == cols) {
+ if (ttygetb (term, "am"))
+ ncols = ncols - 1
+ }
+
+ call write (ttyout, Memc[buf], ncols)
+ call amovkc (cell, Memc[scr], ncols)
+ call ps_updcur (irow, RRIGHT(dest) + 1)
+ }
+
+ # Set attribute back to normal
+
+ if (att != A_NORM)
+ call ps_sendcap ("se", 1)
+
+ }
+
+ call sfree (sp)
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/psheight.x b/pkg/utilities/nttools/tedit/display/screen/psheight.x
new file mode 100644
index 00000000..8350e773
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/psheight.x
@@ -0,0 +1,12 @@
+# PS_HEIGHT -- Get height of physical screen
+#
+# B.Simon 18-Jan-89 Original
+
+int procedure ps_height ()
+
+#--
+include "screen.com"
+
+begin
+ return (lines)
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/psintersect.x b/pkg/utilities/nttools/tedit/display/screen/psintersect.x
new file mode 100644
index 00000000..93c11f0f
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/psintersect.x
@@ -0,0 +1,27 @@
+include "../curses.h"
+
+# PS_INTERSECT -- Intersection between two rectangles
+#
+# B.Simon 18-Jan-89 Original
+
+bool procedure ps_intersect (source, maxrow, maxcol, dest)
+
+int source[RSIZE] # i: Source rectangle
+int maxrow # i: Max row of clipping rectangle
+int maxcol # i: Max column of clipping rectangle
+int dest[RSIZE] # o: Destination rectangle
+#--
+
+begin
+ # Clip source rectangle to (1,1) and (maxrow,maxcol)
+
+ RTOP(dest) = max (1, RTOP(source))
+ RLEFT(dest) = max (1, RLEFT(source))
+ RBOT(dest) = min (maxrow, RBOT(source))
+ RRIGHT(dest) = min (maxcol, RRIGHT(source))
+
+ # Return true if intersection is non-empty
+
+ return (RTOP(dest) <= RBOT(dest) && RLEFT(dest) <= RRIGHT(dest))
+end
+
diff --git a/pkg/utilities/nttools/tedit/display/screen/psscreen.x b/pkg/utilities/nttools/tedit/display/screen/psscreen.x
new file mode 100644
index 00000000..afdd7b8d
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/psscreen.x
@@ -0,0 +1,14 @@
+# PS_SCREEN -- Return a pointer to a given character on the screen
+#
+# B.Simon 28-Sep-90 Original
+
+pointer procedure ps_screen (row, col)
+
+int row # i: Screen line
+int col # i: Screen column
+#--
+include "screen.com"
+
+begin
+ return (termscr+cols*(row-1)+(col-1))
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/pssendcap.x b/pkg/utilities/nttools/tedit/display/screen/pssendcap.x
new file mode 100644
index 00000000..295a6cff
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/pssendcap.x
@@ -0,0 +1,74 @@
+# PS_SENDCAP -- Send a termcap command to the terminal
+#
+# B.Simon 18-Jan-89 Original
+
+procedure ps_sendcap (cap, affcnt)
+
+char cap[ARB] # i: Termcap capability name
+int affcnt # i: Number of lines affected by the command
+#--
+include "screen.com"
+
+int nchar
+pointer sp, capstr
+
+int ttygets()
+
+begin
+ call smark (sp)
+ call salloc (capstr, SZ_FNAME, TY_CHAR)
+
+ # Retrieve the termcap capability string given its name
+ # If it is found, write it to the terminal
+
+ nchar = ttygets (term, cap, Memc[capstr], SZ_FNAME)
+ if (nchar > 0) {
+ call ttywrite (ttyout, term, Memc[capstr], nchar, affcnt)
+ ## call ps_debugcap (cap, Memc[capstr], nchar)
+ }
+
+ call sfree (sp)
+end
+
+# PS_DEBUGCAP -- Print a termcap string for debugging purposes
+
+procedure ps_debugcap (capname, capstr, nchar)
+
+char capname[ARB] # i: Termcap capability name
+char capstr[ARB] # i: Termcap capability string
+int nchar # i: Number of characters in string
+#--
+include "screen.com"
+
+char ch
+int ic, jc
+pointer sp, out
+
+begin
+ # Allocate memory for strings
+
+ call smark (sp)
+ call salloc (out, SZ_LINE, TY_CHAR)
+
+ jc = 0
+ do ic = 1, nchar {
+ ch = capstr[ic]
+ if (ch < ' ') {
+ Memc[out+jc] = '^'
+ jc = jc + 1
+ ch = ch + '@'
+ }
+ Memc[out+jc] = ch
+ jc = jc + 1
+ }
+ Memc[out+jc] = EOS
+
+ # Write string to STDOUT and flush
+
+ call fprintf (ttyout, "%s = %s\n")
+ call pargstr (capname)
+ call pargstr (Memc[out])
+ call flush (ttyout)
+
+ call sfree (sp)
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/pssetcur.x b/pkg/utilities/nttools/tedit/display/screen/pssetcur.x
new file mode 100644
index 00000000..a6954da3
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/pssetcur.x
@@ -0,0 +1,117 @@
+define ABSOLUTE YES # disable relative cursor motion if YES
+
+# PS_SETCUR -- Set the cursor position
+#
+# B.Simon 19-Jan-89 Original
+# B.Simon 19-Dec-90 Rewritten to speed cursor motion
+# B.Simon 10-Apr-91 Add switch to disable relative motion
+
+procedure ps_setcur (row, col)
+
+int row # i: Cursor row
+int col # i: Cursor column
+#--
+include "screen.com"
+
+bool moved
+int newrow, newcol, dr, dc
+
+bool ttygetb()
+
+begin
+ newrow = min (lines, max (1, row))
+ newcol = min (cols, max (1, col))
+
+ moved = true
+ dr = newrow - currow
+ dc = newcol - curcol
+
+ if (ABSOLUTE == YES) {
+ if (dr != 0 || dc != 0)
+ moved = false
+
+ } else if (dr == 0) {
+ if (dc == 0) { # no move
+ return
+
+ } else if (dc == 1) { # move right by one
+ if (ttygetb (term, "nd"))
+ call ps_sendcap ("nd", 1)
+ else
+ moved = false
+
+ } else if (dc == -1) { # move left by one
+ if (ttygetb (term, "le"))
+ call ps_sendcap ("le", 1)
+ else
+ moved = false
+
+ } else {
+ moved = false
+ }
+
+ } else if (dr == 1) {
+ if (dc == 0) { # move down by one
+ if (ttygetb (term, "do"))
+ call ps_sendcap ("do", 1)
+ else
+ moved = false
+
+ } else {
+ moved = false
+ }
+
+ } else if (dr == -1) {
+ if (dc == 0) { # move up by one
+ if (ttygetb (term, "up"))
+ call ps_sendcap ("up", 1)
+ else
+ moved = false
+ } else {
+ moved = false
+ }
+
+ } else {
+ moved = false
+ }
+
+ if (! moved) # must use absolute move
+ call ttygoto (ttyout, term, newcol, newrow)
+
+ # Update current cursor position
+
+ currow = newrow
+ curcol = newcol
+end
+
+# PS_UPDCUR -- Update the cursor position
+
+procedure ps_updcur (row, col)
+
+int row # i: New cursor row
+int col # i: New cursor column
+#--
+include "screen.com"
+
+bool ttygetb()
+
+begin
+ if (row >= lines) {
+ currow = lines
+ } else {
+ currow = row
+ }
+
+ if (col >= cols) {
+ if (ttygetb (term, "am")) {
+ currow = min (row + 1, lines)
+ curcol = 1
+ } else {
+ curcol = cols
+ }
+
+ } else {
+ curcol = col
+ }
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/psslide.x b/pkg/utilities/nttools/tedit/display/screen/psslide.x
new file mode 100644
index 00000000..5ad0bc5d
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/psslide.x
@@ -0,0 +1,182 @@
+include "../curses.h"
+
+# PS_SLIDE -- Slide a rectangle on the screen
+#
+# B.Simon 19-Jan-89 Original
+# B.Simon 26-Sep-90 Updated to use screen buffer
+# B.Simon 22-Mar-91 Fix error in left & right slides
+
+bool procedure ps_slide (source, dir, dist)
+
+int source[RSIZE] # i: Rectangle
+int dir # i: Direction (from curses.h)
+int dist # i: Distance (> 0)
+#--
+include "screen.com"
+
+char blank
+int dest[RSIZE]
+int nrows, ncols, irow, icol
+pointer oldscr, newscr, linscr
+
+data blank / ' ' /
+
+bool ps_intersect(), ttygetb()
+pointer ps_screen()
+
+begin
+ if (! ps_intersect (source, lines, cols, dest))
+ return (true)
+
+ ncols = RWIDTH(dest)
+ nrows = RHEIGHT(dest)
+
+ switch (dir) {
+ case DIR_UP:
+ if (RLEFT(dest) != 1 || RRIGHT(dest) != cols)
+ return (false)
+ if ( !(ttygetb (term, "al") && ttygetb (term, "dl")))
+ return (false)
+
+ call ps_setcur (max (1, RTOP(dest)-dist), 1)
+ do irow = 1, dist
+ call ps_sendcap ("dl", lines - RTOP(dest) + dist)
+
+ if (RBOT(dest) < lines) {
+ call ps_setcur (RBOT(dest) + 1, 1)
+ do irow = 1, dist
+ call ps_sendcap ("al", lines - RBOT(dest))
+ }
+
+ oldscr = ps_screen (RTOP(dest), 1)
+ newscr = ps_screen (RTOP(dest)-dist, 1)
+ do irow = 1, nrows-dist {
+ if (newscr >= termscr)
+ call amovc (Memc[oldscr], Memc[newscr], ncols)
+ oldscr = oldscr + cols
+ newscr = newscr + cols
+ }
+ do irow = 1, dist {
+ if (newscr < (termscr + lines * cols))
+ call amovkc (blank, Memc[newscr], ncols)
+ newscr = newscr + cols
+ }
+
+ case DIR_DOWN:
+ if (RLEFT(dest) != 1 || RRIGHT(dest) != cols)
+ return (false)
+ if ( !(ttygetb (term, "al") && ttygetb (term, "dl")))
+ return (false)
+
+ call ps_setcur (min (lines, RBOT(dest)+1), 1)
+ do irow = 1, dist
+ call ps_sendcap ("dl", lines - RBOT(dest))
+
+ call ps_setcur (RTOP(dest), 1)
+ do irow = 1, dist
+ call ps_sendcap ("al", lines - RTOP(dest))
+
+ oldscr = ps_screen (RBOT(dest), 1)
+ newscr = ps_screen (RBOT(dest)+dist, 1)
+ do irow = 1, nrows-dist {
+ if (newscr < (termscr + lines * cols))
+ call amovc (Memc[oldscr], Memc[newscr], ncols)
+ oldscr = oldscr - cols
+ newscr = newscr - cols
+ }
+ do irow = 1, dist {
+ if (newscr >= termscr)
+ call amovkc (blank, Memc[newscr], ncols)
+ newscr = newscr - cols
+ }
+
+ case DIR_LEFT:
+ if (! ((ttygetb (term, "ic") || ttygetb (term, "im")) &&
+ ttygetb (term, "dc")))
+ return (false)
+
+ do irow = RTOP(dest), RBOT(dest) {
+
+ call ps_setcur (irow, max (1, RLEFT(dest)-dist))
+ call ps_sendcap ("dm", 1)
+ do icol = 1, dist
+ call ps_sendcap ("dc", 1)
+ call ps_sendcap ("ed", 1)
+
+ if (RRIGHT(dest) < cols) {
+ call ps_setcur (irow, RRIGHT(dest) - dist + 1)
+ call ps_sendcap ("im", 1)
+ do icol = 1, dist {
+ call ps_sendcap ("ic", 1)
+ call ps_sendcap ("ip", 1)
+ call putc (ttyout, blank)
+ }
+ call ps_sendcap ("ei", 1)
+ call ps_updcur (irow, RRIGHT(dest) + 1)
+ }
+
+ linscr = ps_screen (irow,1)
+ oldscr = ps_screen (irow,RLEFT(dest))
+ newscr = oldscr - dist
+
+ do icol = 1, ncols-dist+1 {
+ if (newscr >= linscr)
+ Memc[newscr] = Memc[oldscr]
+ oldscr = oldscr + 1
+ newscr = newscr + 1
+ }
+
+ do icol = 1, dist {
+ if (newscr < linscr + cols)
+ Memc[newscr] = blank
+ newscr = newscr + 1
+ }
+ }
+ case DIR_RIGHT:
+ if (! ((ttygetb (term, "ic") || ttygetb (term, "im")) &&
+ ttygetb (term, "dc")))
+ return (false)
+
+ do irow = RTOP(dest), RBOT(dest) {
+
+ if (RRIGHT(dest) < cols - 1) {
+ call ps_setcur (irow, RRIGHT(dest) + 1)
+ call ps_sendcap ("dm", 1)
+ do icol = 1, dist
+ call ps_sendcap ("dc", 1)
+ call ps_sendcap ("ed", 1)
+ }
+
+ call ps_setcur (irow, RLEFT(dest))
+ call ps_sendcap ("im", 1)
+ do icol = 1, dist {
+ call ps_sendcap ("ic", 1)
+ call ps_sendcap ("ip", 1)
+ call putc (ttyout, blank)
+ }
+ call ps_sendcap ("ei", 1)
+ call ps_updcur (irow, RLEFT(dest) + dist)
+
+ linscr = ps_screen (irow,1)
+ oldscr = ps_screen (irow,RRIGHT(dest))
+ newscr = oldscr + dist
+
+ do icol = 1, ncols-dist+1 {
+ if (newscr < linscr + cols)
+ Memc[newscr] = Memc[oldscr]
+ oldscr = oldscr - 1
+ newscr = newscr - 1
+ }
+
+ do icol = 1, dist {
+ if (newscr >= linscr)
+ Memc[newscr] = blank
+ newscr = newscr - 1
+ }
+ }
+ default:
+ return (false)
+ }
+
+ return (true)
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/pssynch.x b/pkg/utilities/nttools/tedit/display/screen/pssynch.x
new file mode 100644
index 00000000..a91474c8
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/pssynch.x
@@ -0,0 +1,12 @@
+# PS_SYNCH -- Bring screen up to date
+#
+# B.Simon 18-Jan-89 Original
+
+procedure ps_synch ()
+
+#--
+include "screen.com"
+
+begin
+ call flush (ttyout)
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/pswidth.x b/pkg/utilities/nttools/tedit/display/screen/pswidth.x
new file mode 100644
index 00000000..d06a190c
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/pswidth.x
@@ -0,0 +1,12 @@
+# PS_WIDTH -- Get width of physical screen
+#
+# B.Simon 18-Jan-89 Original
+
+int procedure ps_width ()
+
+#--
+include "screen.com"
+
+begin
+ return (cols)
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/pswrite.x b/pkg/utilities/nttools/tedit/display/screen/pswrite.x
new file mode 100644
index 00000000..ea8de0af
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/pswrite.x
@@ -0,0 +1,79 @@
+include <ctype.h>
+include "../curses.h"
+
+# PS_WRITE -- Write a string on the physical screen
+#
+# B.Simon 18-Jan-89 Original
+# B.Simon 26-Sep-90 Updated to use screen buffer
+
+procedure ps_write (row, col, ncols, str, att)
+
+int row # i: Starting row
+int col # i: Starting column
+int ncols # i: Number of columns to write
+char str[ARB] # i: String to write
+int att # i: Attribute
+#--
+include "screen.com"
+
+char blank
+int colstart, colend, idxstart, idxend, idx
+pointer scr
+
+data blank / ' ' /
+
+bool ttygetb()
+int strlen()
+pointer ps_screen()
+
+begin
+ # Don't try to print if string is entirely off the screen
+
+ if (row < 1 || row > lines || col > cols)
+ return
+
+ # Compute the portion of the string that is on the screen
+
+ colstart = max (col, 1)
+ colend = min (ncols, strlen(str)) + col - 1
+ colend = min (colend, cols)
+
+ if (colend == cols && row == lines) {
+ if (ttygetb (term, "am"))
+ colend = colend - 1
+ }
+
+ if (colend < colstart)
+ return
+
+ idxstart = colstart - col + 1
+ idxend = colend - col + 1
+
+ # Move the cursor to the position of the first printed character
+
+ call ps_setcur (row, colstart)
+
+ # Print the string with the proper attribute
+ # All non-printing characters are printed as blanks
+
+ if (att != A_NORM)
+ call ps_sendcap ("so", 1)
+
+ scr = ps_screen (row, colstart)
+ do idx = idxstart, idxend {
+ if (IS_PRINT(str[idx])) {
+ call putc (ttyout, str[idx])
+ Memc[scr] = str[idx] + att
+ } else {
+ call putc (ttyout, blank)
+ Memc[scr] = blank + att
+ }
+ scr = scr + 1
+ }
+
+ if (att != A_NORM)
+ call ps_sendcap ("se", 1)
+
+ call ps_updcur (row, colend + 1)
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/pswrtcells.x b/pkg/utilities/nttools/tedit/display/screen/pswrtcells.x
new file mode 100644
index 00000000..0e080121
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/pswrtcells.x
@@ -0,0 +1,114 @@
+include <ctype.h>
+include "../curses.h"
+
+# PS_WRTCELLS -- Write a vector of cells
+#
+# B.Simon 19-Jan-89 Original
+# B.Simon 26-Sep-90 Updated to use screen buffer
+
+procedure ps_wrtcells (row, col, vector, ncols)
+
+int row # i: Starting row
+int col # i: Starting column
+char vector[ARB] # i: Vector to write
+int ncols # i: Number of columns to write
+#--
+include "screen.com"
+
+char blank, att, ch
+int colstart, colend, idxstart, idxend, idx
+pointer scr
+
+data blank / ' ' /
+
+bool ttygetb()
+pointer ps_screen()
+
+begin
+ # Don't try to print if vector is entirely off the screen
+
+ if (row < 1 || row > lines || col > cols)
+ return
+
+ # Compute the portion of the vector that is on the screen
+
+ colstart = max (col, 1)
+ colend = min (ncols + col - 1, cols)
+
+ if (colend == cols && row == lines) {
+ if (ttygetb (term, "am"))
+ colend = colend - 1
+ }
+
+ idxstart = colstart - col + 1
+ idxend = colend - col + 1
+
+ # Adjust string start and end so that portions that
+ # duplicate the current screen contents are not printed
+
+ scr = ps_screen (row, colend)
+ while (idxend >= idxstart) {
+ if (vector[idxend] != Memc[scr])
+ break
+
+ colend = colend - 1
+ idxend = idxend - 1
+ scr = scr - 1
+ }
+
+ scr = ps_screen (row, colstart)
+ while (idxstart <= idxend) {
+ if (vector[idxstart] != Memc[scr])
+ break
+
+ colstart = colstart + 1
+ idxstart = idxstart + 1
+ scr = scr + 1
+ }
+
+ if (colend < colstart)
+ return
+
+ # Move the cursor to the position of the first printed character
+
+ call ps_setcur (row, colstart)
+
+ # Print the vector
+
+ att = 0
+ do idx = idxstart, idxend {
+
+ # Set the proper attribute
+
+ if (vector[idx] < A_STANDOUT) {
+ ch = vector[idx]
+ if (att != 0) {
+ att = 0
+ call ps_sendcap ("se", 1)
+ }
+ } else {
+ ch = vector[idx] - A_STANDOUT
+ if (att == 0) {
+ att = vector[idx] - ch
+ call ps_sendcap ("so", 1)
+ }
+ }
+
+ # Print non-printing character as blank
+
+ if (IS_PRINT(ch)) {
+ call putc (ttyout, ch)
+ Memc[scr] = ch + att
+ } else {
+ call putc (ttyout, blank)
+ Memc[scr] = blank + att
+ }
+ scr = scr + 1
+ }
+
+ if (att != 0)
+ call ps_sendcap ("se", 1)
+
+ call ps_updcur (row, colend + 1)
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/screen/screen.com b/pkg/utilities/nttools/tedit/display/screen/screen.com
new file mode 100644
index 00000000..5a13cd02
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/screen/screen.com
@@ -0,0 +1,18 @@
+# SCREEN.COM -- Global variables used by the screen routines
+
+pointer keytab # Table of function key sequences
+pointer termscr # Copy of terminal screen contents
+pointer htext # Function key help text
+pointer term # The termcap data structure
+int ttyin # Input file descriptor for the terminal
+int ttyout # Output file descriptor for the terminal
+int lines # The number of lines on the screen
+int cols # The number of columns on the screen
+int currow # Cursor row
+int curcol # Cursor column
+int keych # Pushed back keyboard character
+char ks[7] # Initialize keypad sequence
+char ke[7] # Terminate keypad sequence
+
+common /screen/ keytab, termscr, htext, ttyin, ttyout, term,
+ lines, cols, currow, curcol, keych, ks, ke