/* Copyright (c) 1983 University of Maryland Computer Science Department */ /* This structure holds everything needed to do cursor motion except the pad character (PC) and the output speed of the terminal (ospeed), which termcap wants in global variables. */ struct cm { /* Cursor position */ int cm_curY, /* current row */ cm_curX; /* current column */ /* Capabilities from termcap(5) (including extensions) */ char *cm_up, /* up (up) */ *cm_down, /* down (do) */ *cm_left, /* left (bs) */ *cm_right, /* right (nd) */ *cm_home, /* home (ho) */ *cm_cr, /* carriage return (cr) */ *cm_ll, /* last line (ll) */ *cm_abs, /* absolute (cm) */ *cm_habs, /* horizontal absolute (ch) */ *cm_vabs, /* vertical absolute (cv) */ *cm_ds, /* "don't send" string (ds) */ *cm_tab; /* tab (ta) */ int cm_tabwidth, /* tab width (tw) */ cm_cols, /* Number of cols on screen (co) */ cm_rows, /* Number of rows on screen (li) */ cm_autowrap:1, /* autowrap flag (am) */ cm_magicwrap:1, /* vt100s: cursor stays in last col but will wrap if next char is printing (xn) */ cm_usetabs:1, /* if set, use tabs */ cm_autolf:1; /* \r performs a \r\n (rn) */ /* Costs */ int cc_up, /* cost for up */ cc_down, /* etc */ cc_left, cc_right, cc_home, cc_cr, cc_ll, cc_abs, /* abs costs are actually min costs */ cc_habs, cc_vabs, cc_tab; /* Functions */ int (*cx_costinit) (),/* initialize cost factors */ (*cx_goto) (), /* (*cx_goto) (row, col) moves cursor to specified coordinates (0 origin!!) */ (*cx_pad) (), /* (*cx_pad) (n, f) pads n * f msec (f is type float!) */ (*cx_put) (); /* points to putc function (for tputs) */ } Wcm; char PC; /* Pad character */ short ospeed; /* Output speed (from sg_ospeed) */ /* Shorthand */ #ifndef NoCMShortHand #define curY Wcm.cm_curY #define curX Wcm.cm_curX #define Up Wcm.cm_up #define Down Wcm.cm_down #define Left Wcm.cm_left #define Right Wcm.cm_right #define Home Wcm.cm_home #define CR Wcm.cm_cr #define LastLine Wcm.cm_ll #define Tab Wcm.cm_tab #define TabWidth Wcm.cm_tabwidth #define DontSent Wcm.cm_ds #define AbsPosition Wcm.cm_abs #define ColPosition Wcm.cm_habs #define RowPosition Wcm.cm_vabs #define AutoWrap Wcm.cm_autowrap #define MagicWrap Wcm.cm_magicwrap #define UseTabs Wcm.cm_usetabs #define AutoLF Wcm.cm_autolf #define ScreenRows Wcm.cm_rows #define ScreenCols Wcm.cm_cols #define cmcostinit() (*Wcm.cx_costinit) () #define cmgoto(row,col) (*Wcm.cx_goto) (row, col) #define cmat(row,col) (curY = (row), curX = (col)) #define cmplus(n) {if ((curX += (n)) >= ScreenCols && !MagicWrap)\ if (AutoWrap) curX = 0, curY++; else curX--;} #define cmpad(n,f) (*Wcm.cx_pad) (n, f) #define cmputc Wcm.cx_put #endif