📄 x11term.c
字号:
CursorToggle (); UNBLOCK_INPUT ();}staticXToutput_chars (start, len) register char *start; register int len;{#ifdef XDEBUG fprintf (stderr, "XToutput_chars (len %d)\n",len);#endif writechars (start, start+len-1);}XTflash (){#ifdef HAVE_TIMEVAL#ifdef HAVE_SELECT XGCValues gcv_temp; struct timeval to; BLOCK_INPUT_DECLARE ();#ifdef XDEBUG fprintf (stderr, "XTflash\n");#endif BLOCK_INPUT (); XXgc_temp = XCreateGC(XXdisplay, XXwindow, 0, &gcv_temp); XSetState(XXdisplay, XXgc_temp, WhitePixel (XXdisplay, XXscreen), BlackPixel(XXdisplay, XXscreen), GXinvert, AllPlanes); XFillRectangle (XXdisplay, XXwindow, XXgc_temp, 0, 0, screen_width*XXfontw+2*XXInternalBorder, screen_height*XXfonth+2*XXInternalBorder); XFlush (XXdisplay); UNBLOCK_INPUT (); to.tv_sec = 0; to.tv_usec = 250000; select(0, 0, 0, 0, &to); BLOCK_INPUT (); XFillRectangle (XXdisplay, XXwindow, XXgc_temp, 0, 0, screen_width*XXfontw+2*XXInternalBorder, screen_height*XXfonth+2*XXInternalBorder); XFreeGC(XXdisplay, XXgc_temp); XFlush (XXdisplay); UNBLOCK_INPUT ();#endif#endif} XTfeep (){ BLOCK_INPUT_DECLARE ();#ifdef XDEBUG fprintf (stderr, "XTfeep\n");#endif BLOCK_INPUT (); XBell (XXdisplay,50); XFlush (XXdisplay); UNBLOCK_INPUT ();}/* Artificially creating a cursor is hard, the actual position on the * screen (either where it is or last was) is tracked with VisibleX,Y. * Gnu Emacs code tends to assume a cursor exists in hardward at local_cursor_hpos,Y * and that output text will appear there. During updates, the cursor is * supposed to be blinked out and will only reappear after the update * finishes. */CursorToggle (){ register struct matrix *active_screen; if (!WindowMapped) { CursorExists = 0; CursorOutline = 1; return 0; /* Currently the return values are not */ /* used, but I could anticipate using */ /* them in the future. */ } if (VisibleX < 0 || VisibleX >= screen_width || VisibleY < 0 || VisibleY >= screen_height) { /* Not much can be done */ XFlush (XXdisplay); CursorExists = 0; return 0; } active_screen = current_screen; if (active_screen->highlight[VisibleY]) /* If the cursor is in the modeline, it means display was preempted. Don't actually display the cursor there, just say we did. The code below doesn't display it right, and nobody wants to see it anyway. */ ; else if (active_screen->enable[VisibleY] && VisibleX < active_screen->used[VisibleY]) { if (CursorExists) XDrawImageString(XXdisplay, XXwindow, XXgc_norm, VisibleX*XXfontw+XXInternalBorder, VisibleY*XXfonth+XXInternalBorder+XXbase, &active_screen->contents[VisibleY][VisibleX], 1); else if (CursorOutline) { XDrawImageString(XXdisplay, XXwindow, XXgc_norm, VisibleX*XXfontw+XXInternalBorder, VisibleY*XXfonth+XXInternalBorder+XXbase, &active_screen->contents[VisibleY][VisibleX], 1); XDrawRectangle (XXdisplay, XXwindow, XXgc_norm, VisibleX*XXfontw+XXInternalBorder, VisibleY*XXfonth+XXInternalBorder, XXfontw - 1, XXfonth - 1); } else XDrawImageString(XXdisplay, XXwindow, XXgc_curs, VisibleX*XXfontw+XXInternalBorder, VisibleY*XXfonth+XXInternalBorder+XXbase, &active_screen->contents[VisibleY][VisibleX], 1); } else { if (CursorExists) XClearArea (XXdisplay, XXwindow, VisibleX*XXfontw+XXInternalBorder, VisibleY*XXfonth+XXInternalBorder, XXfontw, XXfonth, 0); else if (CursorOutline) XDrawRectangle (XXdisplay, XXwindow, XXgc_norm, VisibleX*XXfontw+XXInternalBorder, VisibleY*XXfonth+XXInternalBorder, XXfontw - 1, XXfonth - 1); else XDrawImageString(XXdisplay, XXwindow, XXgc_curs, VisibleX*XXfontw+XXInternalBorder, VisibleY*XXfonth+XXInternalBorder+XXbase, " ", 1); } CursorExists = !CursorExists; if (!InUpdate) XFlush (XXdisplay); return 1;}/* This routine is used by routines which are called to paint regions *//* designated by Expose events. If the cursor may be in the exposed *//* region, this routine makes sure it is gone so that dumprectangle can *//* toggle it back into existance if dumprectangle is invoked when not in *//* the midst of a screen update. */staticClearCursor (){ BLOCK_INPUT_DECLARE (); BLOCK_INPUT (); if (!WindowMapped) { CursorExists = 0; CursorOutline = 1; UNBLOCK_INPUT (); return; } if (VisibleX < 0 || VisibleX >= screen_width || VisibleY < 0 || VisibleY >= screen_height) { /* Not much can be done */ CursorExists = 0; UNBLOCK_INPUT (); return; } XClearArea (XXdisplay, XXwindow, VisibleX*XXfontw+XXInternalBorder, VisibleY*XXfonth+XXInternalBorder, XXfontw, XXfonth, 0); CursorExists = 0; UNBLOCK_INPUT ();}XTupdate_begin (){ BLOCK_INPUT_DECLARE (); register int i; #ifdef XDEBUG fprintf (stderr, "XTupdate_begin\n");#endif BLOCK_INPUT (); InUpdate = 1; if (CursorExists) CursorToggle (); for (i=0;i<MAXHEIGHT;i++) updated[i] = 0; SavedX = local_cursor_hpos; SavedY = local_cursor_vpos; /* Thw initial "hardware" cursor position is */ /* saved because that is where gnu emacs */ /* expects the cursor to be at the end of */ /* the update */ UNBLOCK_INPUT ();}XTupdate_end (){ BLOCK_INPUT_DECLARE ();#ifdef XDEBUG fprintf (stderr, "XTupdate_end\n");#endif BLOCK_INPUT (); if (CursorExists) CursorToggle (); InUpdate = 0; /* Display cursor at last place requested. */ XTmove_cursor (local_cursor_vpos, local_cursor_hpos); XFlush (XXdisplay); UNBLOCK_INPUT ();}/* Used for Expose events. Have to get the text * back into the newly blank areas. */dumprectangle (top, left, rows, cols) register int top, left, rows, cols;{ register struct matrix *active_screen; register int ourindex; int localX, localY, localHL; if (top < 0) top = 0; if (left < 0) left = 0; rows += top; cols += left; top /= XXfonth; /* Get row and col containing up and */ /* left borders of exposed region -- */ /* round down here*/ left /= XXfontw; rows += XXfonth-1; cols += XXfontw-1; rows /= XXfonth; /* Get row and col containing bottom and */ /* right borders -- round up here */ rows -= top; cols /= XXfontw; cols -= left; if (rows < 0) return; if (cols < 0) return; if (top > screen_height - 1) return; if (left > screen_width - 1) return; if (VisibleX >= left && VisibleX < left + cols && VisibleY >= top && VisibleY < top + rows) ClearCursor (); if (InUpdate) active_screen = new_screen; else /* When queue is dumped in update this */ active_screen = current_screen; for (localY = top, ourindex = 0; ourindex < rows && localY < screen_height; ++ourindex, ++localY) { if (localY < 0 || localY >= screen_height || !active_screen->enable[localY] || left+1 > active_screen->used[localY]) continue; localX = left; localHL = active_screen->highlight[localY]; dumpchars (active_screen, min (cols, active_screen->used[localY]-localX), localX, localY, localHL); } if (!InUpdate && !CursorExists) CursorToggle (); /* Routine usually called */ /* when not in update */}/* What sections of the window will be modified from the UpdateDisplay * routine is totally under software control. Any line with Y coordinate * greater than flexlines will not change during an update. This is really * used only during dellines and inslines routines (scraplines and stufflines) */XTset_terminal_window (n) register int n;{#ifdef XDEBUG fprintf (stderr, "XTset_terminal_window\n");#endif if (n <= 0 || n > screen_height) flexlines = screen_height; else flexlines = n;}XTins_del_lines (vpos, n) int vpos, n;{#ifdef XDEBUG fprintf (stderr, "XTins_del_lines\n");#endif XTmove_cursor (vpos, 0); if (n >= 0) stufflines (n); else scraplines (-n);}/* Estimate the cost of scrolling as equal to drawing one fifth of the character cells copied if black and white, or half of those characters if color. */staticXTcalculate_costs (extra, costvec, ncostvec) int extra; int *costvec, *ncostvec;{ int color_p = DisplayCells (XXdisplay, XXscreen) > 2; CalcLID (0, screen_width / (color_p ? 2 : 5), 0, 0, costvec, ncostvec);}staticXTinsert_chars (start, len) register char *start; register int len;{#ifdef XDEBUG fprintf (stderr, "XTinsert_chars\n");#endif updateline (0);}staticXTdelete_chars (n) register int n;{ char *msg = "Major foobars! This shouldn't show up!"; #ifdef XDEBUG fprintf (stderr, "XTdelete_chars (num %d local_cursor_hpos %d)\n",n,local_cursor_hpos);#endif updateline (0);}stufflines (n) register int n;{ register int topregion, bottomregion; register int length, newtop; BLOCK_INPUT_DECLARE (); if (local_cursor_vpos >= flexlines) return; BLOCK_INPUT (); if (CursorExists) CursorToggle (); topregion = local_cursor_vpos; bottomregion = flexlines-(n+1); newtop = local_cursor_vpos+n; length = bottomregion-topregion+1; if (length > 0 && newtop <= flexlines) { XCopyArea (XXdisplay, XXwindow, XXwindow, XXgc_norm, XXInternalBorder, topregion*XXfonth+XXInternalBorder, screen_width*XXfontw, length*XXfonth, XXInternalBorder, newtop*XXfonth+XXInternalBorder); } newtop = min (newtop, flexlines-1); length = newtop-topregion; if (length > 0) XClearArea (XXdisplay, XXwindow, XXInternalBorder, topregion*XXfonth+XXInternalBorder, screen_width*XXfontw, n*XXfonth, 0); UNBLOCK_INPUT ();}scraplines (n) register int n;{ BLOCK_INPUT_DECLARE (); if (local_cursor_vpos >= flexlines) return; BLOCK_INPUT (); if (CursorExists) CursorToggle (); if (local_cursor_vpos+n >= flexlines) { if (flexlines >= (local_cursor_vpos + 1)) XClearArea (XXdisplay, XXwindow, XXInternalBorder, local_cursor_vpos*XXfonth+XXInternalBorder, screen_width*XXfontw, (flexlines-local_cursor_vpos) * XXfonth, 0); UNBLOCK_INPUT (); } else { XCopyArea (XXdisplay, XXwindow, XXwindow, XXgc_norm, XXInternalBorder, (local_cursor_vpos+n)*XXfonth+XXInternalBorder, screen_width*XXfontw, (flexlines-local_cursor_vpos-n)*XXfonth, XXInternalBorder, local_cursor_vpos*XXfonth+XXInternalBorder); XClearArea (XXdisplay, XXwindow, XXInternalBorder, (flexlines-n)*XXfonth+XXInternalBorder, screen_width*XXfontw, n*XXfonth, 0); UNBLOCK_INPUT (); }} /* Substitutes for standard read routine. Under X not interested in individual * bytes but rather individual packets. */XTread_socket (sd, bufp, numchars) register int sd; register char *bufp; register int numchars;{#ifdef XDEBUG fprintf(stderr,"XTread_socket\n");#endif return (internal_socket_read (bufp, numchars));}/* * Interpreting incoming keycodes. Should have table modifiable as needed * from elisp. */#ifdef sunchar *stringFuncVal(keycode) KeySym keycode;{ switch (keycode) { case XK_L1: return("192"); case XK_L2: return("193"); case XK_L3: return("194"); case XK_L4: return("195"); case XK_L5: return("196"); case XK_L6: return("197"); case XK_L7: return("198"); case XK_L8: return("199"); case XK_L9: return("200"); case XK_L10: return("201"); case XK_R1: return("208"); case XK_R2: return("209"); case XK_R3: return("210"); case XK_R4: return("211"); case XK_R5: return("212"); case XK_R6: return("213"); case XK_R7: return("214"); case XK_R8: return("215"); case XK_R9: return("216"); case XK_R10: return("217"); case XK_R11: return("218"); case XK_R12: return("219"); case XK_R13: return("220"); case XK_R14: return("221"); case XK_R15: return("222"); case XK_Break: /* Sun3 "Alternate" key */ return("223"); case XK_F1: return("224"); case XK_F2: return("225"); case XK_F3: return("226"); case XK_F4: return("227"); case XK_F5: return("228"); case XK_F6: return("229"); case XK_F7: return("230"); case XK_F8: return("231"); case XK_F9: return("232"); default: return("-1"); }}#else#ifndef AIXchar *stringFuncVal(keycode) KeySym keycode;{ switch (keycode) { case XK_F1: return("11"); case XK_F2: return("12"); case XK_F3: return("13"); case XK_F4: return("14"); case XK_F5: return("15"); case XK_F6: return("17"); case XK_F7: return("18"); case XK_F8: return("19"); case XK_F9: return("20"); case XK_F10: return("21"); case XK_F11: return("23"); case XK_F12: return("24"); case XK_F13: return("25"); case XK_F14: return("26"); case XK_F15: return("28"); case XK_Help: return("28"); case XK_F16: return("29"); case XK_Menu: return("29"); case XK_F17: return("31"); case XK_F18: return("32"); case XK_F19: return("33"); case XK_F20: return("34"); case XK_Find : return("1"); case XK_Insert: return("2"); case XK_Delete: return("3"); case XK_Select: return("4"); case XK_Prior: return("5"); case XK_Next: return("6"); default: return("-1"); }}#endif /* not AIX */#endif /* not sun */ internal_socket_read(bufp, numchars) register unsigned char *bufp;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -