home *** CD-ROM | disk | FTP | other *** search
-
- The HASWIN window library.
- ===========================
- Copyright H.A. Shaw 1990.
- ===========================
-
- Drawing text in windows under the HASWIN system.
- -------------------------------------------------
- HASWIN provides a simple text overlay for windows. HASWIN maintains
- a 2-D grid of character cells that are overlayed over the window and redrawn
- automatically by HASWIN. The text overlay may be larger or smaller than the
- window itself but the top left character is always aligned with the top left
- corner of the window work area. The top left corner of the text overlay has position 0,0 and axes are counted right positive and down positive.
- Routines are provided to insert and delete characters and lines and move the
- text cursor. It is also possible to determine various characteristics of
- the text overlay, such as its size and the position of the text cursor. A
- VDU stream-like interface is provided.
-
- A text overlay is made from the following structure. Routines are
- provided for all access to the structure and it should NEVER need to be used
- directly in user programs.
-
- typedef struct text {
- char *text; /* pointer to character data area */
- int xsize,ysize; /* X and Y sizes of data area */
- int xposn,yposn; /* cursor is before this position. */
- char fcol, bcol; /* foreground and background colours. */
- } text;
-
- The following routines are provided to create text overlays and
- manipulate them. The simplest way to create a text overlay for a window is
- to set the WINDOW_AUTOTEXT flag for a window when it is created with the
- haswin_make{pane/slide}window() routines. See later for what the
- WINDOW_AUTOTEXT flag causes HASWIN to do after window creation.
-
- int haswin_maketextoverlay(window *win, int x, int y, char f, char b);
- - This routine creates a text overlay of size "x" by "y" in the
- window "win". "f" is the foreground and "b" the background colour
- for the overlay. If a caret does not already exist in the window
- one is created for it so that text may be inserted automatically
- by the user.
- - If a text area already exists in the window "win" then it is
- altered to reflect the new size, and any existing characters are
- copied. If either "x" or "y" are 0 on entry then the existing
- text area is not altered in that axis.
- - Returns HASWIN_TRUE if successful, or HASWIN_FALSE on any error.
-
- text *haswin_textmakearea(text *txt, int x, int y, char f, char b);
- - This routine creates a text overlay of size "x" by "y" and returns
- a pointer to it. "f" is the foreground and "b" the background
- colour for the overlay.
- - If the text area "txt" is non-zero then it is altered to reflect
- the new size, and any existing characters are copied. If either
- "x" or "y" are 0 on entry then the existing text area is not
- altered in that axis.
- - Returns a pointer to the new text area, or 0 on any error.
-
- int haswin_textredraw(window *win, int x0, int x1, int y0, int y1);
- - Force the text overlay between the character positions "x0","y0"
- and "x1","y1" for the window "win" to be redrawn.
-
- int haswin_textvdu(window *win, char ch)
- - Send the character "ch" along the VDU like stream for the window
- "win". The characters understood by the VDU stream are listed
- below.
- - Returns HASWIN_TRUE if successful, or HASWIN_FALSE on any error.
-
- character action
- ^@ 0 NULL
- ^G 7 ring the bell
- ^H 8 move left (stops at left edge)
- ^I 9 move right (wraps to next line, stops at bottom)
- ^J 10 move down (bottom wraps to top)
- ^K 11 move up (top wraps to bottom)
- ^L 12 clear text (move cursor to top left)
- ^M 13 move to begining of next line (can scroll)
- ^N 14 insert character
- ^O 15 insert line
- ^P 16 delete character
- ^Q 17 delete line
- ^R 18 scroll left
- ^S 19 scroll right
- ^T 20 scroll down
- ^U 21 scroll up
- ^* 30 move cursor to top left.
- <sp>-~ 32-126 character added to text (wraps to next line, scrolls)
- ^? 127 delete character and move left (stops at left edge)
- Unknown characters are ignored. New characters added to the text
- overwrite those that are already in the text overlay. The text
- overlay is automatically updated. The characters that scroll off the
- top, bottom or sides of the text overlay are lost.
-
- int haswin_textdeletechar(window *win, int x, int y);
- - delete the character at the position "x", "y" in window "win" and
- move the rest of the characters in the line to take up the space.
- A space character is added to the end of the line.
- - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
- int haswin_textdeleteline(window *win, int y);
- - delete line "y" in window "win" and move the rest of the lines in
- the text overlay to take up the space.
- A blank line is added to the end of the text overlay.
- - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
- int haswin_textinsertchar(window *win, int x, int y);
- - insert a space character at the position "x", "y" in window "win"
- and move the rest of the characters in the line to give the space.
- The last character on the line is lost.
- - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
- int haswin_textinsertline(window *win, int y);
- - insert a blank line "y" in window "win" and move the rest of the
- text overlay to give the space. The last line in the text overlay
- is lost.
- - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
- int haswin_textscrolldown(window *win);
- - move all the characters in the text overlay down one line. The
- last line is lost, and a blank line is created at the top of the
- text overlay.
- - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
- int haswin_textscrollup(window *win);
- - move all the characters in the text overlay up one line. The
- first line is lost, and a blank line is created at the bottom of
- the text overlay.
- - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
- int haswin_textscrollright(window *win);
- - move all the characters in the text overlay right one character.
- The last character of each line is lost, and a blank character is
- created at the left end of each line.
- - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
- int haswin_textscrollleft(window *win);
- - move all the characters in the text overlay left one character.
- The first character of each line is lost, and a blank character is
- created at the right end of each line.
- - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
- int haswin_textgetchar(window *win, int x, int y);
- - returns the character at the position "x", "y" in the text overlay
- of the window "win", or HASWIN_UNKNOWN if no character can be
- found.
-
- int haswin_textmove(window *win, int x, int y);
- - move the text cursor for the window "win" to the position "x", "y"
- in the text overlay.
- - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
- int haswin_textprintf(window *win, const char *fmt, ...);
- - Use vsprintf() to process the string "fmt" and the following
- arguments and then call haswin_textvdu() on the string. Note that
- \n means move vertically down one line, and \r means move down to
- the beginning of the next line.
- - returns the number of characters sent to the VDU stream for the
- window, or HASWIN_FALSE on any error.
-
- int haswin_textgetxposn(window *win);
- - return the X coordinate of the text cursor position for the window
- "win", or HASWIN_UNKNOWN on any error.
-
- int haswin_textgetyposn(window *win);
- - return the Y coordinate of the text cursor position for the window
- "win", or HASWIN_UNKNOWN on any error.
-
- int haswin_textgetxsize(window *win);
- - return the X size of the text cursor position for the window "win"
- or HASWIN_UNKNOWN on any error.
-
- int haswin_textgetysize(window *win);
- - return the Y size of the text cursor position for the window "win"
- or HASWIN_UNKNOWN on any error.
-
- int haswin_converttxtxtowin(window *win, int x);
- - This routine returns the X window offset for the window "win" of
- the left hand edge of the character position nearest to the
- position "x" in the window "win".
- - returns HASWIN_UNKNOWN on any error.
-
- int haswin_converttxtytowin(window *win, int y);
- - This routine returns the Y window offset for the window "win" of
- the bottom edge of the character position nearest to the position
- "y" in the window "win".
- - returns HASWIN_UNKNOWN on any error.
-
- int haswin_converttxtxytowin(window *win, int *x, int *y);
- - This routine takes the x,y position of a character in the text
- overlay of the window "win" and replaces the values by the window
- offset in the window "win" of the bottom left corner of the
- character.
- - returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
- int haswin_convertwinxtotxt(window *win, int x);
- - This routine takes a X offset in the window "win" and returns the
- X position of the nearest character in the text overlay for the
- window "win" to the offset "x".
- - returns HASWIN_UNKNOWN on any error.
-
- int haswin_convertwinytotxt(window *win, int y);
- - This routine takes a Y offset in the window "win" and returns the
- Y position of the nearest character in the text overlay for the
- window "win" to the offset "y".
- - returns HASWIN_UNKNOWN on any error.
-
- int haswin_convertwinxytotxt(window *win, int *x, int *y);
- - This routine takes an x,y offset in the window "win" and replaces
- the values by the X,Y position of the nearest character in the
- text overlay for the window "win".
- - returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
- int haswin_converttxtxtoscr(window *win, int x);
- - This routine returns the real screen X position of the left hand
- edge of the character position nearest to the position "x" in the
- window "win".
- - returns HASWIN_UNKNOWN on any error.
-
- int haswin_converttxtytoscr(window *win, int y);
- - This routine returns the real screen Y position of the left hand
- edge of the character position nearest to the position "y" in the
- window "win".
- - returns HASWIN_UNKNOWN on any error.
-
- int haswin_converttxtxytoscr(window *win, int *x, int *y);
- - This routine takes the x,y position of a character in the text
- overlay of the window "win" and replaces the values by the real
- screen coordinates of the bottom left corner of the character.
- - returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
- int haswin_convertscrxtotxt(window *win, int x);
- - This routine takes a real screen X position and returns the X
- position of the nearest character position in the text overlay for
- the window "win".
- - returns HASWIN_UNKNOWN on any error.
-
- int haswin_convertscrytotxt(window *win, int y);
- - This routine takes a real screen Y position and returns the Y
- position of the nearest character position in the text overlay for
- the window "win".
- - returns HASWIN_UNKNOWN on any error.
-
- int haswin_convertscrxytotxt(window *win, int *x, int *y);
- - This routine takes a real screen X,Y position and replaces these
- by the values of the x,y position of the nearest character
- position in the text overlay for the window "win".
- - returns HASWIN_UNKNOWN on any error.
-
-