aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/tedit/display/curses
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /pkg/utilities/nttools/tedit/display/curses
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/utilities/nttools/tedit/display/curses')
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/README387
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/addch.x30
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/addstr.x157
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/bindstruct.x35
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/box.x56
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/clear.x35
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/clearok.x21
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/clrtobot.x56
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/clrtoeol.x45
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/delch.x41
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/deleteln.x41
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/delwin.x42
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/echo.x23
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/endwin.x34
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/erase.x37
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/freescreen.x13
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/getch.x53
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/getscreen.x48
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/getstr.x317
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/getstruct.x27
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/getyx.x22
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/hidewin.x40
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/inch.x49
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/initscr.x33
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/insch.x51
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/insertln.x41
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/leaveok.x21
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/mkpkg49
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/move.x39
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/mvwin.x63
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/mvword.x56
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/newwin.x83
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/omkpkg65
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/putscreen.x84
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/refresh.x42
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/savewin.x23
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/scrollok.x21
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/showwin.x39
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/standout.x48
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/wdimen.x45
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/window.com7
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/window.h28
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/winstat.x51
-rw-r--r--pkg/utilities/nttools/tedit/display/curses/wslide.x91
44 files changed, 2589 insertions, 0 deletions
diff --git a/pkg/utilities/nttools/tedit/display/curses/README b/pkg/utilities/nttools/tedit/display/curses/README
new file mode 100644
index 00000000..67220c91
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/README
@@ -0,0 +1,387 @@
+The procedures in this directory are an implementation of the Unix
+curses library, with a few deletions and extensions. The procedures
+have been modified to work in an SPP environment instead of a C
+environment. Unlike the C routines, they do not return an error status
+as a function value. In fact, very few of the procedures call error,
+instead they try to do the most reasonable thing. The mv macros are
+not implemented, instead the program should call move() followed by
+the appropriate procedure. Formatted reads and writes to windows are
+not supported, all reading and writing is done using strings.
+Subwindows are also not supported. The user program does not have
+direct access to the window structure, the function winstat() is
+provided to read fields from the structure. In order to make
+customization of windows easier, each window can have an input
+function and data structure bound to it. The functions bindstruct()
+and getstruct() are provided for this purpose. The forms directory
+gives several examples of binding functions and data structures to a
+window. Two other procedures hidewin() and showwin() are provided to
+hide a window which is currently displayed on the terminal and to
+redisplay it.
+
+The procedure initscr() should be called before using any of the
+procedures in the curses directory. It initializes the terminal and
+creates the first window (referred to as STDSCR), which covers the
+terminal scrren. The procedure endwin() should be called at the end of
+the user program. It closes any windows which are still open and
+resets the terminal. Windows are created by calling newwin() and
+destroyed by calling delwin(). The terminal cursor is moved by the
+procedure move(). Text is written into a window by the procedures
+addch() and addstr(). Text is read from the keyboard and displayed in
+the window by the procedures getch() and getstr(). Changes to the
+window are not displayed until refresh() is called. Fuller
+explanations of these and the other curses procedures is given below.
+
+Many procedures in this directory exist in two forms. The first form
+uses the default window, STDSCR. This window is created when initscr()
+is called and covers the entire screen. The second form uses any
+window and has an extra argument to specify which window to use. The
+names of the two forms are the same, except that the second has the
+letter "w" as the first character. For example, addch() adds a
+character to STDSCR, while waddch() adds a character to any window.
+The macro STDSCR is defined in <curses.h>, so it can be used by your
+program. Many of the procedures in this library operate relative to
+the current cursor position in that window. To set the cursor
+position, the program should call move() or wmove() first. Window
+coordinates are passed row first, column second. The upper left corner
+of a window is (1,1).
+
+procedure addch (ch)
+procedure waddch (win, ch)
+
+pointer win # i: Window descriptor
+char ch # i: Character to add
+
+This procedure adds a single character at the current cursor position.
+The character currently at that position is overwritten. A linefeed
+character clears the rest of the line and moves the cursor to the next
+row. A tab character inserts the apropriate number of spaces at the
+current position. A carriage return moves the cursor to the first
+character on the current line. A backspace moves the cursor one column
+left unless the cursor is in the first column of the window.
+
+procedure addstr (str)
+procedure waddstr (win, str)
+
+int win # i: Window descriptor
+char str[ARB] # i: String to add to window
+
+This procedure adds a string at the current cursor position. If part
+of the string extends beyond the right edge of the window, it will be
+truncated. Special characters have the same meaning as those in addch().
+The window will scroll if scrolling is enabled.
+
+procedure bindstruct (func, structure)
+procedure wbindstruct (win, func, structure)
+
+int win # i: Window descriptor
+extern func # i: Input function
+pointer structure # i: Data structure
+
+This procedure binds an input function and a data structure to a
+window. The data structure is used by the input function to maintain
+the window's state. The input function is called by getch() and
+getstr() to process keyboard input instead of the default procedure,
+editfn(). The input function should have the following calling sequence.
+
+procedure func (win, str, maxch)
+
+int win # i: Window descriptor
+char str[ARB] # io: String containing line
+int maxch # i: Maximum line length
+
+When writing this procedure, the default procedure, editfn() should be
+used as a guide. The procedure should update the terminal screen,
+string, and data structure appropriately. When the procedure gets a
+character indicating input is complete, the character should be pushed
+back on the input stream with the procedure k_pushbk(). Then the
+procedure should return the string to the calling program. The calling
+program can also call getstruct() to retrieve the contents of the data
+structure.
+
+procedure box (win, vert, hor)
+
+int win # i: Window descriptor
+char vert # i: Character used for vertical side of window
+char hor # i: Character used for horizontal side of window
+
+This procedure draws a box around a window. The box is inside the
+original area of the window, which is then reduced so that subsequent
+writes to the window will not overwrite the box.
+
+procedure clear ()
+procedure wclear (win)
+
+int win # i: Window descriptor
+
+This procedure clears a window. It is equivalent to calling clearok()
+with flag set to true, followed by calling erase().
+
+procedure clearok (win, flag)
+
+int win # i: Window descriptor
+bool flag # i: Flag value
+
+This procedure sets the clear flag for a window. If the clear flag is
+true, the entire window will be redrawn when refresh is called.
+
+procedure clrtobot ()
+procedure wclrtobot (win)
+
+int win # i: Window descriptor
+
+This procedure clears a window from the current cursor position to the
+end of the window.
+
+procedure clrtoeol ()
+procedure wclrtoeol (win)
+
+int win # i: Window descriptor
+
+This procedure clears a window from the current cursor position to the
+end of the line.
+
+procedure delch ()
+procedure wdelch (win)
+
+pointer win # i: Window descriptor
+
+This procedure deletes the character at the current cursor poisition
+in the window. Subsequent characters on the line are moved to the left
+by one.
+
+procedure deleteln ()
+procedure wdeleteln (win)
+
+pointer win # i: Window descriptor
+
+This procedure deletes the current line in the window. Subsequent
+lines in the window slide up by one and the last line is left blank.
+
+procedure delwin (win)
+
+This procedure deletes a window created by newwin(). The terminal area
+that was under the window before it was created is redisplayed. The
+data structure associated with the window is freed, including the data
+structure bound by bindstruct(). STDSCR cannot be deleted by this
+procedure, it is deleted by endwin().
+
+procedure echo ()
+procedure noecho ()
+
+These procedures turn character echoing on and off. Character echoing
+is on when the terminal is initialized. If character ecoing is off,
+procedures addch() and addstr() will return immediately after being
+called.
+
+procedure endwin ()
+
+This procedure should be called at the end of a program which uses the
+curses library. It deletes all windows that are still open (including
+STDSCR) and resets the terminal.
+
+procedure erase ()
+procedure werase (win)
+
+int win # i: Window descriptor
+
+This procedure erases a window, filling it with blanks.
+
+int procedure getch ()
+int procedure wgetch (win)
+
+This procedure reads a single character from the keyboard and adds it
+to the window at the current cursor position. If an input function
+has been bound to the window by bindstruct(), the input procedure is
+called to process the character. The procedure returns after calling
+the input function once, regardless of the value of done. The returned
+character is the first character in the string output by the input
+function.
+
+procedure getstr (str, maxch)
+procedure wgetstr (win, str, maxch)
+
+pointer win # i: Window descriptor
+char str[ARB] # o: String that was read from the keyboard
+int maxch # i: Maximum string length
+
+This procedure reads a string from the keyboard and displays it in the
+window at the current cursor position. Editing keys are recognized;
+however, editing is limited to a single line and keys which change the
+current line cause the procedure to exit. The default behaviour of
+this procedure can be modified by binding an input function to the
+window with bindstruct().
+
+procedure getstruct (structure)
+procedure wgetstruct (win, structure)
+
+int win # i: Window descriptor
+pointer structure # o: Data structure
+
+This procedure returns a pointer to the data structure that was bound
+to the window by bindstruct().
+
+procedure getyx (win, row, col)
+
+int win # i: Window descriptor
+int row # o: Cursor row
+int col # o: Cursor column
+
+This procedure returns the location of the cursor in a window. The
+top left corner of a window is (1,1).
+
+procedure hidewin (win)
+
+int win # i: Window descriptor
+
+This procedure hides a window that is currently displayed on the
+screen. The terminal area under the window is displayed after the
+window is hidden. The window can be redisplayed by calling showwin().
+
+char procedure inch ()
+char procedure winch (win)
+
+pointer win # i: Window descriptor
+
+This procedure returns the character at the current cursor location in
+the window.
+
+procedure initscr ()
+
+This procedure initializes the terminal and creates the default
+window, STDSCR. It should be called before any other procedure in the
+curses library is called.
+
+procedure insch (ch)
+procedure winsch (win, ch)
+
+pointer win # i: Window descriptor
+char ch # i: Character to insert
+
+This procedure inserts a character at the current cursor position.
+
+procedure insertln ()
+procedure winsertln (win)
+
+pointer win # i: Window descriptor
+
+This procedure inserts a blank line on the current row. The current
+line and subsequent lines move down by one and the last line in the
+window is deleted.
+
+procedure leaveok (win, flag)
+
+int win # i: Window descriptor
+bool flag # i: Flag value
+
+This procedure sets the leave flag for a window. If the leave flag
+is true, procedures that modify the screen will not move the terminal
+cursor to the window's current cursor position when the window is
+modified. If it is false, the terminal cursor position will be moved
+when the window is updated. When a window is created, the leave flag
+is set to false.
+
+procedure move (row, col)
+procedure wmove (win, row, col)
+
+int win # i: Window descriptor
+int row # i: Cursor row
+int col # i: Cursor column
+
+This procedure moves the cursor position in a window. Coordinates are
+relative to those of the window, and the top left corner of a window
+has the coordinates (1,1)
+
+procedure mvwin (win, row, col)
+
+int win # i: Window descriptor
+int row # i: New top row of window
+int col # i: New left column of window
+
+This position moves the position of a window on the screen. The
+position of a window is the position of the top left corner on the
+terminal screen. If the new corrdinates would place part of the window
+off the screen, the coordinates are modified so that the window stays
+on the screen.
+
+int procedure newwin (nrows, ncols, row, col)
+
+int nrows # i: Window height
+int ncols # i: Window width
+int row # i: Top row of window
+int col # i: Leftmost column of window
+
+This procedure creates a new window. The returned value is the window
+descriptor, which is used as an argument to the other window
+functions. The window position is relative to the top left corner of
+the terminal, which has the coordinates (1,1). If part of the window
+is off the terminal screen, it will be placed and sized so that the
+entire window fits on the screen.
+
+procedure refresh ()
+procedure wrefresh (win)
+
+int win # i: Window descriptor
+
+This procedure causes all changes to a window that have been made by
+other calls in this library to be displayed on the terminal screen. If
+the clear flag has been set to yes by clearok(), the window will be
+cleared and redrawn.
+
+procedure savewin ()
+procedure nosavewin ()
+
+These procedures set and unset the save flag. If the save flag is set,
+whenever a window is created, the area on the terminal screen under is
+saved in a buffer so it can be restored when the window is hidden or
+deleted. If a window will exist throughout the life of a program, the
+save flag can be unset by calling nosavewin() before creating the
+window so that the memory used to hold the buffer will not be wasted.
+The save flag is initially set to yes so that all windows have
+associated screen buffers by default.
+
+procedure scrollok (win, flag)
+
+int win # i: Window descriptor
+bool flag # i: Flag value
+
+If the scroll flag is set to true, a window will scroll when an
+attempt is made to write beyond the last line of a window. If the
+scroll flag is false, the last line of the window will be overwritten.
+When a new window is created, the scroll flag is set to false.
+
+procedure showwin (win)
+
+int win # i: Window descriptor
+
+This procedure shows a window that was previously hidden by a call to
+hidewin(). If the window is not hidden, this procedure has no effect.
+
+procedure standout ()
+procedure standend ()
+procedure wstandout (win)
+procedure wstandend (win)
+
+int win # i: Window descriptor
+
+These procedures modify the character attribute of a window. Calling
+standout() causes all characters written to the window after the call
+to be written in standout mode. Calling standend() causes all
+characacters to be written in normal mode. When a window is created,
+the character attribute of the window is normal.
+
+procedure wdimen (win, nrows, ncols)
+
+int win # i: Window descriptor
+int nrows # o: Window height
+int ncols # o: Window width
+
+This procedure returns the height and width of a window.
+
+int procedure winstat (win, what)
+
+int win # i: Window descriptor
+int what # i: Field to retrieve
+
+This procedure returns a field from the window descriptor. The field
+to retrieve is given by a symbolic constant. These constants are
+listed in the include file <curses.h>.
diff --git a/pkg/utilities/nttools/tedit/display/curses/addch.x b/pkg/utilities/nttools/tedit/display/curses/addch.x
new file mode 100644
index 00000000..f08085e4
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/addch.x
@@ -0,0 +1,30 @@
+include "../curses.h"
+
+# ADDCH -- Add a character to the standard screen
+#
+# B.Simon 01-Oct-90 Original
+
+procedure addch (ch)
+
+char ch # i: Character to add
+#--
+char str[1]
+
+begin
+ str[1] = ch
+ str[2] = EOS
+ call waddstr (STDSCR, str)
+end
+
+procedure waddch (win, ch)
+
+int win # i: Window descriptor
+char ch # i: Character to add
+#--
+char str[1]
+
+begin
+ str[1] = ch
+ str[2] = EOS
+ call waddstr (win, str)
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/addstr.x b/pkg/utilities/nttools/tedit/display/curses/addstr.x
new file mode 100644
index 00000000..f675d151
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/addstr.x
@@ -0,0 +1,157 @@
+include <ctype.h>
+include "../curses.h"
+include "window.h"
+
+define TABSTOP 8
+
+# ADDSTR -- Add a string to a window
+#
+# B.Simon 02-Oct-90 Original
+
+procedure addstr (str)
+
+char str[ARB] # i: String to add to window
+#--
+
+begin
+ call waddstr (STDSCR, str)
+end
+
+procedure waddstr (win, str)
+
+int win # i: Window descriptor
+char str[ARB] # i: String to add to window
+#--
+include "window.com"
+
+bool moved
+int row, col, nrows, ncols, ic, jc, mxchar, itab
+pointer sp, line, pwin
+
+begin
+ pwin = warray[win]
+
+ # Don't print anything if echoing is turned off
+
+ if (echoed == NO)
+ return
+
+ # Allocate an array to hold the string to print
+
+ call smark (sp)
+ call salloc (line, SZ_LINE, TY_CHAR)
+
+ # Get the current cursor position and window size
+
+ row = WIN_CURROW(pwin)
+ col = WIN_CURCOL(pwin)
+ ncols = WIN_WIDTH(pwin)
+ nrows = WIN_HEIGHT(pwin)
+
+ ic = 0
+ jc = 0
+ moved = false
+
+ repeat {
+ ic = ic + 1
+
+ # If the character is printable, just copy it to the array
+ # The array will be printed when the EOS is read
+
+ if (IS_PRINT(str[ic])) {
+ col = col + 1
+ Memc[line+jc] = str[ic]
+ jc = jc + 1
+
+ } else {
+ # Print any characters in the array before handling
+ # the non-printing character
+
+ Memc[line+jc] = EOS
+ if (jc > 0) {
+ jc = 0
+
+ mxchar = ncols - WIN_CURCOL(pwin) + 1
+ call ps_write (WIN_TOP(pwin)+WIN_CURROW(pwin)-1,
+ WIN_LEFT(pwin)+WIN_CURCOL(pwin)-1,
+ mxchar, Memc[line], WIN_ATRIB(pwin))
+
+ WIN_CURCOL(pwin) = col
+ WIN_CURROW(pwin) = row
+
+ # Check for writing past the edge of the window
+ # and scrolling
+
+ if (col > ncols) {
+ col = 1
+ row = row + 1
+ moved = true
+
+ if (row > nrows) {
+ row = nrows
+ if (WIN_SCROLL(pwin) == YES)
+ call wslide (WIN_RECT(pwin), DIR_UP, 1)
+ }
+ }
+ }
+
+ # Some non-printing characters require special action
+ # Others are mapped to printing characters and written
+ # to the array
+
+ switch (str[ic]) {
+ case EOS:
+ ;
+
+ case '\n':
+ call wclrtoeol (win)
+ col = 1
+ row = row + 1
+ moved = true
+
+ # Scroll window if we've hit the last row
+
+ if (row > nrows) {
+ row = nrows
+ if (WIN_SCROLL(pwin) == YES)
+ call wslide (WIN_RECT(pwin), DIR_UP, 1)
+ }
+
+ case '\t':
+ do itab = 1, TABSTOP - mod (col, TABSTOP) {
+ Memc[line+jc] = ' '
+ jc = jc + 1
+ col = col + 1
+ }
+
+ case '\r':
+ if (col > 1) {
+ col = 1
+ moved = true
+ }
+
+ case '\010':
+ if (col > 1) {
+ col = col - 1
+ moved = true
+ }
+
+ default:
+ Memc[line+jc] = ' '
+ col = col + 1
+ jc = jc + 1
+ }
+ }
+
+ # Move cursor, as required
+
+ if (moved) {
+ moved = false
+ call wmove (win, row, col)
+ }
+
+ } until (str[ic] == EOS)
+
+ call sfree (sp)
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/bindstruct.x b/pkg/utilities/nttools/tedit/display/curses/bindstruct.x
new file mode 100644
index 00000000..f9502c3d
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/bindstruct.x
@@ -0,0 +1,35 @@
+include "../curses.h"
+include "window.h"
+
+# BINDSTRUCT -- Bind a data structure and function to a window
+
+procedure bindstruct (func, structure)
+
+extern func # i: Input function
+pointer structure # i: Data structure
+#--
+
+begin
+ call wbindstruct (STDSCR, func, structure)
+end
+
+procedure wbindstruct (win, func, structure)
+
+int win # i: Window descriptor
+extern func # i: Input function
+pointer structure # i: Data structure
+#--
+include "window.com"
+
+pointer pwin
+pointer locpr()
+
+begin
+ pwin = warray[win]
+ if (WIN_DATA(pwin) != NULL)
+ call mfree (WIN_DATA(pwin), TY_STRUCT)
+
+ WIN_FUNC(pwin) = locpr (func)
+ WIN_DATA(pwin) = structure
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/box.x b/pkg/utilities/nttools/tedit/display/curses/box.x
new file mode 100644
index 00000000..06eadbcd
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/box.x
@@ -0,0 +1,56 @@
+include "../curses.h"
+include "window.h"
+
+# BOX -- Draw a box around a window
+#
+# B.Simon 01-Oct-90 Original
+
+procedure box (win, vert, hor)
+
+int win # i: Window descriptor
+char vert # i: Character used for vertical side of window
+char hor # i: Character used for horizontal side of window
+#--
+include "window.com"
+
+int vcode, hcode, rect[RSIZE]
+pointer pwin
+
+begin
+ # Don't box window if either dimension < 3 or window is already boxed
+
+ pwin = warray[win]
+ if (WIN_HEIGHT(pwin) < 3 || WIN_WIDTH(pwin) < 3 ||
+ WIN_BOXED(pwin) == YES)
+ return
+
+ # Draw box
+
+ vcode = vert
+ hcode = hor
+
+ RASG(rect, WIN_TOP(pwin), WIN_LEFT(pwin),
+ WIN_TOP(pwin), WIN_RIGHT(pwin))
+ call ps_fill (rect, hcode, WIN_ATRIB(pwin))
+
+ RASG(rect, WIN_BOT(pwin), WIN_LEFT(pwin),
+ WIN_BOT(pwin), WIN_RIGHT(pwin))
+ call ps_fill (rect, hcode, WIN_ATRIB(pwin))
+
+ RASG(rect, WIN_TOP(pwin), WIN_LEFT(pwin),
+ WIN_BOT(pwin), WIN_LEFT(pwin))
+ call ps_fill (rect, vcode, WIN_ATRIB(pwin))
+
+ RASG(rect, WIN_TOP(pwin), WIN_RIGHT(pwin),
+ WIN_BOT(pwin), WIN_RIGHT(pwin))
+ call ps_fill (rect, vcode, WIN_ATRIB(pwin))
+
+ # Reduce size of window's rectangle and mark as boxed
+
+ WIN_TOP(pwin) = WIN_TOP(pwin) + 1
+ WIN_LEFT(pwin) = WIN_LEFT(pwin) + 1
+ WIN_BOT(pwin) = WIN_BOT(pwin) - 1
+ WIN_RIGHT(pwin) = WIN_RIGHT(pwin) - 1
+ WIN_BOXED(pwin) = YES
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/clear.x b/pkg/utilities/nttools/tedit/display/curses/clear.x
new file mode 100644
index 00000000..7b69f63d
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/clear.x
@@ -0,0 +1,35 @@
+include "../curses.h"
+include "window.h"
+
+# CLEAR -- Clear window and force a redraw of the screen
+#
+# B.Simon 01-Oct-90 Original
+
+procedure clear ()
+
+#--
+include "window.com"
+
+pointer pwin
+
+begin
+ pwin = warray[STDSCR]
+ WIN_CLEAR(pwin) = YES
+
+ call werase (STDSCR)
+end
+
+procedure wclear (win)
+
+int win # i: Window descriptor
+#--
+include "window.com"
+
+pointer pwin
+
+begin
+ pwin = warray[win]
+ WIN_CLEAR(pwin) = YES
+
+ call werase (win)
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/clearok.x b/pkg/utilities/nttools/tedit/display/curses/clearok.x
new file mode 100644
index 00000000..9d3372a9
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/clearok.x
@@ -0,0 +1,21 @@
+include "window.h"
+
+# CLEAROK -- Set the clear flag for a window
+#
+# B.Simon 01-Oct-90 Original
+
+procedure clearok (win, flag)
+
+int win # i: Window descriptor
+bool flag # i: Flag value
+#--
+include "window.com"
+
+pointer pwin
+int btoi()
+
+begin
+ pwin = warray[win]
+ WIN_CLEAR(pwin) = btoi (flag)
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/clrtobot.x b/pkg/utilities/nttools/tedit/display/curses/clrtobot.x
new file mode 100644
index 00000000..da60b805
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/clrtobot.x
@@ -0,0 +1,56 @@
+include "../curses.h"
+include "window.h"
+
+# CLRTOBOT -- Clear window to bottom
+#
+# B.Simon 28-Sep-90 Original
+
+procedure clrtobot ()
+
+#--
+
+begin
+ call wclrtobot (STDSCR)
+end
+
+procedure wclrtobot (win)
+
+int win # i: Window descriptor
+#--
+include "window.com"
+
+int blank, rect[RSIZE]
+pointer pwin
+
+data blank / ' ' /
+
+begin
+ pwin = warray[win]
+
+ # First line may be partial, so it must be handled separately
+
+ if (WIN_CURCOL(pwin) == 1) {
+ RTOP(rect) = WIN_TOP(pwin) + WIN_CURROW(pwin) - 1
+ } else {
+ RTOP(rect) = WIN_TOP(pwin) + WIN_CURROW(pwin) - 1
+ RLEFT(rect) = WIN_LEFT(pwin) + WIN_CURCOL(pwin) - 1
+ RBOT(rect) = RTOP(rect)
+ RRIGHT(rect) = WIN_RIGHT(pwin)
+ call ps_fill (rect, blank, WIN_ATRIB(pwin))
+
+ RTOP(rect) = min (RBOT(rect), RTOP(rect)+1)
+ }
+
+ # Remaining lines form a rectangle
+
+ RLEFT(rect) = WIN_LEFT(pwin)
+ RBOT(rect) = WIN_BOT(pwin)
+ RRIGHT(rect) = WIN_RIGHT(pwin)
+
+ call ps_fill (rect, blank, WIN_ATRIB(pwin))
+ if (WIN_LEAVE(pwin) == NO) {
+ call ps_setcur (WIN_TOP(pwin)+WIN_CURROW(pwin)-1,
+ WIN_LEFT(pwin)+WIN_CURCOL(pwin)-1)
+ }
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/clrtoeol.x b/pkg/utilities/nttools/tedit/display/curses/clrtoeol.x
new file mode 100644
index 00000000..2c42a64e
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/clrtoeol.x
@@ -0,0 +1,45 @@
+include "../curses.h"
+include "window.h"
+
+# CLRTOEOL -- Clear window to end of current line
+#
+# B.Simon 01-Oct-90 Original
+
+procedure clrtoeol ()
+
+#--
+
+begin
+ call wclrtoeol (STDSCR)
+end
+
+procedure wclrtoeol (win)
+
+int win # i: Window descriptor
+#--
+include "window.com"
+
+int blank, rect[RSIZE]
+pointer pwin
+
+data blank / ' ' /
+
+begin
+ pwin = warray[win]
+
+ # Construct the rectangle consisting of the remainder of the
+ # current line and fill with blanks
+
+ RTOP(rect) = WIN_TOP(pwin) + WIN_CURROW(pwin) - 1
+ RLEFT(rect) = WIN_LEFT(pwin) + WIN_CURCOL(pwin) - 1
+ RBOT(rect) = RTOP(rect)
+ RRIGHT(rect) = WIN_RIGHT(pwin)
+ call ps_fill (rect, blank, WIN_ATRIB(pwin))
+
+ # Move the cursor to the new end of the line
+
+ if (WIN_LEAVE(pwin) == NO)
+ call ps_setcur (WIN_TOP(pwin)+WIN_CURROW(pwin)-1,
+ WIN_LEFT(pwin)+WIN_CURCOL(pwin)-1)
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/delch.x b/pkg/utilities/nttools/tedit/display/curses/delch.x
new file mode 100644
index 00000000..a58ed17d
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/delch.x
@@ -0,0 +1,41 @@
+include "../curses.h"
+include "window.h"
+
+# DELCH -- Delete a character from the window
+
+procedure delch ()
+
+# B.Simon 01-Oct-90 Original
+
+#--
+
+begin
+ call wdelch (STDSCR)
+end
+
+procedure wdelch (win)
+
+pointer win # i: Window descriptor
+#--
+include "window.com"
+
+int rect[RSIZE]
+pointer pwin
+
+begin
+ pwin = warray[win]
+
+ # Construct rectangle to slide
+
+ RTOP(rect) = WIN_TOP(pwin) + WIN_CURROW(pwin) - 1
+ RLEFT(rect) = WIN_LEFT(pwin) + WIN_CURCOL(pwin)
+ RBOT(rect) = RTOP(rect)
+ RRIGHT(rect) = WIN_RIGHT(pwin)
+
+ call wslide (rect, DIR_LEFT, 1)
+
+ if (WIN_LEAVE(pwin) == NO)
+ call ps_setcur (WIN_TOP(pwin)+WIN_CURROW(pwin)-1,
+ WIN_LEFT(pwin)+WIN_CURCOL(pwin)-1)
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/deleteln.x b/pkg/utilities/nttools/tedit/display/curses/deleteln.x
new file mode 100644
index 00000000..f5afa1dd
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/deleteln.x
@@ -0,0 +1,41 @@
+include "../curses.h"
+include "window.h"
+
+# DELETELN -- Delete a line from the window
+#
+# B.Simon 01-Oct-90 Original
+
+procedure deleteln ()
+
+#--
+
+begin
+ call wdeleteln (STDSCR)
+end
+
+procedure wdeleteln (win)
+
+pointer win # i: Window descriptor
+#--
+include "window.com"
+
+int rect[RSIZE]
+pointer pwin
+
+begin
+ pwin = warray[win]
+
+ # Construct rectangle to slide
+
+ RTOP(rect) = WIN_TOP(pwin) + WIN_CURROW(pwin) - 1
+ RLEFT(rect) = WIN_LEFT(pwin)
+ RBOT(rect) = WIN_BOT(pwin)
+ RRIGHT(rect) = WIN_RIGHT(pwin)
+
+ call wslide (rect, DIR_UP, 1)
+
+ if (WIN_LEAVE(pwin) == NO)
+ call ps_setcur (WIN_TOP(pwin)+WIN_CURROW(pwin)-1,
+ WIN_LEFT(pwin)+WIN_CURCOL(pwin)-1)
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/delwin.x b/pkg/utilities/nttools/tedit/display/curses/delwin.x
new file mode 100644
index 00000000..5b0db192
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/delwin.x
@@ -0,0 +1,42 @@
+include "../curses.h"
+include "window.h"
+
+# DELWIN --Delete a window
+#
+# B.Simon 28-Sep-90 Original
+
+procedure delwin (win)
+
+int win # i: Window descriptor
+#--
+include "window.com"
+
+int rect[RSIZE]
+pointer pwin
+
+begin
+ # Can't free the standard screen
+
+ if (win == STDSCR)
+ return
+
+ pwin = warray[win]
+
+ # Copy the screen under the window back to the terminal
+ # and then free the buffer which held it
+
+ if (WIN_BUFFER(pwin) != NULL) {
+ call wrect (win, YES, rect)
+ call putscreen (rect, WIN_BUFFER(pwin))
+ call freescreen (WIN_BUFFER(pwin))
+ }
+
+ # Free any data structure associated with the window
+
+ if (WIN_DATA(pwin) != NULL)
+ call mfree (WIN_DATA(pwin), TY_STRUCT)
+
+ call mfree (pwin, TY_STRUCT)
+ warray[win] = NULL
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/echo.x b/pkg/utilities/nttools/tedit/display/curses/echo.x
new file mode 100644
index 00000000..8152aff6
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/echo.x
@@ -0,0 +1,23 @@
+include "window.h"
+
+# ECHO -- Turn character echoing on
+#
+# B.Simon 02-Oct-90 Original
+
+procedure echo ()
+
+#--
+include "window.com"
+
+begin
+ echoed = YES
+end
+
+procedure noecho ()
+
+#--
+include "window.com"
+
+begin
+ echoed = NO
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/endwin.x b/pkg/utilities/nttools/tedit/display/curses/endwin.x
new file mode 100644
index 00000000..87a6c826
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/endwin.x
@@ -0,0 +1,34 @@
+include "window.h"
+
+# ENDWIN -- Finish up window routines
+#
+# B.Simon 28-Sep-90 Original
+
+procedure endwin ()
+
+#--
+include "window.com"
+
+int win
+pointer pwin
+
+begin
+ # Release windows that are still active
+
+ do win = 1, MAXWIN {
+ pwin = warray[win]
+ if (pwin != NULL) {
+ if (WIN_BUFFER(pwin) != NULL)
+ call freescreen (WIN_BUFFER(pwin))
+ if (WIN_DATA(pwin) != NULL)
+ call mfree (WIN_DATA(pwin), TY_STRUCT)
+ call mfree (pwin, TY_STRUCT)
+ }
+ }
+
+ # Reset terminal
+
+ call k_end
+ call ps_end
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/erase.x b/pkg/utilities/nttools/tedit/display/curses/erase.x
new file mode 100644
index 00000000..86b529a8
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/erase.x
@@ -0,0 +1,37 @@
+include "../curses.h"
+include "window.h"
+
+# ERASE -- Erase window
+#
+# B.Simon 28-Sep-90 Original
+
+procedure erase ()
+
+#--
+
+begin
+ call werase (STDSCR)
+end
+
+procedure werase (win)
+
+int win # i: Window descriptor
+#--
+include "window.com"
+
+int blank
+pointer pwin
+
+data blank / ' ' /
+
+begin
+ pwin = warray[win]
+ call ps_fill (WIN_RECT(pwin), blank, WIN_ATRIB(pwin))
+
+ if (WIN_LEAVE(pwin) == NO) {
+ call ps_setcur (WIN_TOP(pwin), WIN_LEFT(pwin))
+ WIN_CURROW(pwin) = 1
+ WIN_CURCOL(pwin) = 1
+ }
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/freescreen.x b/pkg/utilities/nttools/tedit/display/curses/freescreen.x
new file mode 100644
index 00000000..66321451
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/freescreen.x
@@ -0,0 +1,13 @@
+# FREESCREEN -- Free a window's buffer
+#
+# B.Simon 26-Sep-90 Original
+
+procedure freescreen (buffer)
+
+pointer buffer # i: Buffer allocated by wgetscr
+#--
+
+begin
+ if (buffer != NULL)
+ call mfree (buffer, TY_CHAR)
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/getch.x b/pkg/utilities/nttools/tedit/display/curses/getch.x
new file mode 100644
index 00000000..9d69c11f
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/getch.x
@@ -0,0 +1,53 @@
+include "../curses.h"
+include "window.h"
+
+# GETCH -- Get a character and display it in the window
+
+int procedure getch ()
+
+# B.Simon 01-Oct-90 Original
+
+#--
+int wgetch()
+
+begin
+ return (wgetch (STDSCR))
+end
+
+int procedure wgetch (win)
+
+pointer win # i: Window descriptor
+#--
+include "window.com"
+
+char str[1]
+int ch
+pointer pwin
+
+int k_get()
+
+begin
+ str[1] = EOS
+ str[2] = EOS
+ pwin = warray[win]
+
+ if (WIN_FUNC(pwin) == NULL) {
+ call ps_synch
+ ch = k_get ()
+
+ if (ch < K_BASE) {
+ str[1] = ch
+ call waddstr (win, str)
+ }
+
+ } else {
+ call zcall3 (WIN_FUNC(pwin), win, str, 1)
+ if (str[1] == EOS) {
+ ch = k_get () # get pushed back character
+ } else {
+ ch = str[1]
+ }
+ }
+
+ return (ch)
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/getscreen.x b/pkg/utilities/nttools/tedit/display/curses/getscreen.x
new file mode 100644
index 00000000..58020c3f
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/getscreen.x
@@ -0,0 +1,48 @@
+include "../curses.h"
+
+# GETSCREEN -- Retrieve screen contents into a window's buffer
+#
+# B.Simon 26-Sep-90 Original
+
+procedure getscreen (source, buffer)
+
+int source[RSIZE] # i: Rectangle to be retrieved
+pointer buffer # o: Buffer (allocated by this routine)
+#--
+
+int dest[RSIZE]
+int maxcol, maxrow, ncols, nrows, irow
+pointer buf, scr
+
+bool ps_intersect()
+int ps_width(), ps_height()
+pointer ps_screen()
+
+begin
+ # Clip the rectangle to the screen boundary
+ # If the rectangle is entirely off the screen, return
+
+ buffer = NULL
+ maxcol = ps_width ()
+ maxrow = ps_height ()
+ if (! ps_intersect (source, maxrow, maxcol, dest))
+ return
+
+ # Allocate buffer to hold screen contents
+
+ ncols = RWIDTH(dest)
+ nrows = RHEIGHT(dest)
+ call malloc (buffer, ncols*nrows, TY_CHAR)
+
+ # Copy screen contents to buffer
+
+ buf = buffer
+ scr = ps_screen (RTOP(dest), RLEFT(dest))
+
+ do irow = RTOP(dest), RBOT(dest) {
+ call amovc (Memc[scr], Memc[buf], ncols)
+ scr = scr + maxcol
+ buf = buf + ncols
+ }
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/getstr.x b/pkg/utilities/nttools/tedit/display/curses/getstr.x
new file mode 100644
index 00000000..6c1d38e6
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/getstr.x
@@ -0,0 +1,317 @@
+include <ctype.h>
+include "../curses.h"
+include "window.h"
+
+# GETSTR -- Get a string from the keyboard and display it in the window
+#
+# B.Simon 12-Dec-90 Original
+# B.Simon 21-Mar-91 Add several new commands
+
+procedure getstr (str, maxch)
+
+char str[ARB] # o: String that was read from the keyboard
+int maxch # i: Maximum string length
+#--
+int ch
+
+int k_get()
+
+begin
+ str[1] = EOS
+ call weditstr (STDSCR, str, maxch)
+
+ ch = k_get () # discard pushed back character
+end
+
+procedure wgetstr (win, str, maxch)
+
+pointer win # i: Window descriptor
+char str[ARB] # o: String that was read from the keyboard
+int maxch # i: Maximum string length
+#--
+int ch
+
+int k_get()
+
+begin
+ str[1] = EOS
+ call weditstr (win, str, maxch)
+
+ ch = k_get () # discard pushed back character
+end
+
+# EDITSTR -- Edit a string while displaying it in the window
+
+procedure editstr (str, maxch)
+
+char str[ARB] # u: String to edit
+int maxch # i: Maximum string length
+#--
+
+begin
+ call weditstr (STDSCR, str, maxch)
+end
+
+procedure weditstr (win, str, maxch)
+
+pointer win # i: Window descriptor
+char str[ARB] # u: String to edit
+int maxch # i: Maximum string length
+#--
+include "window.com"
+
+pointer pwin
+
+begin
+ # NOTE: It is the reponsibility of the calling program
+ # to make sure that the current window contents and the
+ # string passed to this procedure are in agreement before
+ # this procedure is called.
+
+ pwin = warray[win]
+
+ if (WIN_FUNC(pwin) == NULL) {
+ call editfn (win, str, maxch)
+ } else {
+ call zcall3 (WIN_FUNC(pwin), win, str, maxch)
+ }
+
+end
+
+# EDITFN -- Default function to process window input
+
+procedure editfn (win, str, maxch)
+
+int win # i: Window descriptor
+char str[ARB] # u: String containing line
+int maxch # i: Maximum line length
+#--
+int row, col, ch, ic, jc, mc, nc
+pointer sp, buffer
+
+int strlen(), k_get(), winstat()
+
+begin
+ ic = 0
+ nc = strlen (str)
+
+ row = winstat (win, W_CURROW)
+ col = winstat (win, W_CURCOL)
+
+ call smark (sp)
+ call salloc (buffer, SZ_LINE, TY_CHAR)
+ Memc[buffer] = EOS
+
+ while (nc < maxch) {
+
+ # Read character from keyboard
+
+ call ps_synch
+ ch = k_get ()
+
+ # Check for carriage return
+
+ if (ch == '\r')
+ break
+
+ if (IS_PRINT(ch)) {
+ ic = ic + 1
+ nc = nc + 1
+
+ if (ic == nc) {
+ str[ic] = ch
+ str[ic+1] = EOS
+ call waddstr (win, str[ic])
+
+ } else {
+ call amovc (str[ic], str[ic+1], nc-ic+1)
+
+ str[ic] = ch
+ call winsch (win, str[ic])
+ }
+
+ } else {
+ switch (ch) {
+ case K_UP: # Move up one field
+ break
+
+ case K_DOWN: # Move down one field
+ break
+
+ case K_RIGHT: # Move right one column
+ if (ic < nc) {
+ ic = ic + 1
+ call wmove (win, row, col+ic)
+ }
+
+ case K_LEFT: # Move left one column
+ if (ic > 0) {
+ ic = ic - 1
+ call wmove (win, row, col+ic)
+ }
+
+ case K_NEXTW: # Move forwards one word
+ call mvword_next (str, ic, jc)
+
+ if (jc > ic) {
+ ic = jc
+ call wmove (win, row, col+ic)
+ }
+
+ case K_PREVW: # Move backwards one word
+ call mvword_prev (str, ic, jc)
+
+ if (jc < ic) {
+ ic = jc
+ call wmove (win, row, col+ic)
+ }
+
+ case K_NEXTP: # Move forwards one screen
+ break
+
+ case K_PREVP: # Move backwards one screen
+ break
+
+ case K_HOME: # Move to first field
+ break
+
+ case K_END: # Move to last field
+ break
+
+ case K_BOL: # Move to first column in line
+ if (ic > 0) {
+ ic = 0
+ call wmove (win, row, col)
+ }
+
+ case K_EOL: # Move to last column in line
+ if (ic < nc) {
+ ic = nc
+ call wmove (win, row, col+ic)
+ }
+
+ case K_DEL: # Delete character underneath cursor
+ if (ic < nc) {
+ mc = strlen (Memc[buffer])
+
+ Memc[buffer+mc] = str[ic+1]
+ Memc[buffer+mc+1] = EOS
+
+ call amovc (str[ic+2], str[ic+1], nc-ic)
+
+ call wdelch (win)
+ nc = nc - 1
+ }
+
+ case K_BS: # Delete character to left of cursor
+ if (ic > 0) {
+ mc = strlen (Memc[buffer])
+
+ call amovc (Memc[buffer], Memc[buffer+1], mc+1)
+ Memc[buffer] = str[ic]
+
+ ic = ic - 1
+ call amovc (str[ic+2], str[ic+1], nc-ic)
+
+ call wmove (win, row, col+ic)
+ call wdelch (win)
+ nc = nc - 1
+ }
+
+ case K_DWORD: # Delete next word
+ call mvword_next (str, ic, jc)
+
+ if (jc > ic) {
+ mc = strlen (Memc[buffer])
+ call strcpy (str[ic+1], Memc[buffer+mc], jc-ic)
+ call amovc (str[jc+1], str[ic+1], nc-jc+1)
+
+ call wclrtoeol (win)
+ call waddstr (win, str[ic+1])
+ call wmove (win, row, col+ic)
+ nc = nc - (jc - ic)
+ }
+
+ case K_DLINE: # Delete entire line
+ if (nc > 0) {
+ call strcpy (str[ic+1], Memc[buffer], nc-ic)
+ str[ic+1] = EOS
+
+ call wclrtoeol (win)
+ nc = ic
+ }
+
+ case K_UNDCHR: # Undelete a character
+ mc = strlen (Memc[buffer])
+ if (mc > 0) {
+ call amovc (str[ic+1], str[ic+2], nc-ic+1)
+ str[ic+1] = Memc[buffer+mc-1]
+
+ Memc[buffer+mc-1] = EOS
+ call winsch (win, str[ic+1])
+
+ ic = ic + 1
+ nc = nc + 1
+ }
+
+ case K_UNDWRD: # Undelete a word
+ mc = strlen (Memc[buffer])
+ call mvword_prev (Memc[buffer], mc, jc)
+
+ mc = mc - jc
+ if (mc > 0) {
+ call amovc (str[ic+1], str[ic+mc+1], nc-ic+1)
+ call amovc (Memc[buffer+jc], str[ic+1], mc)
+
+ Memc[buffer+jc] = EOS
+ call wclrtoeol (win)
+ call waddstr (win, str[ic+1])
+
+ ic = ic + mc
+ nc = nc + mc
+ call wmove (win, row, col+ic)
+ }
+
+ case K_UNDLIN: # Undelete a line
+ mc = strlen (Memc[buffer])
+ if (mc > 0) {
+ call amovc (str[ic+1], str[ic+mc+1], nc-ic+1)
+ call amovc (Memc[buffer], str[ic+1], mc)
+
+ Memc[buffer] = EOS
+ call wclrtoeol (win)
+ call waddstr (win, str[ic+1])
+
+ ic = ic + mc
+ nc = nc + mc
+ call wmove (win, row, col+ic)
+ }
+
+ case K_HELP: # Display help screen
+ break
+
+ case K_PAINT: # Redraw the screen
+ call clearok (STDSCR, true)
+ call wrefresh (STDSCR)
+ call wmove (win, row, col+ic)
+
+ case K_EXIT: # Exit procedure
+ break
+
+ default: # Any other character
+ break
+ }
+ }
+ }
+
+ # Terminate string with EOS and push back character
+ # that terminated input
+
+ if (nc >= maxch)
+ ch = EOS
+
+ str[nc+1] = EOS
+ call k_pushbk (ch)
+
+ call sfree (sp)
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/getstruct.x b/pkg/utilities/nttools/tedit/display/curses/getstruct.x
new file mode 100644
index 00000000..9fbce77e
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/getstruct.x
@@ -0,0 +1,27 @@
+include "../curses.h"
+include "window.h"
+
+# GETSTRUCT -- Get the data structure associated with a window
+
+procedure getstruct (structure)
+
+pointer structure # o: Data structure
+#--
+
+begin
+ call wgetstruct (STDSCR, structure)
+end
+
+procedure wgetstruct (win, structure)
+
+int win # i: Window descriptor
+pointer structure # o: Data structure
+#--
+include "window.com"
+
+pointer pwin
+
+begin
+ pwin = warray[win]
+ structure = WIN_DATA(pwin)
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/getyx.x b/pkg/utilities/nttools/tedit/display/curses/getyx.x
new file mode 100644
index 00000000..d25b9b46
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/getyx.x
@@ -0,0 +1,22 @@
+include "window.h"
+
+# GETYX -- Get the current cursor position
+#
+# B.Simon 02-Oct-90 Original
+
+procedure getyx (win, row, col)
+
+int win # i: Window descriptor
+int row # o: Cursor row
+int col # o: Cursor column
+#--
+include "window.com"
+
+pointer pwin
+
+begin
+ pwin = warray[win]
+
+ row = WIN_CURROW(pwin)
+ col = WIN_CURCOL(pwin)
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/hidewin.x b/pkg/utilities/nttools/tedit/display/curses/hidewin.x
new file mode 100644
index 00000000..f116cffd
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/hidewin.x
@@ -0,0 +1,40 @@
+include "../curses.h"
+include "window.h"
+
+# HIDEWIN -- Hide a window
+#
+# B.Simon 28-Sep-90 Original
+
+procedure hidewin (win)
+
+int win # i: Window descriptor
+#--
+include "window.com"
+
+int rect[RSIZE]
+pointer pwin, buffer
+
+begin
+ pwin = warray[win]
+
+ # Don't do anything if the screen under the window wasn't
+ # saved or the window is already hidden
+
+ if (WIN_BUFFER(pwin) == NULL || WIN_HIDDEN(pwin) == YES)
+ return
+
+ # Save the current window contents in a buffer,
+ # and restore the screen under the window
+
+ call wrect (win, YES, rect)
+ call getscreen (rect, buffer)
+ call putscreen (rect, WIN_BUFFER(pwin))
+
+ # Place the window contents in its own buffer and
+ # mark the window as hidden
+
+ call freescreen (WIN_BUFFER(pwin))
+ WIN_BUFFER(pwin) = buffer
+ WIN_HIDDEN(pwin) = YES
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/inch.x b/pkg/utilities/nttools/tedit/display/curses/inch.x
new file mode 100644
index 00000000..9d80df3b
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/inch.x
@@ -0,0 +1,49 @@
+include "../curses.h"
+include "window.h"
+
+# INCH -- Get character at current cursor position
+#
+# B.Simon 02-Oct-90 Original
+
+char procedure inch ()
+
+#--
+char winch()
+
+begin
+ return (winch (STDSCR))
+end
+
+char procedure winch (win)
+
+pointer win # i: Window descriptor
+#--
+include "window.com"
+
+char ch
+int rect[RSIZE]
+pointer pwin, buf
+
+begin
+ pwin = warray[win]
+
+ # Create a box containing the character
+
+ if (WIN_BOXED(pwin) == NO) {
+ RTOP(rect) = WIN_TOP(pwin) + WIN_CURROW(pwin) - 1
+ RLEFT(rect) = WIN_LEFT(pwin) + WIN_CURCOL(pwin) - 1
+ } else {
+ RTOP(rect) = WIN_TOP(pwin) + WIN_CURROW(pwin)
+ RLEFT(rect) = WIN_LEFT(pwin) + WIN_CURCOL(pwin)
+ }
+ RBOT(rect) = RTOP(rect)
+ RRIGHT(rect) = RLEFT(rect)
+
+ # Get the character under the cursor
+
+ call getscreen (rect, buf)
+ ch = Memc[buf]
+ call freescreen (buf)
+
+ return (ch)
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/initscr.x b/pkg/utilities/nttools/tedit/display/curses/initscr.x
new file mode 100644
index 00000000..caa6b9fb
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/initscr.x
@@ -0,0 +1,33 @@
+include "../curses.h"
+include "window.h"
+
+# INITSCR -- Initialize curses routines
+
+procedure initscr ()
+
+#--
+include "window.com"
+
+int stdscr
+string cmdlist CMDSTR
+
+int newwin()
+
+begin
+ # Initialize global variables
+
+ saved = NO
+ echoed = YES
+ call aclri (warray, MAXWIN)
+
+ # Initialize terminal
+
+ call ps_begin
+ call k_begin (cmdlist)
+
+ # Create standard screen (STDSCR)
+
+ stdscr = newwin (GIANT, GIANT, 1, 1)
+ saved = YES
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/insch.x b/pkg/utilities/nttools/tedit/display/curses/insch.x
new file mode 100644
index 00000000..67dc9a7b
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/insch.x
@@ -0,0 +1,51 @@
+include "../curses.h"
+include "window.h"
+
+# INSCH -- Insert a character in the window
+#
+# B.Simon 02-Oct-90 Original
+
+procedure insch (ch)
+
+char ch # i: Character to insert
+#--
+
+begin
+ call winsch (STDSCR, ch)
+end
+
+procedure winsch (win, ch)
+
+pointer win # i: Window descriptor
+char ch # i: Character to insert
+#--
+include "window.com"
+
+char str[1]
+int rect[RSIZE]
+pointer pwin
+
+begin
+
+ pwin = warray[win]
+
+ # Construct rectangle to slide
+
+ RTOP(rect) = WIN_TOP(pwin) + WIN_CURROW(pwin) - 1
+ RLEFT(rect) = WIN_LEFT(pwin) + WIN_CURCOL(pwin) - 1
+ RBOT(rect) = RTOP(rect)
+ RRIGHT(rect) = WIN_RIGHT(pwin)
+
+ # Slide rectangle
+
+ call wslide (rect, DIR_RIGHT, 1)
+ call ps_setcur (WIN_TOP(pwin)+WIN_CURROW(pwin)-1,
+ WIN_LEFT(pwin)+WIN_CURCOL(pwin)-1)
+
+ # Write new character
+
+ str[1] = ch
+ str[2] = EOS
+ call waddstr (win, str)
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/insertln.x b/pkg/utilities/nttools/tedit/display/curses/insertln.x
new file mode 100644
index 00000000..604d860d
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/insertln.x
@@ -0,0 +1,41 @@
+include "../curses.h"
+include "window.h"
+
+# INSERTLN -- Insert a blank line in the window
+#
+# B.Simon 02-Oct-90 Original
+
+procedure insertln ()
+
+#--
+
+begin
+ call winsertln (STDSCR)
+end
+
+procedure winsertln (win)
+
+pointer win # i: Window descriptor
+#--
+include "window.com"
+
+int rect[RSIZE]
+pointer pwin
+
+begin
+ pwin = warray[win]
+
+ # Construct rectangle to slide
+
+ RTOP(rect) = WIN_TOP(pwin) + WIN_CURROW(pwin) - 1
+ RLEFT(rect) = WIN_LEFT(pwin)
+ RBOT(rect) = WIN_BOT(pwin)
+ RRIGHT(rect) = WIN_RIGHT(pwin)
+
+ call wslide (rect, DIR_DOWN, 1)
+
+ if (WIN_LEAVE(pwin) == NO)
+ call ps_setcur (WIN_TOP(pwin)+WIN_CURROW(pwin)-1,
+ WIN_LEFT(pwin)+WIN_CURCOL(pwin)-1)
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/leaveok.x b/pkg/utilities/nttools/tedit/display/curses/leaveok.x
new file mode 100644
index 00000000..3ce0f208
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/leaveok.x
@@ -0,0 +1,21 @@
+include "window.h"
+
+# LEAVEOK -- Set the leave flag for a window
+#
+# B.Simon 02-Oct-90 Original
+
+procedure leaveok (win, flag)
+
+int win # i: Window descriptor
+bool flag # i: Flag value
+#--
+include "window.com"
+
+pointer pwin
+int btoi()
+
+begin
+ pwin = warray[win]
+ WIN_LEAVE(pwin) = btoi (flag)
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/mkpkg b/pkg/utilities/nttools/tedit/display/curses/mkpkg
new file mode 100644
index 00000000..7708de04
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/mkpkg
@@ -0,0 +1,49 @@
+# Update the display library.
+# Author: B.Simon 01-APR-91
+
+$checkout libpkg.a ../../
+$update libpkg.a
+$checkin libpkg.a ../../
+$exit
+
+libpkg.a:
+ addch.x "../curses.h"
+ addstr.x <ctype.h> "../curses.h" "window.h" "window.com"
+ bindstruct.x "../curses.h" "window.h" "window.com"
+ box.x "../curses.h" "window.h" "window.com"
+ clear.x "../curses.h" "window.h" "window.com"
+ clearok.x "window.h" "window.com"
+ clrtobot.x "../curses.h" "window.h" "window.com"
+ clrtoeol.x "../curses.h" "window.h" "window.com"
+ delch.x "../curses.h" "window.h" "window.com"
+ deleteln.x "../curses.h" "window.h" "window.com"
+ delwin.x "../curses.h" "window.h" "window.com"
+ echo.x "window.h" "window.com"
+ endwin.x "window.h" "window.com"
+ erase.x "../curses.h" "window.h" "window.com"
+ freescreen.x
+ getch.x "../curses.h" "window.h" "window.com"
+ getscreen.x "../curses.h"
+ getstr.x "../curses.h" "window.h" "window.com"
+ getstruct.x "../curses.h" "window.h" "window.com"
+ getyx.x "window.h" "window.com"
+ hidewin.x "../curses.h" "window.h" "window.com"
+ inch.x "../curses.h" "window.h" "window.com"
+ initscr.x "../curses.h" "window.h" "window.com"
+ insch.x "../curses.h" "window.h" "window.com"
+ insertln.x "../curses.h" "window.h" "window.com"
+ leaveok.x "window.h" "window.com"
+ move.x "../curses.h" "window.h" "window.com"
+ mvwin.x "../curses.h" "window.h" "window.com"
+ mvword.x
+ newwin.x "../curses.h" "window.h" "window.com"
+ putscreen.x "../curses.h"
+ refresh.x "../curses.h" "window.h" "window.com"
+ savewin.x "window.h" "window.com"
+ scrollok.x "window.h" "window.com"
+ showwin.x "../curses.h" "window.h" "window.com"
+ standout.x "../curses.h" "window.h" "window.com"
+ wdimen.x "../curses.h" "window.h" "window.com"
+ winstat.x "../curses.h" "window.h" "window.com"
+ wslide.x "../curses.h"
+ ;
diff --git a/pkg/utilities/nttools/tedit/display/curses/move.x b/pkg/utilities/nttools/tedit/display/curses/move.x
new file mode 100644
index 00000000..ba3725f7
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/move.x
@@ -0,0 +1,39 @@
+include "../curses.h"
+include "window.h"
+
+# MOVE -- Move the cursor coordinates
+#
+# B.Simon 02-Oct-90 Original
+
+procedure move (row, col)
+
+int row # i: Cursor row
+int col # i: Cursor column
+#--
+
+begin
+ call wmove (STDSCR, row, col)
+end
+
+procedure wmove (win, row, col)
+
+int win # i: Window descriptor
+int row # i: Cursor row
+int col # i: Cursor column
+#--
+include "window.com"
+
+pointer pwin
+
+begin
+ pwin = warray[win]
+
+ WIN_CURROW(pwin) = max (1, row)
+ WIN_CURROW(pwin) = min (WIN_CURROW(pwin), WIN_HEIGHT(pwin))
+
+ WIN_CURCOL(pwin) = max (1, col)
+ WIN_CURCOL(pwin) = min (WIN_CURCOL(pwin), WIN_WIDTH(pwin))
+
+ call ps_setcur (WIN_TOP(pwin)+WIN_CURROW(pwin)-1,
+ WIN_LEFT(pwin)+WIN_CURCOL(pwin)-1)
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/mvwin.x b/pkg/utilities/nttools/tedit/display/curses/mvwin.x
new file mode 100644
index 00000000..dd7b9d73
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/mvwin.x
@@ -0,0 +1,63 @@
+include "../curses.h"
+include "window.h"
+
+# MVWIN -- Move home position of a window
+#
+# B.Simon 28-Sep-90 Original
+
+procedure mvwin (win, row, col)
+
+int win # i: Window descriptor
+int row # i: New top row of window
+int col # i: New left column of window
+#--
+include "window.com"
+
+bool shown
+int rect[RSIZE]
+int maxrow, maxcol, drow, dcol
+pointer pwin
+
+int ps_width(), ps_height()
+
+begin
+ pwin = warray[win]
+
+ # Compute new rectangle containing window
+ # Make sure it is confined to the current screen
+
+ maxrow = ps_height ()
+ maxcol = ps_width ()
+
+ drow = WIN_HEIGHT(pwin) - 1
+ dcol = WIN_WIDTH(pwin) - 1
+
+ RTOP(rect) = max (1, row)
+ if (RTOP(rect) + drow > maxrow)
+ RTOP(rect) = maxrow - drow
+
+ RLEFT(rect) = max (1, col)
+ if (RLEFT(rect) + dcol > maxcol)
+ RLEFT(rect) = maxcol - dcol
+
+ RBOT(rect) = RTOP(rect) + drow
+ RRIGHT(rect) = RLEFT(rect) + dcol
+
+ # Move the window by hiding it at its old location
+ # and showing it at the new location
+
+ if (RTOP(rect) != WIN_TOP(pwin) || RLEFT(rect) != WIN_LEFT(pwin)) {
+ shown = WIN_HIDDEN(pwin) == NO
+ if (shown)
+ call hidewin (win)
+
+ WIN_TOP(pwin) = RTOP(rect)
+ WIN_LEFT(pwin) = RLEFT(rect)
+ WIN_BOT(pwin) = RBOT(rect)
+ WIN_RIGHT(pwin) = RRIGHT(rect)
+
+ if (shown)
+ call showwin (win)
+ }
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/mvword.x b/pkg/utilities/nttools/tedit/display/curses/mvword.x
new file mode 100644
index 00000000..6a606e0d
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/mvword.x
@@ -0,0 +1,56 @@
+# MVWORD -- Move one word over in a string
+#
+# B.Simon 20-Mar-91 Original
+
+procedure mvword_next (str, ic, jc)
+
+char str[ARB] # i: String containing words
+int ic # i: Starting character (0 to strlen(str))
+int jc # o: Character before start of next word
+#--
+int nc
+int strlen()
+
+begin
+ # Find next blank
+
+ nc = strlen (str)
+ for (jc = min (ic+1, nc); jc < nc; jc = jc + 1) {
+ if (str[jc] <= ' ')
+ break
+ }
+
+ # Find first non-blank character after blank
+
+ for ( ; jc < nc; jc = jc + 1) {
+ if (str[jc] > ' ') {
+ jc = jc - 1 # back up to previous blank
+ break
+ }
+ }
+
+end
+
+procedure mvword_prev (str, ic, jc)
+
+char str[ARB] # i: String containing words
+int ic # i: Starting character (0 to strlen(str))
+int jc # o: Character before start of next word
+#--
+
+begin
+ # Find previous nonblank character
+
+ for (jc = max (ic-1, 0); jc > 0; jc = jc - 1) {
+ if (str[jc] > ' ')
+ break
+ }
+
+ # Find blank preceding non-blank character
+
+ for ( ; jc > 0; jc = jc - 1) {
+ if (str[jc] <= ' ')
+ break
+ }
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/newwin.x b/pkg/utilities/nttools/tedit/display/curses/newwin.x
new file mode 100644
index 00000000..f2195309
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/newwin.x
@@ -0,0 +1,83 @@
+include "../curses.h"
+include "window.h"
+
+# NEWWIN -- Create a new window
+#
+# B.Simon 28-Sep-90 Original
+
+int procedure newwin (nrows, ncols, row, col)
+
+int nrows # i: Window height
+int ncols # i: Window width
+int row # i: Top row of window
+int col # i: Leftmost column of window
+#--
+include "window.com"
+
+int win, maxrow, maxcol
+pointer pwin
+
+int ps_height(), ps_width()
+
+begin
+ # Find an empty slot in the window array and allocate a window
+
+ for (win = 1; win <= MAXWIN; win = win + 1) {
+ if (warray[win] == NULL)
+ break
+ }
+
+ if (win > MAXWIN)
+ call error (1, "Cannot create window")
+
+ call malloc (pwin, LEN_WINSTRUCT, TY_STRUCT)
+ warray[win] = pwin
+
+ # Compute the window's rectangle, making sure it is on the screen
+
+ maxrow = ps_height ()
+ maxcol = ps_width ()
+
+ if (row + nrows - 1 > maxrow)
+ WIN_TOP(pwin) = maxrow - nrows + 1
+ else
+ WIN_TOP(pwin) = row
+ WIN_TOP(pwin) = max (1, WIN_TOP(pwin))
+
+ if (col + ncols - 1 > maxcol)
+ WIN_LEFT(pwin) = maxcol - ncols + 1
+ else
+ WIN_LEFT(pwin) = col
+ WIN_LEFT(pwin) = max (1, WIN_LEFT(pwin))
+
+ WIN_BOT(pwin) = min (maxrow, WIN_TOP(pwin) + nrows - 1)
+ WIN_RIGHT(pwin) = min (maxcol, WIN_LEFT(pwin) + ncols - 1)
+
+ # Set the remaining fields of the window
+
+ WIN_CURROW(pwin) = 1
+ WIN_CURCOL(pwin) = 1
+ WIN_CLEAR(pwin) = NO
+ WIN_LEAVE(pwin) = NO
+ WIN_SCROLL(pwin) = NO
+ WIN_HIDDEN(pwin) = NO
+ WIN_BOXED(pwin) = NO
+ WIN_ATRIB(pwin) = A_NORM
+
+ if (saved == NO) {
+ WIN_BUFFER(pwin) = NULL
+ } else {
+ call getscreen (WIN_RECT(pwin), WIN_BUFFER(pwin))
+ }
+
+ WIN_FUNC(pwin) = NULL
+ WIN_DATA(pwin) = NULL
+
+ # Erase the window
+
+ call werase (win)
+
+ # Return window number
+
+ return (win)
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/omkpkg b/pkg/utilities/nttools/tedit/display/curses/omkpkg
new file mode 100644
index 00000000..21c3c249
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/omkpkg
@@ -0,0 +1,65 @@
+
+# Update the newdisp library.
+# Author: B.Simon 26-SEP-90
+
+$set XFLAGS = "-fgq $(XFLAGS)"
+$call default
+$exit
+
+debug:
+ $set XFLAGS = "-fgq $(XFLAGS)"
+ $call default
+ ;
+
+strip:
+ $delete newdisp.a
+ $call default
+ ;
+
+update:
+default:
+ $checkout newdisp.a ../../
+ $update newdisp.a
+ $checkin newdisp.a ../../
+ ;
+
+newdisp.a:
+ addch.x <curses.h>
+ addstr.x <ctype.h> <curses.h> "window.h" "window.com"
+ bindstruct.x <curses.h> "window.h" "window.com"
+ box.x <curses.h> "window.h" "window.com"
+ clear.x <curses.h> "window.h" "window.com"
+ clearok.x "window.h" "window.com"
+ clrtobot.x <curses.h> "window.h" "window.com"
+ clrtoeol.x <curses.h> "window.h" "window.com"
+ delch.x <curses.h> "window.h" "window.com"
+ deleteln.x <curses.h> "window.h" "window.com"
+ delwin.x <curses.h> "window.h" "window.com"
+ echo.x "window.h" "window.com"
+ endwin.x "window.h" "window.com"
+ erase.x <curses.h> "window.h" "window.com"
+ freescreen.x
+ getch.x <curses.h> "window.h" "window.com"
+ getscreen.x <curses.h>
+ getstr.x <curses.h> "window.h" "window.com"
+ getstruct.x <curses.h> "window.h" "window.com"
+ getyx.x "window.h" "window.com"
+ hidewin.x <curses.h> "window.h" "window.com"
+ inch.x <curses.h> "window.h" "window.com"
+ initscr.x <curses.h> "window.h" "window.com"
+ insch.x <curses.h> "window.h" "window.com"
+ insertln.x <curses.h> "window.h" "window.com"
+ leaveok.x "window.h" "window.com"
+ move.x <curses.h> "window.h" "window.com"
+ mvwin.x <curses.h> "window.h" "window.com"
+ newwin.x <curses.h> "window.h" "window.com"
+ putscreen.x <curses.h>
+ refresh.x <curses.h> "window.h" "window.com"
+ savewin.x "window.h" "window.com"
+ scrollok.x "window.h" "window.com"
+ showwin.x <curses.h> "window.h" "window.com"
+ standout.x <curses.h> "window.h" "window.com"
+ wdimen.x <curses.h> "window.h" "window.com"
+ winstat.x <curses.h> "window.h" "window.com"
+ wslide.x <curses.h>
+ ;
diff --git a/pkg/utilities/nttools/tedit/display/curses/putscreen.x b/pkg/utilities/nttools/tedit/display/curses/putscreen.x
new file mode 100644
index 00000000..83bb4966
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/putscreen.x
@@ -0,0 +1,84 @@
+include "../curses.h"
+
+# PUTSCREEN -- Copy buffer back onto screen
+#
+# B.Simon 27-Sep-90 Original
+
+procedure putscreen (source, buffer)
+
+int source[RSIZE] # i: Rectangle to be restored
+pointer buffer # i: Buffer
+#--
+
+bool clear
+int blank, dest[RSIZE]
+int maxcol, maxrow, ncols, nrows, icol, jcol, irow
+pointer sp, buf, ptr, scr
+
+data blank / ' ' /
+
+bool ps_intersect()
+int ps_width(), ps_height()
+pointer ps_screen()
+
+begin
+ # Clip rectangle at screen boundary
+
+ maxcol = ps_width ()
+ maxrow = ps_height ()
+ if (! ps_intersect (source, maxrow, maxcol, dest))
+ return
+
+ call smark (sp)
+ ncols = RWIDTH(dest)
+ nrows = RHEIGHT(dest)
+
+ # If the buffer pointer is null,
+ # copy the current screen contents instead
+
+ if (buffer != NULL) {
+ buf = buffer
+ } else {
+ call salloc (buf, nrows*ncols, TY_CHAR)
+
+ ptr = buf
+ scr = ps_screen (RTOP(dest), RLEFT(dest))
+ do irow = 1, nrows {
+ call amovc (Memc[scr], Memc[ptr], ncols)
+ scr = scr + maxcol
+ ptr = ptr + ncols
+ }
+ }
+
+ # See if clearing the screen first would be faster
+ # if so, do it
+
+ clear = ncols == maxcol
+ if (clear)
+ call ps_fill (dest, blank, A_NORM)
+
+ # Copy buffer to screen using ps_wrtcells
+
+ do irow = RTOP(dest), RBOT(dest) {
+ icol = 1
+ jcol = ncols
+
+ # If the screen has been cleared, don't write blanks
+
+ if (clear) {
+ while (icol <= ncols && Memc[buf+icol-1] == blank)
+ icol = icol + 1
+ while (jcol >= icol && Memc[buf+jcol-1] == blank)
+ jcol = jcol - 1
+ }
+
+ if (jcol >= icol) {
+ call ps_wrtcells (irow, RLEFT(dest)+icol-1,
+ Memc[buf+icol-1], jcol-icol+1)
+ }
+
+ buf = buf + ncols
+ }
+
+ call sfree (sp)
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/refresh.x b/pkg/utilities/nttools/tedit/display/curses/refresh.x
new file mode 100644
index 00000000..b65885d8
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/refresh.x
@@ -0,0 +1,42 @@
+include "../curses.h"
+include "window.h"
+
+# REFRESH -- Bring the terminal screen up to date
+#
+# B.Simon 02-Oct-90 Original
+
+procedure refresh ()
+
+#--
+
+begin
+ call wrefresh (STDSCR)
+end
+
+procedure wrefresh (win)
+
+int win # i: Window descriptor
+#--
+include "window.com"
+
+int rect[RSIZE]
+pointer pwin
+
+begin
+ pwin = warray[win]
+
+ # If the clear flag is set, redraw the contents of the window
+
+ if (WIN_CLEAR(pwin) == YES) {
+ WIN_CLEAR(pwin) = NO
+ call wrect (win, YES, rect)
+ call putscreen (rect, NULL)
+
+ if (WIN_LEAVE(pwin) == NO) {
+ call ps_setcur (WIN_TOP(pwin)+WIN_CURROW(pwin)-1,
+ WIN_LEFT(pwin)+WIN_CURCOL(pwin)-1)
+ }
+ }
+
+ call ps_synch
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/savewin.x b/pkg/utilities/nttools/tedit/display/curses/savewin.x
new file mode 100644
index 00000000..6be4bc72
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/savewin.x
@@ -0,0 +1,23 @@
+include "window.h"
+
+# SAVEWIN -- Save characters under window when a window is created
+#
+# B.Simon 18-Oct-90 Original
+
+procedure savewin ()
+
+#--
+include "window.com"
+
+begin
+ saved = YES
+end
+
+procedure nosavewin ()
+
+#--
+include "window.com"
+
+begin
+ saved = NO
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/scrollok.x b/pkg/utilities/nttools/tedit/display/curses/scrollok.x
new file mode 100644
index 00000000..dfbb3317
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/scrollok.x
@@ -0,0 +1,21 @@
+include "window.h"
+
+# SCROLLOK -- Set the scroll flag for a window
+#
+# B.Simon 02-Oct-90 Original
+
+procedure scrollok (win, flag)
+
+int win # i: Window descriptor
+bool flag # i: Flag value
+#--
+include "window.com"
+
+pointer pwin
+int btoi()
+
+begin
+ pwin = warray[win]
+ WIN_SCROLL(pwin) = btoi (flag)
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/showwin.x b/pkg/utilities/nttools/tedit/display/curses/showwin.x
new file mode 100644
index 00000000..66d4c866
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/showwin.x
@@ -0,0 +1,39 @@
+include "../curses.h"
+include "window.h"
+
+# SHOWWIN -- Show a previously hidden window
+#
+# B.Simon 28-Sep-90 Original
+
+procedure showwin (win)
+
+int win # i: Window descriptor
+#--
+include "window.com"
+
+int rect[RSIZE]
+pointer pwin, buffer
+
+begin
+ pwin = warray[win]
+
+ # Don't do anything if the window is already visible
+
+ if (WIN_HIDDEN(pwin) == NO)
+ return
+
+ # Save the screen under the window in a buffer
+ # and display the window's contents
+
+ call wrect (win, YES, rect)
+ call getscreen (rect, buffer)
+ call putscreen (rect, WIN_BUFFER(pwin))
+
+ # Copy the screen buffer into the window's buffer and
+ # mark the window as visible
+
+ call freescreen (WIN_BUFFER(pwin))
+ WIN_BUFFER(pwin) = buffer
+ WIN_HIDDEN(pwin) = NO
+
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/standout.x b/pkg/utilities/nttools/tedit/display/curses/standout.x
new file mode 100644
index 00000000..855dab58
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/standout.x
@@ -0,0 +1,48 @@
+include "../curses.h"
+include "window.h"
+
+# STANDOUT -- Put the window in standout mode
+#
+# B.Simon 02-Oct-90 Original
+
+procedure standout ()
+
+#--
+
+begin
+ call wstandout (STDSCR)
+end
+
+procedure wstandout (win)
+
+int win # i: Window descriptor
+#--
+include "window.com"
+
+pointer pwin
+
+begin
+ pwin = warray[win]
+ WIN_ATRIB(pwin) = A_STANDOUT
+end
+
+procedure standend ()
+
+#--
+
+begin
+ call wstandend (STDSCR)
+end
+
+procedure wstandend (win)
+
+int win # i: Window descriptor
+#--
+include "window.com"
+
+pointer pwin
+
+begin
+ pwin = warray[win]
+ WIN_ATRIB(pwin) = A_NORM
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/wdimen.x b/pkg/utilities/nttools/tedit/display/curses/wdimen.x
new file mode 100644
index 00000000..55d5a6cf
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/wdimen.x
@@ -0,0 +1,45 @@
+include "../curses.h"
+include "window.h"
+
+# WDIMEN -- Return dimensions of a window
+#
+# B.Simon 11-Oct-90 Original
+
+procedure wdimen (win, nrows, ncols)
+
+int win # i: Window descriptor
+int nrows # o: Window height
+int ncols # o: Window width
+#--
+int rect[RSIZE]
+
+begin
+ call wrect (win, NO, rect)
+
+ nrows = RHEIGHT(rect)
+ ncols = RWIDTH(rect)
+end
+
+# WRECT -- Get the rectangle containing the window
+
+procedure wrect (win, border, rect)
+
+int win # i: Window descriptor
+int border # i: Include border in dimensions?
+int rect[RSIZE] # o: Rectangle containing window dimensions
+#--
+include "window.com"
+
+pointer pwin
+
+begin
+ pwin = warray[win]
+ if (border == NO || WIN_BOXED(pwin) == NO) {
+ RASG(rect, WIN_TOP(pwin), WIN_LEFT(pwin),
+ WIN_BOT(pwin), WIN_RIGHT(pwin))
+
+ } else {
+ RASG(rect, WIN_TOP(pwin)-1, WIN_LEFT(pwin)-1,
+ WIN_BOT(pwin)+1, WIN_RIGHT(pwin)+1)
+ }
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/window.com b/pkg/utilities/nttools/tedit/display/curses/window.com
new file mode 100644
index 00000000..74b0a38c
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/window.com
@@ -0,0 +1,7 @@
+# WINDOW.COM -- Global variables used by the curses subroutines
+
+int saved # Save rectangle under window when creating
+int echoed # Echo characters
+pointer warray[MAXWIN] # Array holding window descriptors
+
+common /window/ saved, echoed, warray
diff --git a/pkg/utilities/nttools/tedit/display/curses/window.h b/pkg/utilities/nttools/tedit/display/curses/window.h
new file mode 100644
index 00000000..41141580
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/window.h
@@ -0,0 +1,28 @@
+# WINDOW.H -- Window structure definitions and macros
+
+define MAXWIN 50 # Maximum number of windows
+define LEN_WINSTRUCT 15 # Length of window structure
+
+# definition of window structure
+
+define WIN_TOP Memi[$1] # Window's top row
+define WIN_LEFT Memi[$1+1] # Window's leftmost column
+define WIN_BOT Memi[$1+2] # Window's bottom row
+define WIN_RIGHT Memi[$1+3] # Window's rightmost column
+define WIN_CURROW Memi[$1+4] # Cursor row relative to window
+define WIN_CURCOL Memi[$1+5] # Cursor column relative to window
+define WIN_CLEAR Memi[$1+6] # Redraw window when refreshed
+define WIN_LEAVE Memi[$1+7] # Leave cursor after redraw
+define WIN_SCROLL Memi[$1+8] # Window will scroll
+define WIN_HIDDEN Memi[$1+9] # Window is hidden
+define WIN_BOXED Memi[$1+10] # Window is boxed
+define WIN_ATRIB Memi[$1+11] # Character attribute of window
+define WIN_BUFFER Memi[$1+12] # Holds characters under the window
+define WIN_FUNC Memi[$1+13] # Function bound to window
+define WIN_DATA Memi[$1+14] # Data structure bound to window
+
+# Macros used to manipulate rectangle
+
+define WIN_RECT Memi[$1]
+define WIN_WIDTH (WIN_RIGHT($1) - WIN_LEFT($1) + 1)
+define WIN_HEIGHT (WIN_BOT($1) - WIN_TOP($1) + 1)
diff --git a/pkg/utilities/nttools/tedit/display/curses/winstat.x b/pkg/utilities/nttools/tedit/display/curses/winstat.x
new file mode 100644
index 00000000..e89e3ca6
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/winstat.x
@@ -0,0 +1,51 @@
+include "../curses.h"
+include "window.h"
+
+# WINSTAT -- Retrieve a field from a window structure
+
+int procedure winstat (win, what)
+
+int win # i: Window descriptor
+int what # i: Field to retrieve
+#--
+include "window.com"
+
+int value
+pointer pwin
+
+string badcode "Unrecognized argument to winstat"
+
+begin
+ pwin = warray[win]
+
+ switch (what) {
+ case W_TOP:
+ value = WIN_TOP(pwin)
+ case W_LEFT:
+ value = WIN_LEFT(pwin)
+ case W_BOT:
+ value = WIN_BOT(pwin)
+ case W_RIGHT:
+ value = WIN_RIGHT(pwin)
+ case W_CURROW:
+ value = WIN_CURROW(pwin)
+ case W_CURCOL:
+ value = WIN_CURCOL(pwin)
+ case W_CLEAR:
+ value = WIN_CLEAR(pwin)
+ case W_LEAVE:
+ value = WIN_LEAVE(pwin)
+ case W_SCROLL:
+ value = WIN_SCROLL(pwin)
+ case W_HIDDEN:
+ value = WIN_HIDDEN(pwin)
+ case W_BOXED:
+ value = WIN_BOXED(pwin)
+ case W_ATRIB:
+ value = WIN_ATRIB(pwin)
+ default:
+ call error (1, badcode)
+ }
+
+ return (value)
+end
diff --git a/pkg/utilities/nttools/tedit/display/curses/wslide.x b/pkg/utilities/nttools/tedit/display/curses/wslide.x
new file mode 100644
index 00000000..b57f68da
--- /dev/null
+++ b/pkg/utilities/nttools/tedit/display/curses/wslide.x
@@ -0,0 +1,91 @@
+include "../curses.h"
+
+# WSLIDE -- Slide a window's rectangle on the screen
+#
+# B.Simon 25-Sep-90 Original
+
+procedure wslide (source, dir, dist)
+
+int source[RSIZE] # i: Rectangle
+int dir # i: Direction (from display.h)
+int dist # i: Distance (> 0)
+#--
+int blank, dest[RSIZE], rect[RSIZE]
+int maxcol, maxrow, ncols, irow, icol
+pointer sp, buffer, oldscr
+
+data blank / ' ' /
+
+bool ps_slide(), ps_intersect()
+int ps_width(), ps_height()
+pointer ps_screen()
+
+begin
+ # First try to slide the rectangle with ps_slide
+ # (move by using insert and delete control sequences)
+
+ if (ps_slide (source, dir, dist))
+ return
+
+ # If this doesn't work, redraw the rectangle from
+ # the screen buffer using ps_wrtcells and ps_fill
+
+ # The left and write scrolls must first be written
+ # to a buffer to avoid the problem with array overlap
+ # when updating the screen buffer
+
+ maxcol = ps_width ()
+ maxrow = ps_height ()
+ if (! ps_intersect (source, maxrow, maxcol, dest))
+ return
+
+ call smark(sp)
+ ncols = RWIDTH(dest)
+ call salloc (buffer, ncols+dist, TY_CHAR)
+
+ switch (dir) {
+ case DIR_UP:
+ oldscr = ps_screen (RTOP(dest), RLEFT(dest))
+ do irow = RTOP(dest), RBOT(dest)-dist {
+ call ps_wrtcells (irow-dist, RLEFT(dest), Memc[oldscr], ncols)
+ oldscr = oldscr + maxcol
+ }
+
+ RASG (rect, max(RTOP(dest), RBOT(dest)-dist+1), RLEFT(dest),
+ RBOT(dest), RRIGHT(dest))
+ call ps_fill (rect, blank, A_NORM)
+
+ case DIR_DOWN:
+ oldscr = ps_screen (RBOT(dest), RLEFT(dest))
+ do irow = RBOT(dest), RTOP(dest)+dist, -1 {
+ call ps_wrtcells (irow+dist, RLEFT(dest), Memc[oldscr], ncols)
+ oldscr = oldscr - maxcol
+ }
+
+ RASG (rect, RTOP(dest), RLEFT(dest),
+ min(RBOT(dest), RTOP(dest)+dist-1), RRIGHT(dest))
+ call ps_fill (rect, blank, A_NORM)
+
+ case DIR_LEFT:
+ icol = RLEFT(dest) - dist
+ oldscr = ps_screen (RTOP(dest), RLEFT(dest))
+ do irow = RTOP(dest), RBOT(dest) {
+ call amovc (Memc[oldscr], Memc[buffer], ncols)
+ call amovkc (blank, Memc[buffer+ncols], ncols-dist)
+
+ call ps_wrtcells (irow, icol, Memc[buffer], ncols)
+ oldscr = oldscr + maxcol
+ }
+ case DIR_RIGHT:
+ icol = RLEFT(dest) + dist
+ oldscr = ps_screen (RTOP(dest), RLEFT(dest))
+ do irow = RTOP(dest), RBOT(dest) {
+ call amovc (Memc[oldscr], Memc[buffer], ncols)
+
+ call ps_wrtcells (irow, icol, Memc[buffer], ncols)
+ oldscr = oldscr + maxcol
+ }
+ }
+
+ call sfree (sp)
+end