/* * Copyright(c) 2006, Space Science and Engineering Center, UW-Madison * Refer to "McIDAS Software Acquisition and Distribution Policies" * in the file mcidas/data/license.txt */ /**** $Id: mcterm.c,v 1.24 2022/01/28 21:56:32 davep Exp $ ****/ /* Generated by wbuild from "unix/mcterm.w" ** (generator version $Revision: 1.24 $ of $Date: 2022/01/28 21:56:32 $) */ #include #include //#line 2380 "unix/mcterm.w" #include //#line 2381 "unix/mcterm.w" #include //#line 2382 "unix/mcterm.w" #include //#line 2383 "unix/mcterm.w" #include //#line 2387 "unix/mcterm.w" #include //#line 2392 "unix/mcterm.w" #include /* Generated by wbuild from "unix/mcterm.w" ** (generator version $Revision: 1.24 $ of $Date: 2022/01/28 21:56:32 $) */ #ifndef _XMcTermP_H_ #define _XMcTermP_H_ #include #include "mcterm.h" _XFUNCPROTOBEGIN #define ATTRIB_REV_SHIFT 0 #define ATTRIB_REV_WIDTH 1 #define ATTRIB_REV (1 <(b )?(a ):(b )) //#line 1100 "unix/mcterm.w" #define min(a, b) ((a )<(b )?(a ):(b )) //#line 1106 "unix/mcterm.w" static void draw_line( #if NeedFunctionPrototypes Widget,int ,int ,int #endif ); //#line 1185 "unix/mcterm.w" static Boolean convert_proc( #if NeedFunctionPrototypes Widget,Atom *,Atom *,Atom *,XtPointer *,unsigned long *,int * #endif ); //#line 1252 "unix/mcterm.w" static Boolean lose_proc( #if NeedFunctionPrototypes Widget,Atom * #endif ); //#line 1262 "unix/mcterm.w" static void paste_callback( #if NeedFunctionPrototypes Widget,XtPointer ,Atom *,Atom *,XtPointer ,unsigned long *,int * #endif ); //#line 1348 "unix/mcterm.w" static void compute_cell_size( #if NeedFunctionPrototypes Widget #endif ); //#line 1370 "unix/mcterm.w" static void set_resize_increments( #if NeedFunctionPrototypes Widget #endif ); //#line 1416 "unix/mcterm.w" static void allocate_contents( #if NeedFunctionPrototypes Widget #endif ); //#line 1466 "unix/mcterm.w" static void xor_cursor( #if NeedFunctionPrototypes Widget,int ,int ,int #endif ); //#line 1527 "unix/mcterm.w" static void enable_cursor( #if NeedFunctionPrototypes Widget #endif ); //#line 1544 "unix/mcterm.w" static void disable_cursor( #if NeedFunctionPrototypes Widget #endif ); //#line 1558 "unix/mcterm.w" static void toggle_cursor( #if NeedFunctionPrototypes Widget #endif ); //#line 1572 "unix/mcterm.w" static void blink_handler( #if NeedFunctionPrototypes XtPointer ,XtIntervalId * #endif ); //#line 1590 "unix/mcterm.w" static void map_handler( #if NeedFunctionPrototypes Widget,XtPointer ,XEvent *,Boolean * #endif ); //#line 1602 "unix/mcterm.w" static void mouse_press_handler( #if NeedFunctionPrototypes Widget,XtPointer ,XEvent *,Boolean * #endif ); //#line 1619 "unix/mcterm.w" static void synchronize_dims( #if NeedFunctionPrototypes Widget #endif ); //#line 1658 "unix/mcterm.w" static void clip_gcs( #if NeedFunctionPrototypes Widget #endif ); //#line 1695 "unix/mcterm.w" static void make_gc( #if NeedFunctionPrototypes Widget #endif ); //#line 1749 "unix/mcterm.w" static void attrib_gcs( #if NeedFunctionPrototypes Widget,attrib_t #endif ); //#line 1875 "unix/mcterm.w" static void add_char( #if NeedFunctionPrototypes Widget,int #endif ); //#line 1913 "unix/mcterm.w" static void repeat_char( #if NeedFunctionPrototypes Widget,int #endif ); //#line 1923 "unix/mcterm.w" static void next_tabstop( #if NeedFunctionPrototypes Widget #endif ); //#line 1946 "unix/mcterm.w" static void delete_line( #if NeedFunctionPrototypes Widget #endif ); //#line 1984 "unix/mcterm.w" static void insert_line( #if NeedFunctionPrototypes Widget #endif ); //#line 2018 "unix/mcterm.w" static void cursor_down( #if NeedFunctionPrototypes Widget #endif ); //#line 2034 "unix/mcterm.w" static void clear_eol( #if NeedFunctionPrototypes Widget #endif ); //#line 2048 "unix/mcterm.w" static void clear_eos( #if NeedFunctionPrototypes Widget #endif ); //#line 2069 "unix/mcterm.w" static void delete_char( #if NeedFunctionPrototypes Widget #endif ); //#line 2085 "unix/mcterm.w" static void insert_chars( #if NeedFunctionPrototypes Widget,int #endif ); //#line 2101 "unix/mcterm.w" static void set_cursortype( #if NeedFunctionPrototypes Widget,int #endif ); //#line 2113 "unix/mcterm.w" static void set_scroll( #if NeedFunctionPrototypes Widget,int ,int #endif ); //#line 2130 "unix/mcterm.w" static void set_attrib( #if NeedFunctionPrototypes Widget,int #endif ); //#line 2189 "unix/mcterm.w" static void attrib_set_foreground( #if NeedFunctionPrototypes attrib_t *,int #endif ); //#line 2199 "unix/mcterm.w" static int attrib_get_foreground( #if NeedFunctionPrototypes attrib_t #endif ); //#line 2212 "unix/mcterm.w" static void attrib_set_background( #if NeedFunctionPrototypes attrib_t *,int #endif ); //#line 2222 "unix/mcterm.w" static int attrib_get_background( #if NeedFunctionPrototypes attrib_t #endif ); //#line 2235 "unix/mcterm.w" static void goto_xy( #if NeedFunctionPrototypes Widget,int ,int #endif ); //#line 2247 "unix/mcterm.w" static void find_cell( #if NeedFunctionPrototypes Widget,int ,int ,int *,int * #endif ); //#line 2269 "unix/mcterm.w" static void handle_keys( #if NeedFunctionPrototypes Widget,XtPointer ,XEvent *,Boolean * #endif ); //#line 2278 "unix/mcterm.w" static void print_geometry( #if NeedFunctionPrototypes FILE *,XtWidgetGeometry * #endif ); //#line 2312 "unix/mcterm.w" static void request_resize( #if NeedFunctionPrototypes Widget,Dimension ,Dimension #endif ); //#line 1106 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1106 "unix/mcterm.w" static void draw_line(Widget self,int row,int lft,int rgt) #else //#line 1106 "unix/mcterm.w" static void draw_line(self,row,lft,rgt)Widget self;int row;int lft;int rgt; #endif //#line 1107 "unix/mcterm.w" { Display *dpy = XtDisplay(self); Window win = XtWindow(self); int x, y; Bool undid_cursor = False; x = ((XMcTermWidget)self)->xmcTerm.margin + lft * ((XMcTermWidget)self)->xmcTerm.cellwidth; y = ((XMcTermWidget)self)->xmcTerm.margin + row * ((XMcTermWidget)self)->xmcTerm.cellheight + ((XMcTermWidget)self)->xmcTerm.font->ascent; /* * disable the cursor if we are about to draw over it */ if (((XMcTermWidget)self)->xmcTerm.cursor_on && row == ((XMcTermWidget)self)->xmcTerm.xor_cursory && lft <= ((XMcTermWidget)self)->xmcTerm.xor_cursorx && ((XMcTermWidget)self)->xmcTerm.xor_cursorx < rgt) { disable_cursor(self); undid_cursor = True; } /* * draw the requested text */ while (lft < rgt) { int i, n; GC use_gc; i = lft + 1; while (i < rgt && ((XMcTermWidget)self)->xmcTerm.attribs[row][i] == ((XMcTermWidget)self)->xmcTerm.attribs[row][lft]) i++; attrib_gcs(self, ((XMcTermWidget)self)->xmcTerm.attribs[row][lft]); switch (((XMcTermWidget)self)->xmcTerm.attribs[row][lft] & ATTRIB_REV) { case 0: use_gc = ((XMcTermWidget)self)->xmcTerm.defgc; break; case ATTRIB_REV: use_gc = ((XMcTermWidget)self)->xmcTerm.revgc; break; } n = i - lft; XDrawImageString(dpy, win, use_gc, x, y, &((XMcTermWidget)self)->xmcTerm.contents[row][lft], n); if (((XMcTermWidget)self)->xmcTerm.attribs[row][lft] & ATTRIB_ULINE) { /* * We want to draw a line of n * $cellwidth pixels * beginning at [x,y]. Since the endpoint of the * line is included in the line, the endpoint is * [x+n*$cellwidth-1,y] */ XDrawLine(dpy, win, use_gc, x, y + ((XMcTermWidget)self)->xmcTerm.uline_pos, x + n * ((XMcTermWidget)self)->xmcTerm.cellwidth - 1, y + ((XMcTermWidget)self)->xmcTerm.uline_pos); } lft = i; x += n * ((XMcTermWidget)self)->xmcTerm.cellwidth; } /* * restore the cursor if we had to disable it */ if (undid_cursor) enable_cursor(self); } //#line 1185 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1185 "unix/mcterm.w" static Boolean convert_proc(Widget self,Atom * selection,Atom * target,Atom * type_return,XtPointer * value_return,unsigned long * length_return,int * format_return) #else //#line 1185 "unix/mcterm.w" static Boolean convert_proc(self,selection,target,type_return,value_return,length_return,format_return)Widget self;Atom * selection;Atom * target;Atom * type_return;XtPointer * value_return;unsigned long * length_return;int * format_return; #endif //#line 1186 "unix/mcterm.w" { static Atom xa_targets = None; if (xa_targets == None) { xa_targets = XInternAtom(XtDisplay(self), "TARGETS", False); assert(xa_targets != None); } if (*target == xa_targets) { /* We support this many conversion atoms. */ const unsigned long num_atoms = 2; /* * On some systems, the Atom typedef is 64 bits wide, so * we need an Atom typedef that is guaranteed to be 32 bits * wide. * * This is because *format_return MUST be set to one of 8, 16, * or 32. 64 is not allowed. */ typedef CARD32 Atom32; Atom32 *valueP; int i; /* Create the list of conversion atoms we support */ valueP = (Atom32 *) XtMalloc((Cardinal)(sizeof(Atom32) * (num_atoms))); assert(valueP); i = 0; valueP[i++] = (Atom32) XA_STRING; valueP[i++] = (Atom32) xa_targets; assert(i == num_atoms); /* Arrange to return it */ *type_return = XA_ATOM; *value_return = (XtPointer) valueP; *length_return = num_atoms; *format_return = sizeof(Atom32) * 8; assert(*format_return == 32); /* if (value_return) XtFree(value_return); */ return True; } else if (*target == XA_STRING) { *type_return = XA_STRING; *value_return = ((XMcTermWidget)self)->xmcTerm.selection; *length_return = ((XMcTermWidget)self)->xmcTerm.selection_len; *format_return = 8; mct_debug(self, "convert_proc(): XA_STRING:"); mct_debug(self, *value_return); int i; /* Only do this if we have MCPASTE set */ if (((XMcTermWidget)self)->xmcTerm.paste_mode < 2) { /* Compare to local copy */ if (strcmp(*value_return, (XtPointer)((XMcTermWidget)self)->xmcTerm.paste_string)) { mct_debug(self, "convert_proc(): selection does not match paste_string, reassigning:"); *value_return = ((XMcTermWidget)self)->xmcTerm.paste_string; *length_return = strlen(((XMcTermWidget)self)->xmcTerm.paste_string); mct_debug(self, *value_return); } /* Look for nonalpha characters */ char *foo; for (i=0; i 126) { printf("%d: %c [%d]\n", i, *foo, *foo); mct_debug(self, "convert_proc(): Bad char: False"); *value_return = NULL; *length_return = 0; return False; } } /* See if we have anyting at all */ if (*value_return == NULL || *length_return == 0 || strlen(*value_return) == 0) { mct_debug(self, "convert_proc(): 0 bytes: False"); *value_return = NULL; *length_return = 0; return False; } } /* End MCPASTE protection */ mct_debug(self, "convert_proc(): True"); return True; } else { mct_debug(self, "convert_proc(): False"); return False; } } //#line 1252 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1252 "unix/mcterm.w" static Boolean lose_proc(Widget self,Atom * selection) #else //#line 1252 "unix/mcterm.w" static Boolean lose_proc(self,selection)Widget self;Atom * selection; #endif //#line 1253 "unix/mcterm.w" { if (((XMcTermWidget)self)->xmcTerm.paste_mode != 0) { ((XMcTermWidget)self)->xmcTerm.paste_ok = True; ((XMcTermWidget)self)->xmcTerm.paste_lastfree = NULL; mct_debug(self, "lose_proc(): paste_ok: True"); } else { mct_debug(self, "lose_proc()"); } } //#line 1262 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1262 "unix/mcterm.w" static void paste_callback(Widget self,XtPointer client_data,Atom * selection,Atom * type,XtPointer value,unsigned long * length,int * format) #else //#line 1262 "unix/mcterm.w" static void paste_callback(self,client_data,selection,type,value,length,format)Widget self;XtPointer client_data;Atom * selection;Atom * type;XtPointer value;unsigned long * length;int * format; #endif //#line 1263 "unix/mcterm.w" { /* See if this looks like our last paste */ /* if (((XMcTermWidget)self)->xmcTerm.paste_lastfree == value) { mct_debug(self, "paste_callback(): Double paste intercepted!"); return; } */ /* if it's what we're expecting, process it */ if(*selection == XA_PRIMARY && *type == XA_STRING && *format == 8 && value && *length > 0) { char *text = (char *) value; mct_debug(self, "paste_callback: text:"); mct_debug(self, text); int i; for (i = 0; i < *length; i++) XtCallCallbackList(self, ((XMcTermWidget)self)->xmcTerm.pasteCallback, (XtPointer) &text[i]); /* Examine paste_mode to determine what to do with clipboard */ if (((XMcTermWidget)self)->xmcTerm.paste_mode == 0) { ((XMcTermWidget)self)->xmcTerm.paste_ok = False; mct_debug(self, "paste_callback(): paste_ok: False"); return; } if (((XMcTermWidget)self)->xmcTerm.paste_free) { if (value) { mct_debug(self, "paste_callback(): Attempt XtFree()"); if (((XMcTermWidget)self)->xmcTerm.paste_lastfree == value) { mct_debug(self, "paste_callback(): Double free prevented!"); } else { ((XMcTermWidget)self)->xmcTerm.paste_lastfree = value; XtFree(value); } } } else { mct_debug(self, "paste_callback(): Prevent XtFree()"); } if (((XMcTermWidget)self)->xmcTerm.paste_mode == 1) { ((XMcTermWidget)self)->xmcTerm.paste_ok = False; mct_debug(self, "paste_callback(): paste_ok: False"); } else { ((XMcTermWidget)self)->xmcTerm.paste_ok = True; mct_debug(self, "paste_callback(): paste_ok: True"); } return; } /* * *format == 32 for XA_ATOM, even though Atom is 64 bits on some * platforms... */ #if 0 if(*selection == XA_PRIMARY && *type == XA_ATOM && *format == 32) { Atom *list = (Atom *) value; int i; fprintf(stderr, "paste_callback: %lu targets\n", *length); for (i = 0; i < *length; i++) { char *name = "!!!NAME NOT RETRIEVED!!!"; if (list[i] == XT_CONVERT_FAIL) { name = "XT_CONVERT_FAIL"; } else if (list[i] == 0) { name = "!!!ZERO ATOM!!!"; } else { name = XGetAtomName(XtDisplay(self), (Atom) list[i]); if (!name) name = "!!!NULL!!!"; } fprintf(stderr, "paste_callback: targets[%d] == 0x%08X (%s)\n", i, (unsigned int) list[i], name); } fflush(stderr); if (value) XtFree(value); return; } #endif /* if we get to here, it's an error */ XBell(XtDisplay(self), 0); mct_debug(self, "paste_callback(): Error"); if (((XMcTermWidget)self)->xmcTerm.paste_mode != 0) { if (((XMcTermWidget)self)->xmcTerm.paste_free) { if (value) { mct_debug(self, "paste_callback(): Attempt XtFree()"); if (((XMcTermWidget)self)->xmcTerm.paste_lastfree == value) { mct_debug(self, "paste_callback(): Double free prevented!"); } else { ((XMcTermWidget)self)->xmcTerm.paste_lastfree = value; XtFree(value); } } } else { mct_debug(self, "paste_callback(): Prevent XtFree()"); } } } //#line 1348 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1348 "unix/mcterm.w" static void compute_cell_size(Widget self) #else //#line 1348 "unix/mcterm.w" static void compute_cell_size(self)Widget self; #endif //#line 1349 "unix/mcterm.w" { unsigned long h1; if (! XGetFontProperty(((XMcTermWidget)self)->xmcTerm.font, XA_QUAD_WIDTH, &h1)) h1 = XTextWidth(((XMcTermWidget)self)->xmcTerm.font, "M", 1); ((XMcTermWidget)self)->xmcTerm.cellwidth = (int) h1; h1 = ((XMcTermWidget)self)->xmcTerm.font->ascent + ((XMcTermWidget)self)->xmcTerm.font->descent; ((XMcTermWidget)self)->xmcTerm.cellheight = (int) h1; if (! XGetFontProperty(((XMcTermWidget)self)->xmcTerm.font, XA_UNDERLINE_POSITION, &h1)) h1 = 2; ((XMcTermWidget)self)->xmcTerm.uline_pos = (int) h1; if (! XGetFontProperty(((XMcTermWidget)self)->xmcTerm.font, XA_UNDERLINE_THICKNESS, &h1)) h1 = 1; ((XMcTermWidget)self)->xmcTerm.uline_thick = (int) h1; } //#line 1370 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1370 "unix/mcterm.w" static void set_resize_increments(Widget self) #else //#line 1370 "unix/mcterm.w" static void set_resize_increments(self)Widget self; #endif //#line 1371 "unix/mcterm.w" { Widget top; top = XtParent(self); if (!top) return; if (!XtIsWMShell(top)) return; if (((XMcTermWidget)self)->xmcTerm.debug_set_resize_increments) { fprintf(stderr, "Setting baseWidth = %ld\n", (long)(2 * ((XMcTermWidget)self)->xmcTerm.margin)); fprintf(stderr, "Setting baseHeight = %ld\n", (long)(2 * ((XMcTermWidget)self)->xmcTerm.margin)); fprintf(stderr, "Setting widthInc = %ld\n", (long)(((XMcTermWidget)self)->xmcTerm.cellwidth)); fprintf(stderr, "Setting heightInc = %ld\n", (long)(((XMcTermWidget)self)->xmcTerm.cellheight)); } XtVaSetValues(top, XtNbaseWidth, 2 * ((XMcTermWidget)self)->xmcTerm.margin, XtNbaseHeight, 2 * ((XMcTermWidget)self)->xmcTerm.margin, XtNwidthInc, ((XMcTermWidget)self)->xmcTerm.cellwidth, XtNheightInc, ((XMcTermWidget)self)->xmcTerm.cellheight, /* * Set some reasonable minimum sizes. */ XtNminWidth, 2 * ((XMcTermWidget)self)->xmcTerm.margin + 8 * ((XMcTermWidget)self)->xmcTerm.cellwidth, XtNminHeight, 2 * ((XMcTermWidget)self)->xmcTerm.margin + 4 * ((XMcTermWidget)self)->xmcTerm.cellheight, NULL); } //#line 1416 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1416 "unix/mcterm.w" static void allocate_contents(Widget self) #else //#line 1416 "unix/mcterm.w" static void allocate_contents(self)Widget self; #endif //#line 1417 "unix/mcterm.w" { int i, j; /* Remove superfluous lines */ for (i = ((XMcTermWidget)self)->xmcTerm.rows; i < ((XMcTermWidget)self)->xmcTerm.allocated_rows; i++) { XtFree(((XMcTermWidget)self)->xmcTerm.contents[i]); XtFree((char *)((XMcTermWidget)self)->xmcTerm.attribs[i]); } /* Allocate and initialize new lines */ ((XMcTermWidget)self)->xmcTerm.contents = (char **)XtRealloc((char *)((XMcTermWidget)self)->xmcTerm.contents, ((XMcTermWidget)self)->xmcTerm.rows*(int)sizeof(char *)); ((XMcTermWidget)self)->xmcTerm.attribs = (attrib_t **)XtRealloc((char *)((XMcTermWidget)self)->xmcTerm.attribs, ((XMcTermWidget)self)->xmcTerm.rows*(int)sizeof(attrib_t*)); for (i = ((XMcTermWidget)self)->xmcTerm.allocated_rows; i < ((XMcTermWidget)self)->xmcTerm.rows; i++) { ((XMcTermWidget)self)->xmcTerm.contents[i] = XtMalloc(((XMcTermWidget)self)->xmcTerm.columns*(int)sizeof(char)); ((XMcTermWidget)self)->xmcTerm.attribs[i] = (attrib_t *)XtMalloc(((XMcTermWidget)self)->xmcTerm.columns*(int)sizeof(attrib_t)); for (j = 0; j < ((XMcTermWidget)self)->xmcTerm.columns; j++) { ((XMcTermWidget)self)->xmcTerm.contents[i][j] = ' '; ((XMcTermWidget)self)->xmcTerm.attribs[i][j] = 0; } } /* Lengthen or shorten existing lines */ if (((XMcTermWidget)self)->xmcTerm.allocated_columns != ((XMcTermWidget)self)->xmcTerm.columns) { for (i = 0; i < min(((XMcTermWidget)self)->xmcTerm.allocated_rows, ((XMcTermWidget)self)->xmcTerm.rows); i++) { ((XMcTermWidget)self)->xmcTerm.contents[i] = XtRealloc(((XMcTermWidget)self)->xmcTerm.contents[i], ((XMcTermWidget)self)->xmcTerm.columns*(int)sizeof(char)); ((XMcTermWidget)self)->xmcTerm.attribs[i] = (attrib_t *)XtRealloc((char *)((XMcTermWidget)self)->xmcTerm.attribs[i], ((XMcTermWidget)self)->xmcTerm.columns*(int)sizeof(attrib_t)); for (j = ((XMcTermWidget)self)->xmcTerm.allocated_columns; j < ((XMcTermWidget)self)->xmcTerm.columns; j++) { ((XMcTermWidget)self)->xmcTerm.contents[i][j] = ' '; ((XMcTermWidget)self)->xmcTerm.attribs[i][j] = 0; } } } if (((XMcTermWidget)self)->xmcTerm.allocated_rows != ((XMcTermWidget)self)->xmcTerm.rows) { set_scroll(self, 0, ((XMcTermWidget)self)->xmcTerm.rows-1); } if (((XMcTermWidget)self)->xmcTerm.allocated_columns != ((XMcTermWidget)self)->xmcTerm.columns) { ((XMcTermWidget)self)->xmcTerm.do_wrap = False; } ((XMcTermWidget)self)->xmcTerm.allocated_rows = ((XMcTermWidget)self)->xmcTerm.rows; ((XMcTermWidget)self)->xmcTerm.allocated_columns = ((XMcTermWidget)self)->xmcTerm.columns; } //#line 1466 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1466 "unix/mcterm.w" static void xor_cursor(Widget self,int type,int row,int col) #else //#line 1466 "unix/mcterm.w" static void xor_cursor(self,type,row,col)Widget self;int type;int row;int col; #endif //#line 1467 "unix/mcterm.w" { Display *dpy = XtDisplay(self); Window win = XtWindow(self); int x, y; int half_height; int three_quarter_height; unsigned int width, height; x = ((XMcTermWidget)self)->xmcTerm.margin + col * ((XMcTermWidget)self)->xmcTerm.cellwidth; y = ((XMcTermWidget)self)->xmcTerm.margin + row * ((XMcTermWidget)self)->xmcTerm.cellheight; width = ((XMcTermWidget)self)->xmcTerm.cellwidth; height = ((XMcTermWidget)self)->xmcTerm.cellheight; half_height = ((XMcTermWidget)self)->xmcTerm.cellheight/2; three_quarter_height = (3 * ((XMcTermWidget)self)->xmcTerm.cellheight) / 4; attrib_gcs(self, ((XMcTermWidget)self)->xmcTerm.attribs[row][col]); switch (type) { case XMcTermCursorBlank: /* don't draw anything */ break; case XMcTermCursorUnderline: y += ((XMcTermWidget)self)->xmcTerm.cellheight-1; height -= ((XMcTermWidget)self)->xmcTerm.cellheight-1; XFillRectangle(dpy, win, ((XMcTermWidget)self)->xmcTerm.cursorgc, x, y, width, height); break; case XMcTermCursorFullHollow: XDrawRectangle(dpy, win, ((XMcTermWidget)self)->xmcTerm.cursorgc, x, y, width-1, height-1); break; case XMcTermCursorFullSolid: XFillRectangle(dpy, win, ((XMcTermWidget)self)->xmcTerm.cursorgc, x, y, width, height); break; case XMcTermCursorHalfHollow: y += half_height; height -= half_height; XDrawRectangle(dpy, win, ((XMcTermWidget)self)->xmcTerm.cursorgc, x, y, width-1, height-1); break; case XMcTermCursorHalfSolid: y += half_height; height -= half_height; XFillRectangle(dpy, win, ((XMcTermWidget)self)->xmcTerm.cursorgc, x, y, width, height); break; case XMcTermCursorQuarterHollow: y += three_quarter_height; height -= three_quarter_height; XDrawRectangle(dpy, win, ((XMcTermWidget)self)->xmcTerm.cursorgc, x, y, width-1, height-1); break; case XMcTermCursorQuarterSolid: y += three_quarter_height; height -= three_quarter_height; XFillRectangle(dpy, win, ((XMcTermWidget)self)->xmcTerm.cursorgc, x, y, width, height); break; } } //#line 1527 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1527 "unix/mcterm.w" static void enable_cursor(Widget self) #else //#line 1527 "unix/mcterm.w" static void enable_cursor(self)Widget self; #endif //#line 1528 "unix/mcterm.w" { if (((XMcTermWidget)self)->xmcTerm.cursor_on) { /* Restore to normal */ return; } xor_cursor(self, ((XMcTermWidget)self)->xmcTerm.cursortype, ((XMcTermWidget)self)->xmcTerm.cursory, ((XMcTermWidget)self)->xmcTerm.cursorx); ((XMcTermWidget)self)->xmcTerm.xor_cursorx = ((XMcTermWidget)self)->xmcTerm.cursorx; ((XMcTermWidget)self)->xmcTerm.xor_cursory = ((XMcTermWidget)self)->xmcTerm.cursory; ((XMcTermWidget)self)->xmcTerm.xor_cursortype = ((XMcTermWidget)self)->xmcTerm.cursortype; ((XMcTermWidget)self)->xmcTerm.cursor_on = True; } //#line 1544 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1544 "unix/mcterm.w" static void disable_cursor(Widget self) #else //#line 1544 "unix/mcterm.w" static void disable_cursor(self)Widget self; #endif //#line 1545 "unix/mcterm.w" { if (! ((XMcTermWidget)self)->xmcTerm.cursor_on) { return; } xor_cursor(self, ((XMcTermWidget)self)->xmcTerm.xor_cursortype, ((XMcTermWidget)self)->xmcTerm.xor_cursory, ((XMcTermWidget)self)->xmcTerm.xor_cursorx); ((XMcTermWidget)self)->xmcTerm.cursor_on = False; } //#line 1558 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1558 "unix/mcterm.w" static void toggle_cursor(Widget self) #else //#line 1558 "unix/mcterm.w" static void toggle_cursor(self)Widget self; #endif //#line 1559 "unix/mcterm.w" { if (((XMcTermWidget)self)->xmcTerm.cursor_on) { disable_cursor(self); } else { enable_cursor(self); } } //#line 1572 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1572 "unix/mcterm.w" static void blink_handler(XtPointer client_data,XtIntervalId * id) #else //#line 1572 "unix/mcterm.w" static void blink_handler(client_data,id)XtPointer client_data;XtIntervalId * id; #endif //#line 1573 "unix/mcterm.w" { Widget self = (Widget) client_data; toggle_cursor(self); ((XMcTermWidget)self)->xmcTerm.timer = XtAppAddTimeOut(XtWidgetToApplicationContext(self), 500, blink_handler, self); } //#line 1590 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1590 "unix/mcterm.w" static void map_handler(Widget self,XtPointer client_data,XEvent * event,Boolean * cont) #else //#line 1590 "unix/mcterm.w" static void map_handler(self,client_data,event,cont)Widget self;XtPointer client_data;XEvent * event;Boolean * cont; #endif //#line 1591 "unix/mcterm.w" { if (event->type == MapNotify) ((XMcTermWidget)self)->xmcTerm.timer = XtAppAddTimeOut(XtWidgetToApplicationContext(self), 500, blink_handler, self); else if (event->type == UnmapNotify) XtRemoveTimeOut(((XMcTermWidget)self)->xmcTerm.timer); } //#line 1602 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1602 "unix/mcterm.w" static void mouse_press_handler(Widget self,XtPointer client_data,XEvent * event,Boolean * cont) #else //#line 1602 "unix/mcterm.w" static void mouse_press_handler(self,client_data,event,cont)Widget self;XtPointer client_data;XEvent * event;Boolean * cont; #endif //#line 1603 "unix/mcterm.w" { char tbuffer[128]; if(event->xany.send_event) { /* Pass to mct_winx.c so the mouse press can be handled */ XtCallCallbackList(self, ((XMcTermWidget)self)->xmcTerm.mouseCallback, &event->xbutton); } } //#line 1619 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1619 "unix/mcterm.w" static void synchronize_dims(Widget self) #else //#line 1619 "unix/mcterm.w" static void synchronize_dims(self)Widget self; #endif //#line 1620 "unix/mcterm.w" { XMcTermWindowSizeInfo cb_info; int oldcolumns = ((XMcTermWidget)self)->xmcTerm.columns, oldrows = ((XMcTermWidget)self)->xmcTerm.rows; ((XMcTermWidget)self)->xmcTerm.columns = max(1, ((int)((XMcTermWidget)self)->core.width - 2 * ((XMcTermWidget)self)->xmcTerm.margin)/((XMcTermWidget)self)->xmcTerm.cellwidth); ((XMcTermWidget)self)->xmcTerm.rows = max(1, ((int)((XMcTermWidget)self)->core.height - 2 * ((XMcTermWidget)self)->xmcTerm.margin)/((XMcTermWidget)self)->xmcTerm.cellheight); if (((XMcTermWidget)self)->xmcTerm.cursorx >= ((XMcTermWidget)self)->xmcTerm.columns) { ((XMcTermWidget)self)->xmcTerm.cursorx = ((XMcTermWidget)self)->xmcTerm.columns - 1; ((XMcTermWidget)self)->xmcTerm.do_wrap = False; } if (((XMcTermWidget)self)->xmcTerm.cursory >= ((XMcTermWidget)self)->xmcTerm.rows) ((XMcTermWidget)self)->xmcTerm.cursory = ((XMcTermWidget)self)->xmcTerm.rows - 1; if (((XMcTermWidget)self)->xmcTerm.rows != oldrows || ((XMcTermWidget)self)->xmcTerm.columns != oldcolumns) { Bool undid_cursor = False; /* * Disable the cursor before resizing the window in case * the old cursor position will be off the new screen. */ if (((XMcTermWidget)self)->xmcTerm.cursor_on) { disable_cursor(self); undid_cursor = True; } allocate_contents(self); cb_info.rows = ((XMcTermWidget)self)->xmcTerm.rows; cb_info.columns = ((XMcTermWidget)self)->xmcTerm.columns; XtCallCallbackList(self, ((XMcTermWidget)self)->xmcTerm.resizeCallback, &cb_info); /* * Enable the cursor if we disabled it. */ if (undid_cursor) enable_cursor(self); } } //#line 1658 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1658 "unix/mcterm.w" static void clip_gcs(Widget self) #else //#line 1658 "unix/mcterm.w" static void clip_gcs(self)Widget self; #endif //#line 1659 "unix/mcterm.w" { XRectangle rect; /* * If the user specifies an initial geometry with -geometry, * the resize() method gets called before the window is * realized. In that case, we need to avoid modifying the * GCs because they have not been created yet. */ if (! XtIsRealized(self)) return; /* the inside of our window */ rect.x = 0; rect.y = 0; rect.width = ((XMcTermWidget)self)->core.width; rect.height = ((XMcTermWidget)self)->core.height; XSetClipRectangles(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.defgc, 0, 0, &rect, 1, YXSorted); XSetClipRectangles(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.revgc, 0, 0, &rect, 1, YXSorted); XSetClipRectangles(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.cursorgc, 0, 0, &rect, 1, YXSorted); } //#line 1695 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1695 "unix/mcterm.w" static void make_gc(Widget self) #else //#line 1695 "unix/mcterm.w" static void make_gc(self)Widget self; #endif //#line 1696 "unix/mcterm.w" { XGCValues values; unsigned long mask; if (! XtIsRealized(self)) return; mask = GCFont | GCLineWidth; if (((XMcTermWidget)self)->xmcTerm.defgc) XFreeGC(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.defgc); values.font = ((XMcTermWidget)self)->xmcTerm.font->fid; values.line_width = ((XMcTermWidget)self)->xmcTerm.uline_thick; ((XMcTermWidget)self)->xmcTerm.defgc = XCreateGC(XtDisplay(self), XtWindow(self), mask, &values); if (((XMcTermWidget)self)->xmcTerm.revgc) XFreeGC(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.revgc); values.font = ((XMcTermWidget)self)->xmcTerm.font->fid; values.line_width = ((XMcTermWidget)self)->xmcTerm.uline_thick; ((XMcTermWidget)self)->xmcTerm.revgc = XCreateGC(XtDisplay(self), XtWindow(self), mask, &values); /* * To quote from the X FAQ: * * You might expect that when using GXxor to draw black on black you * would get white. But this is not necessarily the case, since * GXxor does not operate on RGB values but on colormap indices. * * If you want to use GXxor simply to switch between two colors, * then you can take the shortcut of setting the background color * in the GC (graphics context) to 0 and the foreground color to a * value such that when it draws over red, say, the result is blue, * and when it draws over blue the result is red. This foreground * value is itself the XOR of the colormap indices of red and blue. * * Hence the peculiar settings for the background and foreground * pixels in |cursorgc|. */ mask = GCFunction | GCLineWidth; if (((XMcTermWidget)self)->xmcTerm.cursorgc) XFreeGC(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.cursorgc); values.function = GXxor; values.line_width = 0; ((XMcTermWidget)self)->xmcTerm.cursorgc = XCreateGC(XtDisplay(self), XtWindow(self), mask, &values); attrib_gcs(self, 0); clip_gcs(self); } //#line 1749 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1749 "unix/mcterm.w" static void attrib_gcs(Widget self,attrib_t a) #else //#line 1749 "unix/mcterm.w" static void attrib_gcs(self,a)Widget self;attrib_t a; #endif //#line 1750 "unix/mcterm.w" { Pixel fg; Pixel bg; if (! XtIsRealized(self)) return; switch(attrib_get_foreground(a)) { case XMcTermForegroundBlack: fg = a & ATTRIB_BRIGHT ? ((XMcTermWidget)self)->xmcTerm.foregroundBrightBlack : ((XMcTermWidget)self)->xmcTerm.foregroundNormalBlack; break; case XMcTermForegroundRed: fg = a & ATTRIB_BRIGHT ? ((XMcTermWidget)self)->xmcTerm.foregroundBrightRed : ((XMcTermWidget)self)->xmcTerm.foregroundNormalRed; break; case XMcTermForegroundGreen: fg = a & ATTRIB_BRIGHT ? ((XMcTermWidget)self)->xmcTerm.foregroundBrightGreen : ((XMcTermWidget)self)->xmcTerm.foregroundNormalGreen; break; case XMcTermForegroundYellow: fg = a & ATTRIB_BRIGHT ? ((XMcTermWidget)self)->xmcTerm.foregroundBrightYellow : ((XMcTermWidget)self)->xmcTerm.foregroundNormalYellow; break; case XMcTermForegroundBlue: fg = a & ATTRIB_BRIGHT ? ((XMcTermWidget)self)->xmcTerm.foregroundBrightBlue : ((XMcTermWidget)self)->xmcTerm.foregroundNormalBlue; break; case XMcTermForegroundMagenta: fg = a & ATTRIB_BRIGHT ? ((XMcTermWidget)self)->xmcTerm.foregroundBrightMagenta : ((XMcTermWidget)self)->xmcTerm.foregroundNormalMagenta; break; case XMcTermForegroundCyan: fg = a & ATTRIB_BRIGHT ? ((XMcTermWidget)self)->xmcTerm.foregroundBrightCyan : ((XMcTermWidget)self)->xmcTerm.foregroundNormalCyan; break; case XMcTermForegroundWhite: fg = a & ATTRIB_BRIGHT ? ((XMcTermWidget)self)->xmcTerm.foregroundBrightWhite : ((XMcTermWidget)self)->xmcTerm.foregroundNormalWhite; break; default: fg = a & ATTRIB_BRIGHT ? ((XMcTermWidget)self)->xmcTerm.foregroundBright : ((XMcTermWidget)self)->xmcTerm.foreground; break; } switch(attrib_get_background(a)) { case XMcTermBackgroundBlack: bg = ((XMcTermWidget)self)->xmcTerm.backgroundBlack; break; case XMcTermBackgroundRed: bg = ((XMcTermWidget)self)->xmcTerm.backgroundRed; break; case XMcTermBackgroundGreen: bg = ((XMcTermWidget)self)->xmcTerm.backgroundGreen; break; case XMcTermBackgroundYellow: bg = ((XMcTermWidget)self)->xmcTerm.backgroundYellow; break; case XMcTermBackgroundBlue: bg = ((XMcTermWidget)self)->xmcTerm.backgroundBlue; break; case XMcTermBackgroundMagenta: bg = ((XMcTermWidget)self)->xmcTerm.backgroundMagenta; break; case XMcTermBackgroundCyan: bg = ((XMcTermWidget)self)->xmcTerm.backgroundCyan; break; case XMcTermBackgroundWhite: bg = ((XMcTermWidget)self)->xmcTerm.backgroundWhite; break; default: bg = ((XMcTermWidget)self)->core.background_pixel; break; } XSetForeground(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.defgc, fg); XSetBackground(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.defgc, bg); XSetForeground(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.revgc, bg); XSetBackground(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.revgc, fg); /* * To quote from the X FAQ: * * You might expect that when using GXxor to draw black on black you * would get white. But this is not necessarily the case, since * GXxor does not operate on RGB values but on colormap indices. * * If you want to use GXxor simply to switch between two colors, * then you can take the shortcut of setting the background color * in the GC (graphics context) to 0 and the foreground color to a * value such that when it draws over red, say, the result is blue, * and when it draws over blue the result is red. This foreground * value is itself the XOR of the colormap indices of red and blue. * * Hence the peculiar settings for the background and foreground * pixels in |cursorgc|. */ XSetForeground(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.cursorgc, fg ^ bg); XSetBackground(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.cursorgc, 0); } //#line 1875 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1875 "unix/mcterm.w" static void add_char(Widget self,int c) #else //#line 1875 "unix/mcterm.w" static void add_char(self,c)Widget self;int c; #endif //#line 1876 "unix/mcterm.w" { if (((XMcTermWidget)self)->xmcTerm.do_wrap) { ((XMcTermWidget)self)->xmcTerm.cursorx = 0; /* CR */ cursor_down(self); /* LF */ ((XMcTermWidget)self)->xmcTerm.do_wrap = False; } if (((XMcTermWidget)self)->xmcTerm.insert_mode) { memmove(&((XMcTermWidget)self)->xmcTerm.contents[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx+1], &((XMcTermWidget)self)->xmcTerm.contents[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx], (((XMcTermWidget)self)->xmcTerm.columns - ((XMcTermWidget)self)->xmcTerm.cursorx - 1)); memmove(&((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx+1], &((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx], sizeof(attrib_t)*(((XMcTermWidget)self)->xmcTerm.columns - ((XMcTermWidget)self)->xmcTerm.cursorx - 1)); ((XMcTermWidget)self)->xmcTerm.contents[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx] = c; ((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx] = ((XMcTermWidget)self)->xmcTerm.cur_attrib; } else { ((XMcTermWidget)self)->xmcTerm.contents[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx] = c; ((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx] = ((XMcTermWidget)self)->xmcTerm.cur_attrib; } ((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory][0] |= ATTRIB_DIRTY; if (((XMcTermWidget)self)->xmcTerm.cursorx < ((XMcTermWidget)self)->xmcTerm.columns - 1) { ((XMcTermWidget)self)->xmcTerm.cursorx++; } else { /* Margin reached */ ((XMcTermWidget)self)->xmcTerm.do_wrap = True; } ((XMcTermWidget)self)->xmcTerm.last_char = c; /* Save for repeat_char() */ } //#line 1913 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1913 "unix/mcterm.w" static void repeat_char(Widget self,int n) #else //#line 1913 "unix/mcterm.w" static void repeat_char(self,n)Widget self;int n; #endif //#line 1914 "unix/mcterm.w" { for (; n > 0; n--) add_char(self, ((XMcTermWidget)self)->xmcTerm.last_char); } //#line 1923 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1923 "unix/mcterm.w" static void next_tabstop(Widget self) #else //#line 1923 "unix/mcterm.w" static void next_tabstop(self)Widget self; #endif //#line 1924 "unix/mcterm.w" { if (! ((XMcTermWidget)self)->xmcTerm.insert_mode) { ((XMcTermWidget)self)->xmcTerm.cursorx = ((((XMcTermWidget)self)->xmcTerm.cursorx + 8)/8) * 8; } else { int x = ((((XMcTermWidget)self)->xmcTerm.cursorx + 8)/8) * 8; if (x >= ((XMcTermWidget)self)->xmcTerm.columns) x = ((XMcTermWidget)self)->xmcTerm.columns - 1; while (((XMcTermWidget)self)->xmcTerm.cursorx != x) add_char(self, ' '); ((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory][0] |= ATTRIB_DIRTY; } } //#line 1946 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1946 "unix/mcterm.w" static void delete_line(Widget self) #else //#line 1946 "unix/mcterm.w" static void delete_line(self)Widget self; #endif //#line 1947 "unix/mcterm.w" { int i; char *swap_contents; attrib_t *swap_attribs; /* if the cursor is not in the scroll region, do nothing */ if (((XMcTermWidget)self)->xmcTerm.cursory < ((XMcTermWidget)self)->xmcTerm.scroll_top_row || ((XMcTermWidget)self)->xmcTerm.scroll_bot_row < ((XMcTermWidget)self)->xmcTerm.cursory) { return; } ((XMcTermWidget)self)->xmcTerm.do_wrap = False; swap_contents = ((XMcTermWidget)self)->xmcTerm.contents[((XMcTermWidget)self)->xmcTerm.cursory]; swap_attribs = ((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory]; for (i = ((XMcTermWidget)self)->xmcTerm.cursory; i < ((XMcTermWidget)self)->xmcTerm.scroll_bot_row; i++) { ((XMcTermWidget)self)->xmcTerm.contents[i] = ((XMcTermWidget)self)->xmcTerm.contents[i+1]; ((XMcTermWidget)self)->xmcTerm.attribs[i] = ((XMcTermWidget)self)->xmcTerm.attribs[i+1]; ((XMcTermWidget)self)->xmcTerm.attribs[i][0] |= ATTRIB_DIRTY; } ((XMcTermWidget)self)->xmcTerm.contents[((XMcTermWidget)self)->xmcTerm.scroll_bot_row] = swap_contents; ((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.scroll_bot_row] = swap_attribs; memset(&((XMcTermWidget)self)->xmcTerm.contents[((XMcTermWidget)self)->xmcTerm.scroll_bot_row][0], ' ', ((XMcTermWidget)self)->xmcTerm.columns); memset(&((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.scroll_bot_row][0], 0, sizeof(attrib_t)*((XMcTermWidget)self)->xmcTerm.columns); ((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.scroll_bot_row][0] |= ATTRIB_DIRTY; } //#line 1984 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 1984 "unix/mcterm.w" static void insert_line(Widget self) #else //#line 1984 "unix/mcterm.w" static void insert_line(self)Widget self; #endif //#line 1985 "unix/mcterm.w" { int i; char *swap_contents; attrib_t *swap_attribs; /* if the cursor is not in the scroll region, do nothing */ if (((XMcTermWidget)self)->xmcTerm.cursory < ((XMcTermWidget)self)->xmcTerm.scroll_top_row || ((XMcTermWidget)self)->xmcTerm.scroll_bot_row < ((XMcTermWidget)self)->xmcTerm.cursory) { return; } ((XMcTermWidget)self)->xmcTerm.do_wrap = False; swap_contents = ((XMcTermWidget)self)->xmcTerm.contents[((XMcTermWidget)self)->xmcTerm.scroll_bot_row]; swap_attribs = ((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.scroll_bot_row]; for (i = ((XMcTermWidget)self)->xmcTerm.scroll_bot_row; i > ((XMcTermWidget)self)->xmcTerm.cursory; i--) { ((XMcTermWidget)self)->xmcTerm.contents[i] = ((XMcTermWidget)self)->xmcTerm.contents[i-1]; ((XMcTermWidget)self)->xmcTerm.attribs[i] = ((XMcTermWidget)self)->xmcTerm.attribs[i-1]; ((XMcTermWidget)self)->xmcTerm.attribs[i][0] |= ATTRIB_DIRTY; } ((XMcTermWidget)self)->xmcTerm.contents[((XMcTermWidget)self)->xmcTerm.cursory] = swap_contents; ((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory] = swap_attribs; memset(((XMcTermWidget)self)->xmcTerm.contents[((XMcTermWidget)self)->xmcTerm.cursory], ' ', ((XMcTermWidget)self)->xmcTerm.columns); memset(((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory], 0, sizeof(attrib_t)*((XMcTermWidget)self)->xmcTerm.columns); ((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory][0] |= ATTRIB_DIRTY; } //#line 2018 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 2018 "unix/mcterm.w" static void cursor_down(Widget self) #else //#line 2018 "unix/mcterm.w" static void cursor_down(self)Widget self; #endif //#line 2019 "unix/mcterm.w" { ((XMcTermWidget)self)->xmcTerm.do_wrap = False; if (((XMcTermWidget)self)->xmcTerm.cursory == ((XMcTermWidget)self)->xmcTerm.scroll_bot_row) { ((XMcTermWidget)self)->xmcTerm.cursory = ((XMcTermWidget)self)->xmcTerm.scroll_top_row; delete_line(self); ((XMcTermWidget)self)->xmcTerm.cursory = ((XMcTermWidget)self)->xmcTerm.scroll_bot_row; } else if (((XMcTermWidget)self)->xmcTerm.cursory < ((XMcTermWidget)self)->xmcTerm.rows - 1) { ((XMcTermWidget)self)->xmcTerm.cursory++; } } //#line 2034 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 2034 "unix/mcterm.w" static void clear_eol(Widget self) #else //#line 2034 "unix/mcterm.w" static void clear_eol(self)Widget self; #endif //#line 2035 "unix/mcterm.w" { ((XMcTermWidget)self)->xmcTerm.do_wrap = False; memset(&((XMcTermWidget)self)->xmcTerm.contents[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx], ' ', (((XMcTermWidget)self)->xmcTerm.columns - ((XMcTermWidget)self)->xmcTerm.cursorx)); memset(&((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx], 0, sizeof(attrib_t) * (((XMcTermWidget)self)->xmcTerm.columns - ((XMcTermWidget)self)->xmcTerm.cursorx)); ((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory][0] |= ATTRIB_DIRTY; } //#line 2048 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 2048 "unix/mcterm.w" static void clear_eos(Widget self) #else //#line 2048 "unix/mcterm.w" static void clear_eos(self)Widget self; #endif //#line 2049 "unix/mcterm.w" { int i, save_x, save_y; ((XMcTermWidget)self)->xmcTerm.do_wrap = False; clear_eol(self); save_x = ((XMcTermWidget)self)->xmcTerm.cursorx; save_y = ((XMcTermWidget)self)->xmcTerm.cursory; ((XMcTermWidget)self)->xmcTerm.cursorx = 0; for (i = save_y + 1; i < ((XMcTermWidget)self)->xmcTerm.rows; i++) { ((XMcTermWidget)self)->xmcTerm.cursory = i; clear_eol(self); } ((XMcTermWidget)self)->xmcTerm.cursorx = save_x; ((XMcTermWidget)self)->xmcTerm.cursory = save_y; } //#line 2069 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 2069 "unix/mcterm.w" static void delete_char(Widget self) #else //#line 2069 "unix/mcterm.w" static void delete_char(self)Widget self; #endif //#line 2070 "unix/mcterm.w" { ((XMcTermWidget)self)->xmcTerm.do_wrap = False; memmove(&((XMcTermWidget)self)->xmcTerm.contents[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx], &((XMcTermWidget)self)->xmcTerm.contents[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx+1], (((XMcTermWidget)self)->xmcTerm.columns - ((XMcTermWidget)self)->xmcTerm.cursorx - 1)); memmove(&((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx], &((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx+1], sizeof(attrib_t)*(((XMcTermWidget)self)->xmcTerm.columns - ((XMcTermWidget)self)->xmcTerm.cursorx - 1)); ((XMcTermWidget)self)->xmcTerm.contents[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.columns-1] = ' '; ((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.columns-1] = 0; ((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory][0] |= ATTRIB_DIRTY; } //#line 2085 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 2085 "unix/mcterm.w" static void insert_chars(Widget self,int n) #else //#line 2085 "unix/mcterm.w" static void insert_chars(self,n)Widget self;int n; #endif //#line 2086 "unix/mcterm.w" { ((XMcTermWidget)self)->xmcTerm.do_wrap = False; if (n > ((XMcTermWidget)self)->xmcTerm.columns - ((XMcTermWidget)self)->xmcTerm.cursorx) n = ((XMcTermWidget)self)->xmcTerm.columns - ((XMcTermWidget)self)->xmcTerm.cursorx; memmove(&((XMcTermWidget)self)->xmcTerm.contents[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx+n], &((XMcTermWidget)self)->xmcTerm.contents[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx], (((XMcTermWidget)self)->xmcTerm.columns - ((XMcTermWidget)self)->xmcTerm.cursorx - n)); memmove(&((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx+n], &((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx], sizeof(attrib_t)*(((XMcTermWidget)self)->xmcTerm.columns - ((XMcTermWidget)self)->xmcTerm.cursorx - n)); memset(&((XMcTermWidget)self)->xmcTerm.contents[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx], ' ', n); memset(&((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory][((XMcTermWidget)self)->xmcTerm.cursorx], 0, sizeof(attrib_t)*n); ((XMcTermWidget)self)->xmcTerm.attribs[((XMcTermWidget)self)->xmcTerm.cursory][0] |= ATTRIB_DIRTY; } //#line 2101 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 2101 "unix/mcterm.w" static void set_cursortype(Widget self,int type) #else //#line 2101 "unix/mcterm.w" static void set_cursortype(self,type)Widget self;int type; #endif //#line 2102 "unix/mcterm.w" { if (type < XMcTermCursorMin || XMcTermCursorMax < type) return; ((XMcTermWidget)self)->xmcTerm.cursortype = type; } //#line 2113 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 2113 "unix/mcterm.w" static void set_scroll(Widget self,int toprow,int botrow) #else //#line 2113 "unix/mcterm.w" static void set_scroll(self,toprow,botrow)Widget self;int toprow;int botrow; #endif //#line 2114 "unix/mcterm.w" { if (toprow < 0 || botrow < toprow || botrow > ((XMcTermWidget)self)->xmcTerm.rows-1) return; assert(0 <= toprow); assert(toprow <= botrow); assert(botrow <= ((XMcTermWidget)self)->xmcTerm.rows-1); ((XMcTermWidget)self)->xmcTerm.scroll_top_row = toprow; ((XMcTermWidget)self)->xmcTerm.scroll_bot_row = botrow; } //#line 2130 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 2130 "unix/mcterm.w" static void set_attrib(Widget self,int n) #else //#line 2130 "unix/mcterm.w" static void set_attrib(self,n)Widget self;int n; #endif //#line 2131 "unix/mcterm.w" { int i; int val; for (i = 0; i < n; i++) { val = ((XMcTermWidget)self)->xmcTerm.escparm[i]; switch(val) { case 0: ((XMcTermWidget)self)->xmcTerm.cur_attrib = 0; break; case 4: ((XMcTermWidget)self)->xmcTerm.cur_attrib |= ATTRIB_ULINE; break; case 7: /* turn on reverse */ ((XMcTermWidget)self)->xmcTerm.cur_attrib |= ATTRIB_REV; break; case 27: /* turn off reverse */ ((XMcTermWidget)self)->xmcTerm.cur_attrib &= ~ATTRIB_REV; break; case XMcTermForegroundBright: /* turn on bright */ ((XMcTermWidget)self)->xmcTerm.cur_attrib |= ATTRIB_BRIGHT; break; case XMcTermForegroundNormal: /* turn off bright */ ((XMcTermWidget)self)->xmcTerm.cur_attrib &= ~ATTRIB_BRIGHT; break; case XMcTermForegroundBlack: case XMcTermForegroundRed: case XMcTermForegroundGreen: case XMcTermForegroundYellow: case XMcTermForegroundBlue: case XMcTermForegroundMagenta: case XMcTermForegroundCyan: case XMcTermForegroundWhite: case XMcTermForegroundDefault: attrib_set_foreground(&((XMcTermWidget)self)->xmcTerm.cur_attrib, val); break; case XMcTermBackgroundBlack: case XMcTermBackgroundRed: case XMcTermBackgroundGreen: case XMcTermBackgroundYellow: case XMcTermBackgroundBlue: case XMcTermBackgroundMagenta: case XMcTermBackgroundCyan: case XMcTermBackgroundWhite: case XMcTermBackgroundDefault: attrib_set_background(&((XMcTermWidget)self)->xmcTerm.cur_attrib, val); break; } } } //#line 2189 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 2189 "unix/mcterm.w" static void attrib_set_foreground(attrib_t * a,int n) #else //#line 2189 "unix/mcterm.w" static void attrib_set_foreground(a,n)attrib_t * a;int n; #endif //#line 2190 "unix/mcterm.w" { *a &= ~ATTRIB_FOREGROUND_MASK; if (n == XMcTermForegroundDefault) return; *a |= (((n-XMcTermForegroundBlack)+1) << ATTRIB_FOREGROUND_SHIFT); } //#line 2199 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 2199 "unix/mcterm.w" static int attrib_get_foreground(attrib_t a) #else //#line 2199 "unix/mcterm.w" static int attrib_get_foreground(a)attrib_t a; #endif //#line 2200 "unix/mcterm.w" { a &= ATTRIB_FOREGROUND_MASK; if (a == 0) return XMcTermForegroundDefault; return (a>>ATTRIB_FOREGROUND_SHIFT)-1 + XMcTermForegroundBlack; } //#line 2212 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 2212 "unix/mcterm.w" static void attrib_set_background(attrib_t * a,int n) #else //#line 2212 "unix/mcterm.w" static void attrib_set_background(a,n)attrib_t * a;int n; #endif //#line 2213 "unix/mcterm.w" { *a &= ~ATTRIB_BACKGROUND_MASK; if (n == XMcTermBackgroundDefault) return; *a |= (((n-XMcTermBackgroundBlack)+1) << ATTRIB_BACKGROUND_SHIFT); } //#line 2222 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 2222 "unix/mcterm.w" static int attrib_get_background(attrib_t a) #else //#line 2222 "unix/mcterm.w" static int attrib_get_background(a)attrib_t a; #endif //#line 2223 "unix/mcterm.w" { a &= ATTRIB_BACKGROUND_MASK; if (a == 0) return XMcTermBackgroundDefault; return (a>>ATTRIB_BACKGROUND_SHIFT)-1 + XMcTermBackgroundBlack; } //#line 2235 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 2235 "unix/mcterm.w" static void goto_xy(Widget self,int x,int y) #else //#line 2235 "unix/mcterm.w" static void goto_xy(self,x,y)Widget self;int x;int y; #endif //#line 2236 "unix/mcterm.w" { ((XMcTermWidget)self)->xmcTerm.do_wrap = False; ((XMcTermWidget)self)->xmcTerm.cursorx = max(0, min(((XMcTermWidget)self)->xmcTerm.columns - 1, x)); ((XMcTermWidget)self)->xmcTerm.cursory = max(0, min(((XMcTermWidget)self)->xmcTerm.rows - 1, y)); } //#line 2247 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 2247 "unix/mcterm.w" static void find_cell(Widget self,int cx,int cy,int * col,int * row) #else //#line 2247 "unix/mcterm.w" static void find_cell(self,cx,cy,col,row)Widget self;int cx;int cy;int * col;int * row; #endif //#line 2248 "unix/mcterm.w" { int i, j, x, y; for (x = ((XMcTermWidget)self)->xmcTerm.margin + ((XMcTermWidget)self)->xmcTerm.cellwidth, i = 0; i < ((XMcTermWidget)self)->xmcTerm.columns - 1 && x < cx; i++, x += ((XMcTermWidget)self)->xmcTerm.cellwidth) ; for (y = ((XMcTermWidget)self)->xmcTerm.margin + ((XMcTermWidget)self)->xmcTerm.cellheight, j = 0; j < ((XMcTermWidget)self)->xmcTerm.rows - 1 && y < cy; j++, y += ((XMcTermWidget)self)->xmcTerm.cellheight) ; *col = i; *row = j; } //#line 2269 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 2269 "unix/mcterm.w" static void handle_keys(Widget self,XtPointer client_data,XEvent * event,Boolean * cont) #else //#line 2269 "unix/mcterm.w" static void handle_keys(self,client_data,event,cont)Widget self;XtPointer client_data;XEvent * event;Boolean * cont; #endif //#line 2270 "unix/mcterm.w" { assert(event->type == KeyPress); XtCallCallbackList(self, ((XMcTermWidget)self)->xmcTerm.keyCallback, &event->xkey); *cont = False; } //#line 2278 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 2278 "unix/mcterm.w" static void print_geometry(FILE * f,XtWidgetGeometry * g) #else //#line 2278 "unix/mcterm.w" static void print_geometry(f,g)FILE * f;XtWidgetGeometry * g; #endif //#line 2279 "unix/mcterm.w" { fprintf(f, "request_mode:"); if (g->request_mode & CWX) fprintf(f, " CWX"); if (g->request_mode & CWY) fprintf(f, " CWY"); if (g->request_mode & CWWidth) fprintf(f, " CWWidth"); if (g->request_mode & CWHeight) fprintf(f, " CWHeight"); if (g->request_mode & CWBorderWidth) fprintf(f, " CWBorderWidth"); if (g->request_mode & CWSibling) fprintf(f, " CWSibling"); if (g->request_mode & CWStackMode) fprintf(f, " CWStackMode"); fprintf(f, "\n"); if (g->request_mode & CWX) fprintf(f, " CWX = %ld\n", (long) g->x); if (g->request_mode & CWY) fprintf(f, " CWY = %ld\n", (long) g->y); if (g->request_mode & CWWidth) fprintf(f, " CWWidth = %ld\n", (long) g->width); if (g->request_mode & CWHeight) fprintf(f, " CWHeight = %ld\n", (long) g->height); if (g->request_mode & CWBorderWidth) fprintf(f, " CWBorderWidth = %ld\n", (long) g->border_width); if (g->request_mode & CWSibling) fprintf(f, " CWSibling = %ld\n", (long) g->sibling); if (g->request_mode & CWStackMode) fprintf(f, " CWStackMode = %ld\n", (long) g->stack_mode); /* CWX CWY CWWidth CWHeight CWBorderWidth CWSibling CWStackMode */ } //#line 2312 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 2312 "unix/mcterm.w" static void request_resize(Widget self,Dimension new_width,Dimension new_height) #else //#line 2312 "unix/mcterm.w" static void request_resize(self,new_width,new_height)Widget self;Dimension new_width;Dimension new_height; #endif //#line 2313 "unix/mcterm.w" { XtWidgetGeometry request; XtWidgetGeometry compromise_return; XtGeometryResult ans; if (((XMcTermWidget)self)->xmcTerm.debug_set_values) { fprintf(stderr, "set_values A: $width, $height == %ld, %ld\n", (long)((XMcTermWidget)self)->core.width, (long)((XMcTermWidget)self)->core.height); } request.request_mode = CWWidth | CWHeight | XtCWQueryOnly; request.width = new_width; request.height = new_height; ans = XtMakeGeometryRequest(self, &request, &compromise_return); if (ans == XtGeometryNo) { if (((XMcTermWidget)self)->xmcTerm.debug_set_values) { fprintf(stderr, "set_values B: aborting geometry request\n"); } return; } request.request_mode = CWWidth | CWHeight; ans = XtMakeGeometryRequest(self, &request, &compromise_return); if (((XMcTermWidget)self)->xmcTerm.debug_set_values) { fprintf(stderr, "XtMakeResizeRequest(%ld, %ld) -> %ld, %ld, %s\n", (long)request.width, (long)request.height, (long)compromise_return.width, (long)compromise_return.height, ans == XtGeometryYes ? "Yes" : ans == XtGeometryNo ? "No" : ans == XtGeometryAlmost ? "Almost" : "Unknown return value!" ); } switch(ans) { case XtGeometryAlmost: request.width = compromise_return.width; request.height = compromise_return.height; XtMakeGeometryRequest(self, &request, &compromise_return); break; } /* * At this point, $width and $height might have been * changed. */ if (((XMcTermWidget)self)->xmcTerm.debug_set_values) { fprintf(stderr, "set_values B: $width, $height == %ld, %ld\n", (long)((XMcTermWidget)self)->core.width, (long)((XMcTermWidget)self)->core.height); } } static XtResource resources[] = { //#line 38 "unix/mcterm.w" {XtNrows,XtCRows,XtRInt,sizeof(((XMcTermRec*)NULL)->xmcTerm.rows),XtOffsetOf(XMcTermRec,xmcTerm.rows),XtRImmediate,(XtPointer)DEFAULT_ROWS }, //#line 46 "unix/mcterm.w" {XtNcolumns,XtCColumns,XtRInt,sizeof(((XMcTermRec*)NULL)->xmcTerm.columns),XtOffsetOf(XMcTermRec,xmcTerm.columns),XtRImmediate,(XtPointer)DEFAULT_COLUMNS }, //#line 50 "unix/mcterm.w" {XtNfont,XtCFont,XtRFontStruct,sizeof(((XMcTermRec*)NULL)->xmcTerm.font),XtOffsetOf(XMcTermRec,xmcTerm.font),XtRString,(XtPointer)XtDefaultFont }, //#line 55 "unix/mcterm.w" {XtNmargin,XtCMargin,XtRInt,sizeof(((XMcTermRec*)NULL)->xmcTerm.margin),XtOffsetOf(XMcTermRec,xmcTerm.margin),XtRImmediate,(XtPointer)DEFAULT_MARGIN }, //#line 69 "unix/mcterm.w" {XtNbackgroundBlack,XtCBackgroundBlack,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.backgroundBlack),XtOffsetOf(XMcTermRec,xmcTerm.backgroundBlack),XtRString,(XtPointer)"black"}, //#line 70 "unix/mcterm.w" {XtNbackgroundRed,XtCBackgroundRed,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.backgroundRed),XtOffsetOf(XMcTermRec,xmcTerm.backgroundRed),XtRString,(XtPointer)"red4"}, //#line 71 "unix/mcterm.w" {XtNbackgroundGreen,XtCBackgroundGreen,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.backgroundGreen),XtOffsetOf(XMcTermRec,xmcTerm.backgroundGreen),XtRString,(XtPointer)"green4"}, //#line 72 "unix/mcterm.w" {XtNbackgroundYellow,XtCBackgroundYellow,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.backgroundYellow),XtOffsetOf(XMcTermRec,xmcTerm.backgroundYellow),XtRString,(XtPointer)"yellow4"}, //#line 73 "unix/mcterm.w" {XtNbackgroundBlue,XtCBackgroundBlue,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.backgroundBlue),XtOffsetOf(XMcTermRec,xmcTerm.backgroundBlue),XtRString,(XtPointer)"blue4"}, //#line 74 "unix/mcterm.w" {XtNbackgroundMagenta,XtCBackgroundMagenta,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.backgroundMagenta),XtOffsetOf(XMcTermRec,xmcTerm.backgroundMagenta),XtRString,(XtPointer)"magenta4"}, //#line 75 "unix/mcterm.w" {XtNbackgroundCyan,XtCBackgroundCyan,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.backgroundCyan),XtOffsetOf(XMcTermRec,xmcTerm.backgroundCyan),XtRString,(XtPointer)"cyan4"}, //#line 76 "unix/mcterm.w" {XtNbackgroundWhite,XtCBackgroundWhite,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.backgroundWhite),XtOffsetOf(XMcTermRec,xmcTerm.backgroundWhite),XtRString,(XtPointer)"grey80"}, //#line 78 "unix/mcterm.w" {XtNforegroundNormalBlack,XtCForegroundNormalBlack,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foregroundNormalBlack),XtOffsetOf(XMcTermRec,xmcTerm.foregroundNormalBlack),XtRString,(XtPointer)"black"}, //#line 79 "unix/mcterm.w" {XtNforegroundNormalRed,XtCForegroundNormalRed,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foregroundNormalRed),XtOffsetOf(XMcTermRec,xmcTerm.foregroundNormalRed),XtRString,(XtPointer)"red4"}, //#line 80 "unix/mcterm.w" {XtNforegroundNormalGreen,XtCForegroundNormalGreen,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foregroundNormalGreen),XtOffsetOf(XMcTermRec,xmcTerm.foregroundNormalGreen),XtRString,(XtPointer)"green4"}, //#line 81 "unix/mcterm.w" {XtNforegroundNormalYellow,XtCForegroundNormalYellow,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foregroundNormalYellow),XtOffsetOf(XMcTermRec,xmcTerm.foregroundNormalYellow),XtRString,(XtPointer)"yellow4"}, //#line 82 "unix/mcterm.w" {XtNforegroundNormalBlue,XtCForegroundNormalBlue,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foregroundNormalBlue),XtOffsetOf(XMcTermRec,xmcTerm.foregroundNormalBlue),XtRString,(XtPointer)"blue4"}, //#line 83 "unix/mcterm.w" {XtNforegroundNormalMagenta,XtCForegroundNormalMagenta,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foregroundNormalMagenta),XtOffsetOf(XMcTermRec,xmcTerm.foregroundNormalMagenta),XtRString,(XtPointer)"magenta4"}, //#line 84 "unix/mcterm.w" {XtNforegroundNormalCyan,XtCForegroundNormalCyan,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foregroundNormalCyan),XtOffsetOf(XMcTermRec,xmcTerm.foregroundNormalCyan),XtRString,(XtPointer)"cyan4"}, //#line 85 "unix/mcterm.w" {XtNforegroundNormalWhite,XtCForegroundNormalWhite,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foregroundNormalWhite),XtOffsetOf(XMcTermRec,xmcTerm.foregroundNormalWhite),XtRString,(XtPointer)"grey80"}, //#line 87 "unix/mcterm.w" {XtNforegroundBrightBlack,XtCForegroundBrightBlack,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foregroundBrightBlack),XtOffsetOf(XMcTermRec,xmcTerm.foregroundBrightBlack),XtRString,(XtPointer)"grey50"}, //#line 88 "unix/mcterm.w" {XtNforegroundBrightRed,XtCForegroundBrightRed,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foregroundBrightRed),XtOffsetOf(XMcTermRec,xmcTerm.foregroundBrightRed),XtRString,(XtPointer)"red"}, //#line 89 "unix/mcterm.w" {XtNforegroundBrightGreen,XtCForegroundBrightGreen,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foregroundBrightGreen),XtOffsetOf(XMcTermRec,xmcTerm.foregroundBrightGreen),XtRString,(XtPointer)"green"}, //#line 90 "unix/mcterm.w" {XtNforegroundBrightYellow,XtCForegroundBrightYellow,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foregroundBrightYellow),XtOffsetOf(XMcTermRec,xmcTerm.foregroundBrightYellow),XtRString,(XtPointer)"yellow"}, //#line 91 "unix/mcterm.w" {XtNforegroundBrightBlue,XtCForegroundBrightBlue,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foregroundBrightBlue),XtOffsetOf(XMcTermRec,xmcTerm.foregroundBrightBlue),XtRString,(XtPointer)"blue"}, //#line 92 "unix/mcterm.w" {XtNforegroundBrightMagenta,XtCForegroundBrightMagenta,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foregroundBrightMagenta),XtOffsetOf(XMcTermRec,xmcTerm.foregroundBrightMagenta),XtRString,(XtPointer)"magenta"}, //#line 93 "unix/mcterm.w" {XtNforegroundBrightCyan,XtCForegroundBrightCyan,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foregroundBrightCyan),XtOffsetOf(XMcTermRec,xmcTerm.foregroundBrightCyan),XtRString,(XtPointer)"cyan"}, //#line 94 "unix/mcterm.w" {XtNforegroundBrightWhite,XtCForegroundBrightWhite,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foregroundBrightWhite),XtOffsetOf(XMcTermRec,xmcTerm.foregroundBrightWhite),XtRString,(XtPointer)"white"}, //#line 96 "unix/mcterm.w" {XtNforeground,XtCForeground,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foreground),XtOffsetOf(XMcTermRec,xmcTerm.foreground),XtRString,(XtPointer)XtDefaultForeground }, //#line 97 "unix/mcterm.w" {XtNforegroundBright,XtCForegroundBright,XtRPixel,sizeof(((XMcTermRec*)NULL)->xmcTerm.foregroundBright),XtOffsetOf(XMcTermRec,xmcTerm.foregroundBright),XtRString,(XtPointer)XtDefaultForeground }, //#line 103 "unix/mcterm.w" {XtNkeyCallback,XtCKeyCallback,XtRCallback,sizeof(((XMcTermRec*)NULL)->xmcTerm.keyCallback),XtOffsetOf(XMcTermRec,xmcTerm.keyCallback),XtRImmediate,(XtPointer)NULL }, //#line 109 "unix/mcterm.w" {XtNmouseCallback,XtCMouseCallback,XtRCallback,sizeof(((XMcTermRec*)NULL)->xmcTerm.mouseCallback),XtOffsetOf(XMcTermRec,xmcTerm.mouseCallback),XtRImmediate,(XtPointer)NULL }, //#line 115 "unix/mcterm.w" {XtNpasteCallback,XtCPasteCallback,XtRCallback,sizeof(((XMcTermRec*)NULL)->xmcTerm.pasteCallback),XtOffsetOf(XMcTermRec,xmcTerm.pasteCallback),XtRImmediate,(XtPointer)NULL }, //#line 123 "unix/mcterm.w" {XtNresizeCallback,XtCResizeCallback,XtRCallback,sizeof(((XMcTermRec*)NULL)->xmcTerm.resizeCallback),XtOffsetOf(XMcTermRec,xmcTerm.resizeCallback),XtRImmediate,(XtPointer)NULL }, //#line 127 "unix/mcterm.w" {XtNdebug_query_geometry,XtCDebug_query_geometry,XtRBool,sizeof(((XMcTermRec*)NULL)->xmcTerm.debug_query_geometry),XtOffsetOf(XMcTermRec,xmcTerm.debug_query_geometry),XtRImmediate,(XtPointer)False }, //#line 128 "unix/mcterm.w" {XtNdebug_set_values,XtCDebug_set_values,XtRBool,sizeof(((XMcTermRec*)NULL)->xmcTerm.debug_set_values),XtOffsetOf(XMcTermRec,xmcTerm.debug_set_values),XtRImmediate,(XtPointer)False }, //#line 129 "unix/mcterm.w" {XtNdebug_resize,XtCDebug_resize,XtRBool,sizeof(((XMcTermRec*)NULL)->xmcTerm.debug_resize),XtOffsetOf(XMcTermRec,xmcTerm.debug_resize),XtRImmediate,(XtPointer)False }, //#line 130 "unix/mcterm.w" {XtNdebug_set_resize_increments,XtCDebug_set_resize_increments,XtRBool,sizeof(((XMcTermRec*)NULL)->xmcTerm.debug_set_resize_increments),XtOffsetOf(XMcTermRec,xmcTerm.debug_set_resize_increments),XtRImmediate,(XtPointer)False }, }; XMcTermClassRec xmcTermClassRec = { { /* core_class part */ /* superclass */ (WidgetClass) &coreClassRec, /* class_name */ "XMcTerm", /* widget_size */ sizeof(XMcTermRec), /* class_initialize */ NULL, /* class_part_initialize*/ _resolve_inheritance, /* class_inited */ FALSE, /* initialize */ initialize, /* initialize_hook */ NULL, /* realize */ realize, /* actions */ actionsList, /* num_actions */ 4, /* resources */ resources, /* num_resources */ 38, /* xrm_class */ NULLQUARK, /* compres_motion */ True , /* compress_exposure */ XtExposeCompressMultiple , /* compress_enterleave */ True , /* visible_interest */ False , /* destroy */ destroy, /* resize */ resize, /* expose */ expose, /* set_values */ set_values, /* set_values_hook */ NULL, /* set_values_almost */ XtInheritSetValuesAlmost, /* get_values+hook */ NULL, /* accept_focus */ XtInheritAcceptFocus, /* version */ XtVersion, /* callback_private */ NULL, /* tm_table */ defaultTranslations, /* query_geometry */ query_geometry, /* display_acceleator */ XtInheritDisplayAccelerator, /* extension */ NULL }, { /* XMcTerm_class part */ write, }, }; WidgetClass xmcTermWidgetClass = (WidgetClass) &xmcTermClassRec; /*ARGSUSED*/ //#line 938 "unix/mcterm.w" static void start_selection(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params; { find_cell(self, event->xbutton.x, event->xbutton.y, &((XMcTermWidget)self)->xmcTerm.start_x, &((XMcTermWidget)self)->xmcTerm.start_y); ((XMcTermWidget)self)->xmcTerm.end_x = ((XMcTermWidget)self)->xmcTerm.start_x; ((XMcTermWidget)self)->xmcTerm.end_y = ((XMcTermWidget)self)->xmcTerm.start_y; ((XMcTermWidget)self)->xmcTerm.drag_started = False; /* No selection yet */ } /*ARGSUSED*/ //#line 955 "unix/mcterm.w" static void extend_selection(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params; { int i, j, sx, sy, ex, ey, x, y; ((XMcTermWidget)self)->xmcTerm.drag_started = True; find_cell(self, event->xbutton.x, event->xbutton.y, &x, &y); if (((XMcTermWidget)self)->xmcTerm.start_y < y || (((XMcTermWidget)self)->xmcTerm.start_y == y && ((XMcTermWidget)self)->xmcTerm.start_x < x)) { sy = ((XMcTermWidget)self)->xmcTerm.start_y; ey = y; sx = ((XMcTermWidget)self)->xmcTerm.start_x; ex = x; } else { /* Swap start and end */ sy = y; ey = ((XMcTermWidget)self)->xmcTerm.start_y; sx = x; ex = ((XMcTermWidget)self)->xmcTerm.start_x; } /* Draw the lines that the mouse passed over since last event */ for (i = min(y, ((XMcTermWidget)self)->xmcTerm.end_y); i <= max(y, ((XMcTermWidget)self)->xmcTerm.end_y); i++) { /* Toggle REV attribute on cells within selected region */ if (i == sy && i == ey) for (j = sx; j <= ex; j++) ((XMcTermWidget)self)->xmcTerm.attribs[i][j] ^= ATTRIB_REV; else if (i == sy) for (j = sx; j < ((XMcTermWidget)self)->xmcTerm.columns; j++) ((XMcTermWidget)self)->xmcTerm.attribs[i][j] ^= ATTRIB_REV; else if (i == ey) for (j = 0; j < ex; j++) ((XMcTermWidget)self)->xmcTerm.attribs[i][j] ^= ATTRIB_REV; else if (sy < i && i < ey) for (j = 0; j < ((XMcTermWidget)self)->xmcTerm.columns; j++) ((XMcTermWidget)self)->xmcTerm.attribs[i][j] ^= ATTRIB_REV; draw_line(self, i, 0, ((XMcTermWidget)self)->xmcTerm.columns); /* Draw the line */ /* Toggle REV attribute on cells in region again */ if (i == sy && i == ey) for (j = sx; j <= ex; j++) ((XMcTermWidget)self)->xmcTerm.attribs[i][j] ^= ATTRIB_REV; else if (i == sy) for (j = sx; j < ((XMcTermWidget)self)->xmcTerm.columns; j++) ((XMcTermWidget)self)->xmcTerm.attribs[i][j] ^= ATTRIB_REV; else if (i == ey) for (j = 0; j < ex; j++) ((XMcTermWidget)self)->xmcTerm.attribs[i][j] ^= ATTRIB_REV; else if (sy < i && i < ey) for (j = 0; j < ((XMcTermWidget)self)->xmcTerm.columns; j++) ((XMcTermWidget)self)->xmcTerm.attribs[i][j] ^= ATTRIB_REV; } ((XMcTermWidget)self)->xmcTerm.end_x = x; ((XMcTermWidget)self)->xmcTerm.end_y = y; } /*ARGSUSED*/ //#line 1016 "unix/mcterm.w" static void end_selection(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params; { int sx, sy, ex, ey, k, i, j; if (! ((XMcTermWidget)self)->xmcTerm.drag_started) return; /* No movement since BtnDown */ if (((XMcTermWidget)self)->xmcTerm.start_y < ((XMcTermWidget)self)->xmcTerm.end_y || (((XMcTermWidget)self)->xmcTerm.start_y == ((XMcTermWidget)self)->xmcTerm.end_y && ((XMcTermWidget)self)->xmcTerm.start_x < ((XMcTermWidget)self)->xmcTerm.end_x)) { sy = ((XMcTermWidget)self)->xmcTerm.start_y; ey = ((XMcTermWidget)self)->xmcTerm.end_y; sx = ((XMcTermWidget)self)->xmcTerm.start_x; ex = ((XMcTermWidget)self)->xmcTerm.end_x; } else { /* Swap start & end */ sy = ((XMcTermWidget)self)->xmcTerm.end_y; ey = ((XMcTermWidget)self)->xmcTerm.start_y; sx = ((XMcTermWidget)self)->xmcTerm.end_x; ex = ((XMcTermWidget)self)->xmcTerm.start_x; } /* Unhighlight the selection */ if (sy == ey) { draw_line(self, sy, sx, ex + 1); } else { draw_line(self, sy, sx, ((XMcTermWidget)self)->xmcTerm.columns); /* First (partial) line */ for (i = sy + 1; i <= ey - 1; i++) /* Middle lines */ draw_line(self, i, 0, ((XMcTermWidget)self)->xmcTerm.columns); draw_line(self, ey, 0, ex + 1); /* Last (partial) line */ } /* If MCPASTE=NONE, do not copy to buffer */ if (((XMcTermWidget)self)->xmcTerm.paste_mode == 0) { mct_debug(self, "end_selection(): MCPASTE: NONE"); return; } /* Copy selection to buffer */ if (sy == ey) { ((XMcTermWidget)self)->xmcTerm.selection = XtMalloc(ex - sx + 2); for (k = 0, j = sx; j <= ex; k++, j++) ((XMcTermWidget)self)->xmcTerm.selection[k] = ((XMcTermWidget)self)->xmcTerm.contents[sy][j]; ((XMcTermWidget)self)->xmcTerm.selection[k] = '\0'; ((XMcTermWidget)self)->xmcTerm.selection_len = k; } else { ((XMcTermWidget)self)->xmcTerm.selection = XtMalloc(((XMcTermWidget)self)->xmcTerm.columns - sx + 1 + (ey - sy - 1) * (((XMcTermWidget)self)->xmcTerm.columns + 1) + ex + 3); k = 0; for (j = sx; j < ((XMcTermWidget)self)->xmcTerm.columns; j++, k++) ((XMcTermWidget)self)->xmcTerm.selection[k] = ((XMcTermWidget)self)->xmcTerm.contents[sy][j]; ((XMcTermWidget)self)->xmcTerm.selection[k++] = '\n'; for (i = sy + 1; i <= ey - 1; i++) { for (j = 0; j < ((XMcTermWidget)self)->xmcTerm.columns; j++, k++) ((XMcTermWidget)self)->xmcTerm.selection[k] = ((XMcTermWidget)self)->xmcTerm.contents[i][j]; ((XMcTermWidget)self)->xmcTerm.selection[k++] = '\n'; } for (j = 0; j <= ex; j++, k++) ((XMcTermWidget)self)->xmcTerm.selection[k] = ((XMcTermWidget)self)->xmcTerm.contents[ey][j]; ((XMcTermWidget)self)->xmcTerm.selection[k] = '\0'; ((XMcTermWidget)self)->xmcTerm.selection_len = k; } /* Copy to our local string */ mct_debug(self, "end_selection(): selection:"); mct_debug(self, ((XMcTermWidget)self)->xmcTerm.selection); if (((XMcTermWidget)self)->xmcTerm.paste_string == NULL) { mct_debug(self, "end_selection(): XtMalloc paste_string"); ((XMcTermWidget)self)->xmcTerm.paste_string = XtMalloc(1024); } for (j = 0; j < k; j++) { ((XMcTermWidget)self)->xmcTerm.paste_string[j] = ((XMcTermWidget)self)->xmcTerm.selection[j]; } // printf("Setting %d to null\n", k); ((XMcTermWidget)self)->xmcTerm.paste_string[k] = '\0'; mct_debug(self, "end_selection(): Made local copy:"); mct_debug(self, ((XMcTermWidget)self)->xmcTerm.paste_string); /* Now ask the X server for ownership of the selection */ if (XtOwnSelection(self, XA_PRIMARY, event->xbutton.time, convert_proc, lose_proc, NULL) == False) XtAppWarning(XtWidgetToApplicationContext(self), "Failed to become selection owner"); if (((XMcTermWidget)self)->xmcTerm.paste_mode != 0) { ((XMcTermWidget)self)->xmcTerm.paste_ok = True; ((XMcTermWidget)self)->xmcTerm.paste_lastfree = NULL; mct_debug(self, "end_selection(): paste_ok: True"); } else { mct_debug(self, "end_selection()"); } } /*ARGSUSED*/ //#line 1079 "unix/mcterm.w" static void paste_selection(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params; { /* Examine paste_mode */ if (((XMcTermWidget)self)->xmcTerm.paste_mode == 0) { mct_debug(self, "paste_selection(): MCPASTE: NONE"); return; } if (((XMcTermWidget)self)->xmcTerm.paste_mode == 1) { if (! ((XMcTermWidget)self)->xmcTerm.paste_ok) { mct_debug(self, "paste_selection(): MCPASTE: ONE, !paste_ok"); return; } mct_debug(self, "paste_selection(): MCPASTE: ONE, paste_ok"); } XtGetSelectionValue(self, XA_PRIMARY, XA_STRING, paste_callback, NULL, event->xbutton.time); /* If MCPASTE=ONE, disallow future pastes */ if (((XMcTermWidget)self)->xmcTerm.paste_mode == 1) { ((XMcTermWidget)self)->xmcTerm.paste_ok = False; mct_debug(self, "paste_selection(): paste_ok: False"); } } /*DEBUG*/ static void mct_debug(self,str_debug)Widget self;char*str_debug; { if (!(((XMcTermWidget)self)->xmcTerm.paste_debug)) { return; } printf("DEBUG [%d]: %s\n", strlen(str_debug), str_debug); } static void _resolve_inheritance(class) WidgetClass class; { XMcTermWidgetClass c = (XMcTermWidgetClass) class; XMcTermWidgetClass super; if (class == xmcTermWidgetClass) return; super = (XMcTermWidgetClass)class->core_class.superclass; if (c->xmcTerm_class.write == XtInherit_write) c->xmcTerm_class.write = super->xmcTerm_class.write; } //#line 375 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 375 "unix/mcterm.w" static void initialize(Widget request,Widget self,ArgList args,Cardinal * num_args) #else //#line 375 "unix/mcterm.w" static void initialize(request,self,args,num_args)Widget request;Widget self;ArgList args;Cardinal * num_args; #endif //#line 376 "unix/mcterm.w" { compute_cell_size(self); set_resize_increments(self); if (((XMcTermWidget)self)->xmcTerm.columns < 1) ((XMcTermWidget)self)->xmcTerm.columns = 1; if (((XMcTermWidget)self)->xmcTerm.rows < 1) ((XMcTermWidget)self)->xmcTerm.rows = 1; ((XMcTermWidget)self)->core.width = 2 * ((XMcTermWidget)self)->xmcTerm.margin + ((XMcTermWidget)self)->xmcTerm.columns * ((XMcTermWidget)self)->xmcTerm.cellwidth; ((XMcTermWidget)self)->core.height = 2 * ((XMcTermWidget)self)->xmcTerm.margin + ((XMcTermWidget)self)->xmcTerm.rows * ((XMcTermWidget)self)->xmcTerm.cellheight; ((XMcTermWidget)self)->xmcTerm.allocated_columns = ((XMcTermWidget)self)->xmcTerm.allocated_rows = 0; ((XMcTermWidget)self)->xmcTerm.contents = NULL; ((XMcTermWidget)self)->xmcTerm.attribs = NULL; allocate_contents(self); XtAddEventHandler(self, StructureNotifyMask, False, map_handler, NULL); XtInsertEventHandler(self, KeyPressMask, False, handle_keys, NULL, XtListHead); XtInsertEventHandler(self, ButtonPressMask, False, mouse_press_handler, NULL, XtListHead); ((XMcTermWidget)self)->xmcTerm.defgc = ((XMcTermWidget)self)->xmcTerm.revgc = ((XMcTermWidget)self)->xmcTerm.cursorgc = NULL; ((XMcTermWidget)self)->xmcTerm.savedx = ((XMcTermWidget)self)->xmcTerm.savedy = ((XMcTermWidget)self)->xmcTerm.cursorx = ((XMcTermWidget)self)->xmcTerm.cursory = 0; ((XMcTermWidget)self)->xmcTerm.cursor_on = False; ((XMcTermWidget)self)->xmcTerm.do_wrap = False; ((XMcTermWidget)self)->xmcTerm.cursortype = XMcTermCursorFullSolid; ((XMcTermWidget)self)->xmcTerm.cur_attrib = 0; ((XMcTermWidget)self)->xmcTerm.insert_mode = False; ((XMcTermWidget)self)->xmcTerm.last_char = ' '; ((XMcTermWidget)self)->xmcTerm.state = Init; ((XMcTermWidget)self)->xmcTerm.start_x = 0; ((XMcTermWidget)self)->xmcTerm.start_y = 0; ((XMcTermWidget)self)->xmcTerm.end_x = 0; ((XMcTermWidget)self)->xmcTerm.end_y = 0; ((XMcTermWidget)self)->xmcTerm.selection = NULL; ((XMcTermWidget)self)->xmcTerm.selection_len = 0; ((XMcTermWidget)self)->xmcTerm.drag_started = False; ((XMcTermWidget)self)->xmcTerm.mcpaste_env = getenv("MCPASTE"); ((XMcTermWidget)self)->xmcTerm.mcpastef_env = getenv("MCPASTEF"); ((XMcTermWidget)self)->xmcTerm.mcpasted_env = getenv("MCPASTED"); ((XMcTermWidget)self)->xmcTerm.paste_mode = 2; ((XMcTermWidget)self)->xmcTerm.paste_string = NULL; ((XMcTermWidget)self)->xmcTerm.paste_free = True; ((XMcTermWidget)self)->xmcTerm.paste_debug = False; ((XMcTermWidget)self)->xmcTerm.paste_ok = True; ((XMcTermWidget)self)->xmcTerm.paste_lastfree = NULL; if (((XMcTermWidget)self)->xmcTerm.mcpasted_env != NULL) { if (strcmp(((XMcTermWidget)self)->xmcTerm.mcpasted_env, "DEBUG") == 0) { ((XMcTermWidget)self)->xmcTerm.paste_debug = True; mct_debug(self, "initialize(): MCPASTED: DEBUG"); } } if (((XMcTermWidget)self)->xmcTerm.mcpastef_env != NULL) { if (strcmp(((XMcTermWidget)self)->xmcTerm.mcpastef_env, "NOFREE") == 0) { ((XMcTermWidget)self)->xmcTerm.paste_free = False; mct_debug(self, "initialize(): MCPASTEP: NOFREE"); } } if (((XMcTermWidget)self)->xmcTerm.mcpaste_env != NULL) { if (strcmp(((XMcTermWidget)self)->xmcTerm.mcpaste_env, "NONE") == 0) { ((XMcTermWidget)self)->xmcTerm.paste_mode = 0; ((XMcTermWidget)self)->xmcTerm.paste_ok = False; mct_debug(self, "initialize(): MCPASTE: NONE"); } else if (strcmp(((XMcTermWidget)self)->xmcTerm.mcpaste_env, "ONE") == 0) { ((XMcTermWidget)self)->xmcTerm.paste_mode = 1; ((XMcTermWidget)self)->xmcTerm.paste_ok = True; mct_debug(self, "initialize(): MCPASTE: ONE"); } else if (strcmp(((XMcTermWidget)self)->xmcTerm.mcpaste_env, "BROKEN") == 0) { ((XMcTermWidget)self)->xmcTerm.paste_mode = 2; ((XMcTermWidget)self)->xmcTerm.paste_ok = True; mct_debug(self, "initialize(): MCPASTE: BROKEN"); } } } //#line 425 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 425 "unix/mcterm.w" static void realize(Widget self,XtValueMask * mask,XSetWindowAttributes * attributes) #else //#line 425 "unix/mcterm.w" static void realize(self,mask,attributes)Widget self;XtValueMask * mask;XSetWindowAttributes * attributes; #endif //#line 426 "unix/mcterm.w" { coreClassRec.core_class.realize(self, mask, attributes); make_gc(self); } //#line 438 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 438 "unix/mcterm.w" static Boolean set_values(Widget old,Widget request,Widget self,ArgList args,Cardinal * num_args) #else //#line 438 "unix/mcterm.w" static Boolean set_values(old,request,self,args,num_args)Widget old;Widget request;Widget self;ArgList args;Cardinal * num_args; #endif //#line 439 "unix/mcterm.w" { Bool redraw = False; Bool need_gc = False; Dimension new_width = ((XMcTermWidget)self)->core.width; Dimension new_height = ((XMcTermWidget)self)->core.height; if (((XMcTermWidget)self)->xmcTerm.font != ((XMcTermWidget)old)->xmcTerm.font) { compute_cell_size(self); set_resize_increments(self); need_gc = True; } if (((XMcTermWidget)self)->xmcTerm.foreground != ((XMcTermWidget)old)->xmcTerm.foreground || ((XMcTermWidget)self)->xmcTerm.foregroundBright != ((XMcTermWidget)old)->xmcTerm.foregroundBright || ((XMcTermWidget)self)->core.background_pixel != ((XMcTermWidget)old)->core.background_pixel || ((XMcTermWidget)self)->xmcTerm.foregroundNormalBlack != ((XMcTermWidget)old)->xmcTerm.foregroundNormalBlack || ((XMcTermWidget)self)->xmcTerm.foregroundNormalRed != ((XMcTermWidget)old)->xmcTerm.foregroundNormalRed || ((XMcTermWidget)self)->xmcTerm.foregroundNormalGreen != ((XMcTermWidget)old)->xmcTerm.foregroundNormalGreen || ((XMcTermWidget)self)->xmcTerm.foregroundNormalYellow != ((XMcTermWidget)old)->xmcTerm.foregroundNormalYellow || ((XMcTermWidget)self)->xmcTerm.foregroundNormalBlue != ((XMcTermWidget)old)->xmcTerm.foregroundNormalBlue || ((XMcTermWidget)self)->xmcTerm.foregroundNormalMagenta != ((XMcTermWidget)old)->xmcTerm.foregroundNormalMagenta || ((XMcTermWidget)self)->xmcTerm.foregroundNormalCyan != ((XMcTermWidget)old)->xmcTerm.foregroundNormalCyan || ((XMcTermWidget)self)->xmcTerm.foregroundNormalWhite != ((XMcTermWidget)old)->xmcTerm.foregroundNormalWhite || ((XMcTermWidget)self)->xmcTerm.foregroundBrightBlack != ((XMcTermWidget)old)->xmcTerm.foregroundBrightBlack || ((XMcTermWidget)self)->xmcTerm.foregroundBrightRed != ((XMcTermWidget)old)->xmcTerm.foregroundBrightRed || ((XMcTermWidget)self)->xmcTerm.foregroundBrightGreen != ((XMcTermWidget)old)->xmcTerm.foregroundBrightGreen || ((XMcTermWidget)self)->xmcTerm.foregroundBrightYellow != ((XMcTermWidget)old)->xmcTerm.foregroundBrightYellow || ((XMcTermWidget)self)->xmcTerm.foregroundBrightBlue != ((XMcTermWidget)old)->xmcTerm.foregroundBrightBlue || ((XMcTermWidget)self)->xmcTerm.foregroundBrightMagenta != ((XMcTermWidget)old)->xmcTerm.foregroundBrightMagenta || ((XMcTermWidget)self)->xmcTerm.foregroundBrightCyan != ((XMcTermWidget)old)->xmcTerm.foregroundBrightCyan || ((XMcTermWidget)self)->xmcTerm.foregroundBrightWhite != ((XMcTermWidget)old)->xmcTerm.foregroundBrightWhite || ((XMcTermWidget)self)->xmcTerm.backgroundBlack != ((XMcTermWidget)old)->xmcTerm.backgroundBlack || ((XMcTermWidget)self)->xmcTerm.backgroundRed != ((XMcTermWidget)old)->xmcTerm.backgroundRed || ((XMcTermWidget)self)->xmcTerm.backgroundGreen != ((XMcTermWidget)old)->xmcTerm.backgroundGreen || ((XMcTermWidget)self)->xmcTerm.backgroundYellow != ((XMcTermWidget)old)->xmcTerm.backgroundYellow || ((XMcTermWidget)self)->xmcTerm.backgroundBlue != ((XMcTermWidget)old)->xmcTerm.backgroundBlue || ((XMcTermWidget)self)->xmcTerm.backgroundMagenta != ((XMcTermWidget)old)->xmcTerm.backgroundMagenta || ((XMcTermWidget)self)->xmcTerm.backgroundCyan != ((XMcTermWidget)old)->xmcTerm.backgroundCyan || ((XMcTermWidget)self)->xmcTerm.backgroundWhite != ((XMcTermWidget)old)->xmcTerm.backgroundWhite) { need_gc = True; } if (((XMcTermWidget)self)->xmcTerm.columns < 1) ((XMcTermWidget)self)->xmcTerm.columns = 1; /* Silently increase */ if (((XMcTermWidget)self)->xmcTerm.rows < 1) ((XMcTermWidget)self)->xmcTerm.rows = 1; /* * If the width did not change, but the columns or margin or cellwidth * did, recompute the width. */ if (((XMcTermWidget)self)->core.width == ((XMcTermWidget)old)->core.width) { if (((XMcTermWidget)self)->xmcTerm.columns != ((XMcTermWidget)old)->xmcTerm.columns || ((XMcTermWidget)self)->xmcTerm.margin != ((XMcTermWidget)old)->xmcTerm.margin || ((XMcTermWidget)self)->xmcTerm.cellwidth != ((XMcTermWidget)old)->xmcTerm.cellwidth) { new_width = 2 * ((XMcTermWidget)self)->xmcTerm.margin + ((XMcTermWidget)self)->xmcTerm.columns * ((XMcTermWidget)self)->xmcTerm.cellwidth; } } /* * If the height did not change, but the rows or margin or cellheight * did, recompute the height. */ if (((XMcTermWidget)self)->core.height == ((XMcTermWidget)old)->core.height) { if (((XMcTermWidget)self)->xmcTerm.rows != ((XMcTermWidget)old)->xmcTerm.rows || ((XMcTermWidget)self)->xmcTerm.margin != ((XMcTermWidget)old)->xmcTerm.margin || ((XMcTermWidget)self)->xmcTerm.cellheight != ((XMcTermWidget)old)->xmcTerm.cellheight) { new_height = 2 * ((XMcTermWidget)self)->xmcTerm.margin + ((XMcTermWidget)self)->xmcTerm.rows * ((XMcTermWidget)self)->xmcTerm.cellheight; } } /* * If we want to change our own size, try to do it. */ if (new_width != ((XMcTermWidget)self)->core.width || new_height != ((XMcTermWidget)self)->core.height) { request_resize(self, new_width, new_height); } if (need_gc) { make_gc(self); redraw = True; } /* * Now make sure that $rows and $columns are in sync with * our current $width and $height. */ synchronize_dims(self); clip_gcs(self); return redraw; } //#line 547 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 547 "unix/mcterm.w" static XtGeometryResult query_geometry(Widget self,XtWidgetGeometry * request,XtWidgetGeometry * reply) #else //#line 547 "unix/mcterm.w" static XtGeometryResult query_geometry(self,request,reply)Widget self;XtWidgetGeometry * request;XtWidgetGeometry * reply; #endif //#line 548 "unix/mcterm.w" { XtGeometryMask whmask = CWWidth | CWHeight; /* Compute our preferred geometry */ reply->request_mode = whmask; reply->width = 2 * ((XMcTermWidget)self)->xmcTerm.margin + ((XMcTermWidget)self)->xmcTerm.columns * ((XMcTermWidget)self)->xmcTerm.cellwidth; reply->height = 2 * ((XMcTermWidget)self)->xmcTerm.margin + ((XMcTermWidget)self)->xmcTerm.rows * ((XMcTermWidget)self)->xmcTerm.cellheight; if (((XMcTermWidget)self)->xmcTerm.debug_query_geometry) { fprintf(stderr, "query_geometry:\n"); fprintf(stderr, "requested geometry:"); print_geometry(stderr, request); fprintf(stderr, "preferred geometry:"); print_geometry(stderr, request); } /* * If the proposed geometry is acceptable without * modification, return XtGeometryYes. */ if (((request->request_mode & whmask) == whmask) && request->width == reply->width && request->height == reply->height) { if (((XMcTermWidget)self)->xmcTerm.debug_query_geometry) { fprintf(stderr, "query_geometry: returning XtGeometryYes\n"); } return XtGeometryYes; } /* * If the proposed geometry is the same as the current * geometry, return XtGeometryNo, which indicates that * no change should be made. */ if (((XMcTermWidget)self)->core.width == reply->width && ((XMcTermWidget)self)->core.height == reply->height) { if (((XMcTermWidget)self)->xmcTerm.debug_query_geometry) { fprintf(stderr, "query_geometry: returning XtGeometryNo\n"); } return XtGeometryNo; } /* * If the proposed geometry is not acceptable, store * the suggested modifications in the reply structure * and return XtGeometryAlmost. */ if (((XMcTermWidget)self)->xmcTerm.debug_query_geometry) { fprintf(stderr, "query_geometry: returning XtGeometryAlmost\n"); } return XtGeometryAlmost; } //#line 617 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 617 "unix/mcterm.w" static void resize(Widget self) #else //#line 617 "unix/mcterm.w" static void resize(self)Widget self; #endif //#line 618 "unix/mcterm.w" { if (((XMcTermWidget)self)->xmcTerm.debug_resize) { fprintf(stderr, "resize A: $width, $height, $rows, $columns == %ld, %ld, %ld, %ld\n", (long)((XMcTermWidget)self)->core.width, (long)((XMcTermWidget)self)->core.height, (long)((XMcTermWidget)self)->xmcTerm.rows, (long)((XMcTermWidget)self)->xmcTerm.columns); } synchronize_dims(self); clip_gcs(self); if (((XMcTermWidget)self)->xmcTerm.debug_resize) { fprintf(stderr, "resize B: $width, $height, $rows, $columns == %ld, %ld, %ld, %ld\n", (long)((XMcTermWidget)self)->core.width, (long)((XMcTermWidget)self)->core.height, (long)((XMcTermWidget)self)->xmcTerm.rows, (long)((XMcTermWidget)self)->xmcTerm.columns); } } //#line 639 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 639 "unix/mcterm.w" static void destroy(Widget self) #else //#line 639 "unix/mcterm.w" static void destroy(self)Widget self; #endif //#line 640 "unix/mcterm.w" { int i; if (((XMcTermWidget)self)->xmcTerm.allocated_rows != 0) { for (i = 0; i < ((XMcTermWidget)self)->xmcTerm.allocated_rows; i++) { XtFree(((XMcTermWidget)self)->xmcTerm.contents[i]); XtFree((char *)((XMcTermWidget)self)->xmcTerm.attribs[i]); } XtFree((char *) ((XMcTermWidget)self)->xmcTerm.contents); XtFree((char *) ((XMcTermWidget)self)->xmcTerm.attribs); } XFreeGC(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.defgc); XFreeGC(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.revgc); XFreeGC(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.cursorgc); } //#line 665 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 665 "unix/mcterm.w" static void expose(Widget self,XEvent * event,Region region) #else //#line 665 "unix/mcterm.w" static void expose(self,event,region)Widget self;XEvent * event;Region region; #endif //#line 666 "unix/mcterm.w" { int top, bot, lft, rgt, y, x, i, w, h; XExposeEvent *ev = (XExposeEvent *) event; Region region1; XRectangle rect; if (! XtIsRealized(self)) return; /* the inside of our window */ rect.x = 0; rect.y = 0; rect.width = ((XMcTermWidget)self)->core.width; rect.height = ((XMcTermWidget)self)->core.height; region1 = XCreateRegion(); XUnionRectWithRegion(&rect, region1, region1); if (region) XIntersectRegion(region, region1, region1); XSetRegion(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.defgc, region1); XSetRegion(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.revgc, region1); XSetRegion(XtDisplay(self), ((XMcTermWidget)self)->xmcTerm.cursorgc, region1); x = ev ? ev->x : rect.x; y = ev ? ev->y : rect.y; w = ev ? ev->width : rect.width; h = ev ? ev->height : rect.height; find_cell(self, x, y, &lft, &top); find_cell(self, x + w, y + h, &rgt, &bot); if (lft < ((XMcTermWidget)self)->xmcTerm.columns && top < ((XMcTermWidget)self)->xmcTerm.rows) for (i = top; i <= bot; i++) draw_line(self, i, lft, rgt + 1); XDestroyRegion(region1); clip_gcs(self); /* Reset clipping region */ } //#line 722 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 722 "unix/mcterm.w" static void write(Widget self,char * text,size_t n) #else //#line 722 "unix/mcterm.w" static void write(self,text,n)Widget self;char * text;size_t n; #endif //#line 723 "unix/mcterm.w" { size_t i; for (i = 0; i < n; i++) { switch (((XMcTermWidget)self)->xmcTerm.state) { case Init: switch (text[i]) { case '\007': XBell(XtDisplay(self), 0); break; /* Bell */ case '\015': ((XMcTermWidget)self)->xmcTerm.cursorx = 0; ((XMcTermWidget)self)->xmcTerm.do_wrap = False; break; /* CR */ case '\011': next_tabstop(self); break; /* Tab */ case '\012': cursor_down(self); break; /* LF */ case '\010': if (((XMcTermWidget)self)->xmcTerm.cursorx) { ((XMcTermWidget)self)->xmcTerm.cursorx--; ((XMcTermWidget)self)->xmcTerm.do_wrap = False; } break; /* Backspace */ case '\033': ((XMcTermWidget)self)->xmcTerm.state = Esc; break; /* Esc */ default: add_char(self, text[i]); } break; case Esc: switch (text[i]) { case '[': ((XMcTermWidget)self)->xmcTerm.state = EscLB; break; case ']': ((XMcTermWidget)self)->xmcTerm.state = EscRB; break; case '2': ((XMcTermWidget)self)->xmcTerm.state = Init; break; /* Set tab stop ignored */ case '7': ((XMcTermWidget)self)->xmcTerm.savedx = ((XMcTermWidget)self)->xmcTerm.cursorx; ((XMcTermWidget)self)->xmcTerm.savedy = ((XMcTermWidget)self)->xmcTerm.cursory; ((XMcTermWidget)self)->xmcTerm.state = Init; break; case '8': goto_xy(self, ((XMcTermWidget)self)->xmcTerm.savedx, ((XMcTermWidget)self)->xmcTerm.savedy); ((XMcTermWidget)self)->xmcTerm.state = Init; break; default: /* Unrecognized sequence */ add_char(self, '\033'); add_char(self, text[i]); ((XMcTermWidget)self)->xmcTerm.state = Init; } break; case EscLB: switch (text[i]) { case 'H': goto_xy(self, 0, 0); ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 'J': clear_eos(self); ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 'K': clear_eol(self), ((XMcTermWidget)self)->xmcTerm.state = Init; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': ((XMcTermWidget)self)->xmcTerm.escparm[0] = text[i] - '0'; ((XMcTermWidget)self)->xmcTerm.state = EscLBRegister0; break; case 'C': if (((XMcTermWidget)self)->xmcTerm.cursorx < ((XMcTermWidget)self)->xmcTerm.columns - 1) ((XMcTermWidget)self)->xmcTerm.cursorx++; ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 'A': if (((XMcTermWidget)self)->xmcTerm.cursory) ((XMcTermWidget)self)->xmcTerm.cursory--; ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 'P': delete_char(self); ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 'M': delete_line(self); ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 'm': ((XMcTermWidget)self)->xmcTerm.cur_attrib = 0; ((XMcTermWidget)self)->xmcTerm.state = Init; break; case '@': insert_chars(self, 1); ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 'L': insert_line(self); ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 's': ((XMcTermWidget)self)->xmcTerm.savedx = ((XMcTermWidget)self)->xmcTerm.cursorx; ((XMcTermWidget)self)->xmcTerm.savedy = ((XMcTermWidget)self)->xmcTerm.cursory; ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 'u': goto_xy(self, ((XMcTermWidget)self)->xmcTerm.savedx, ((XMcTermWidget)self)->xmcTerm.savedy); ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 'r': set_scroll(self, 0, ((XMcTermWidget)self)->xmcTerm.rows-1); ((XMcTermWidget)self)->xmcTerm.state = Init; break; default: /* Unrecognized sequence */ add_char(self, '\033'); add_char(self, '['); add_char(self, text[i]); ((XMcTermWidget)self)->xmcTerm.state = Init; } break; case EscLBRegister0: switch (text[i]) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': ((XMcTermWidget)self)->xmcTerm.escparm[0] = 10 * ((XMcTermWidget)self)->xmcTerm.escparm[0] + text[i] - '0'; break; case ';': ((XMcTermWidget)self)->xmcTerm.escparm[1] = 0; ((XMcTermWidget)self)->xmcTerm.state = EscLBRegister1; break; case 'm': set_attrib(self, 1); ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 'h': ((XMcTermWidget)self)->xmcTerm.insert_mode = True; ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 'l': ((XMcTermWidget)self)->xmcTerm.insert_mode = False; ((XMcTermWidget)self)->xmcTerm.state = Init; break; case '@': insert_chars(self, ((XMcTermWidget)self)->xmcTerm.escparm[0]); ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 'b': repeat_char(self, ((XMcTermWidget)self)->xmcTerm.escparm[0] - 1); ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 'H': case 'f': goto_xy(self, 0, ((XMcTermWidget)self)->xmcTerm.escparm[0] - 1); ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 'n': ((XMcTermWidget)self)->xmcTerm.state = Init; break; /* Report cursor pos ignored */ case 'j': ((XMcTermWidget)self)->xmcTerm.cursorx = ((XMcTermWidget)self)->xmcTerm.cursory = 0; clear_eos(self); ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 'r': set_scroll(self, ((XMcTermWidget)self)->xmcTerm.escparm[0]-1, ((XMcTermWidget)self)->xmcTerm.rows-1); ((XMcTermWidget)self)->xmcTerm.state = Init; break; default: ((XMcTermWidget)self)->xmcTerm.state = Init; /* Ignore unknown sequence */ } break; case EscLBRegister1: switch (text[i]) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': ((XMcTermWidget)self)->xmcTerm.escparm[1] = 10 * ((XMcTermWidget)self)->xmcTerm.escparm[1] + text[i] - '0'; break; case ';': ((XMcTermWidget)self)->xmcTerm.escparm[2] = 0; ((XMcTermWidget)self)->xmcTerm.state = EscLBRegister2; break; case 'm': set_attrib(self, 2); ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 'H': case 'f': goto_xy(self, ((XMcTermWidget)self)->xmcTerm.escparm[1] - 1, ((XMcTermWidget)self)->xmcTerm.escparm[0] - 1); ((XMcTermWidget)self)->xmcTerm.state = Init; break; case 'r': set_scroll(self, ((XMcTermWidget)self)->xmcTerm.escparm[0]-1, ((XMcTermWidget)self)->xmcTerm.escparm[1]-1); ((XMcTermWidget)self)->xmcTerm.state = Init; break; default: ((XMcTermWidget)self)->xmcTerm.state = Init; /* Ignore unknown sequence */ } break; case EscLBRegister2: switch (text[i]) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': ((XMcTermWidget)self)->xmcTerm.escparm[2] = 10 * ((XMcTermWidget)self)->xmcTerm.escparm[2] + text[i] - '0'; break; case ';': ((XMcTermWidget)self)->xmcTerm.escparm[3] = 0; ((XMcTermWidget)self)->xmcTerm.state = EscLBRegister3; break; case 'm': set_attrib(self, 3); ((XMcTermWidget)self)->xmcTerm.state = Init; break; default: ((XMcTermWidget)self)->xmcTerm.state = Init; /* Ignore unknown sequence */ } break; case EscLBRegister3: switch (text[i]) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': ((XMcTermWidget)self)->xmcTerm.escparm[3] = 10 * ((XMcTermWidget)self)->xmcTerm.escparm[3] + text[i] - '0'; break; case ';': ((XMcTermWidget)self)->xmcTerm.escparm[4] = 0; ((XMcTermWidget)self)->xmcTerm.state = EscLBRegister4; break; case 'm': set_attrib(self, 4); ((XMcTermWidget)self)->xmcTerm.state = Init; break; default: ((XMcTermWidget)self)->xmcTerm.state = Init; /* Ignore unknown sequence */ } break; case EscLBRegister4: switch (text[i]) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': ((XMcTermWidget)self)->xmcTerm.escparm[4] = 10 * ((XMcTermWidget)self)->xmcTerm.escparm[4] + text[i] - '0'; break; case 'm': set_attrib(self, 5); ((XMcTermWidget)self)->xmcTerm.state = Init; break; default: ((XMcTermWidget)self)->xmcTerm.state = Init; /* Ignore unknown sequence */ } break; case EscRB: switch (text[i]) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': ((XMcTermWidget)self)->xmcTerm.escparm[0] = text[i] - '0'; ((XMcTermWidget)self)->xmcTerm.state = EscRBRegister0; break; default: /* Unrecognized sequence */ add_char(self, '\033'); add_char(self, ']'); add_char(self, text[i]); ((XMcTermWidget)self)->xmcTerm.state = Init; } break; case EscRBRegister0: switch (text[i]) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': ((XMcTermWidget)self)->xmcTerm.escparm[0] = 10 * ((XMcTermWidget)self)->xmcTerm.escparm[0] + text[i] - '0'; break; #if 0 case ';': ((XMcTermWidget)self)->xmcTerm.escparm[1] = 0; ((XMcTermWidget)self)->xmcTerm.state = EscRBRegister1; break; #endif case 'X': set_cursortype(self, ((XMcTermWidget)self)->xmcTerm.escparm[0]); ((XMcTermWidget)self)->xmcTerm.state = Init; break; default: ((XMcTermWidget)self)->xmcTerm.state = Init; /* Ignore unknown sequence */ } break; default: assert(0); /* cannot happen */ } } /* Finally redraw all lines that are marked as `dirty' */ if (XtIsRealized(self)) { int j; for (j = 0; j < ((XMcTermWidget)self)->xmcTerm.rows; j++) if (((XMcTermWidget)self)->xmcTerm.attribs[j][0] & ATTRIB_DIRTY) { ((XMcTermWidget)self)->xmcTerm.attribs[j][0] &= ~ATTRIB_DIRTY; draw_line(self, j, 0, ((XMcTermWidget)self)->xmcTerm.columns); } } } //#line 147 "unix/mcterm.w" //#line 152 "unix/mcterm.w" //#line 153 "unix/mcterm.w" //#line 154 "unix/mcterm.w" //#line 155 "unix/mcterm.w" //#line 156 "unix/mcterm.w" //#line 157 "unix/mcterm.w" //#line 158 "unix/mcterm.w" //#line 159 "unix/mcterm.w" //#line 161 "unix/mcterm.w" //#line 162 "unix/mcterm.w" //#line 167 "unix/mcterm.w" //#line 174 "unix/mcterm.w" //#line 182 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 182 "unix/mcterm.w" void XMcTermWrite(Widget self,char * buf,size_t nbytes) #else //#line 182 "unix/mcterm.w" void XMcTermWrite(self,buf,nbytes)Widget self;char * buf;size_t nbytes; #endif //#line 183 "unix/mcterm.w" { if (! XtIsSubclass(self, xmcTermWidgetClass)) XtAppError(XtWidgetToApplicationContext(self), "XMcTermWrite may only be called for McTerm widgets."); ((XMcTermWidgetClass)self->core.widget_class)->xmcTerm_class.write(self, buf, nbytes); } //#line 195 "unix/mcterm.w" /*ARGSUSED*/ #if NeedFunctionPrototypes //#line 195 "unix/mcterm.w" void XMcTermCellSize(Widget self,XMcTermCellSizeInfo * buf) #else //#line 195 "unix/mcterm.w" void XMcTermCellSize(self,buf)Widget self;XMcTermCellSizeInfo * buf; #endif //#line 196 "unix/mcterm.w" { if (! XtIsSubclass(self, xmcTermWidgetClass)) XtAppError(XtWidgetToApplicationContext(self), "XMcTermCellSize may only be called for McTerm widgets."); buf->cellwidth = ((XMcTermWidget)self)->xmcTerm.cellwidth; buf->cellheight = ((XMcTermWidget)self)->xmcTerm.cellheight; }