X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fxemacs-chise.git.1;a=blobdiff_plain;f=src%2Fredisplay-tty.c;fp=src%2Fredisplay-tty.c;h=80bdcc408e17879c087a99e7af0e4da3e4c97132;hp=9e8515dc443dd368aa3052a83725a04f924296d3;hb=a5812bf2ff9a9cf40f4ff78dcb83f5b4c295bd18;hpb=ccce6217f84987dff10ed3d2b60b9f0f65d8f25a diff --git a/src/redisplay-tty.c b/src/redisplay-tty.c index 9e8515d..80bdcc4 100644 --- a/src/redisplay-tty.c +++ b/src/redisplay-tty.c @@ -53,17 +53,12 @@ Boston, MA 02111-1307, USA. */ invoking them correctly. */ /* # include */ /* # include */ -#ifdef __cplusplus -extern "C" { -#endif -extern int tgetent (CONST char *, CONST char *); -extern int tgetflag (CONST char *); -extern int tgetnum (CONST char *); -extern char *tgetstr (CONST char *, char **); -extern void tputs (CONST char *, int, void (*)(int)); -#ifdef __cplusplus -} -#endif +EXTERN_C int tgetent (const char *, const char *); +EXTERN_C int tgetflag (const char *); +EXTERN_C int tgetnum (const char *); +EXTERN_C char *tgetstr (const char *, char **); +EXTERN_C void tputs (const char *, int, void (*)(int)); + #define FORCE_CURSOR_UPDATE(c) send_string_to_tty_console (c, 0, 0) #define OUTPUTN(c, a, n) \ do { \ @@ -81,11 +76,11 @@ extern void tputs (CONST char *, int, void (*)(int)); } while (0) #define OUTPUT1_IF(c, a) OUTPUTN_IF (c, a, 1) -static void tty_output_emchar_dynarr (struct window *w, - struct display_line *dl, - Emchar_dynarr *buf, int xpos, - face_index findex, - int cursor); +static void tty_output_charc_dynarr (struct window *w, + struct display_line *dl, + Charc_dynarr *buf, int xpos, + face_index findex, + int cursor); static void tty_output_bufbyte_string (struct window *w, struct display_line *dl, Bufbyte *str, Bytecount len, @@ -104,13 +99,13 @@ static void term_get_fkeys (Lisp_Object keymap, char **address); Non-Mule tty's don't have fonts (that we use at least), so everything is considered to be fixed width -- in other words, we return LEN. Under Mule, however, a character can still cover more than one - column, so we use emchar_string_displayed_columns(). + column, so we use charc_string_displayed_columns(). ****************************************************************************/ static int -tty_text_width (struct frame *f, struct face_cachel *cachel, CONST Emchar *str, - Charcount len) +tty_text_width (struct frame *f, struct face_cachel *cachel, + const Charc *str, Charcount len) { - return emchar_string_displayed_columns (str, len); + return charc_string_displayed_columns (str, len); } /***************************************************************************** @@ -138,40 +133,40 @@ tty_eol_cursor_width (void) } /***************************************************************************** - tty_output_begin + tty_frame_output_begin Perform any necessary initialization prior to an update. ****************************************************************************/ #ifdef DEBUG_XEMACS -void tty_output_begin (struct device *d); +void tty_frame_output_begin (struct frame *f); void #else static void #endif -tty_output_begin (struct device *d) +tty_frame_output_begin (struct frame *f) { #ifndef HAVE_TERMIOS /* Termcap requires `ospeed' to be a global variable so we have to always set it for whatever tty console we are actually currently working with. */ - ospeed = DEVICE_TTY_DATA (d)->ospeed; + ospeed = DEVICE_TTY_DATA (XDEVICE (FRAME_DEVICE (f)))->ospeed; #endif } /***************************************************************************** - tty_output_end + tty_frame_output_end Perform any necessary flushing of queues when an update has completed. ****************************************************************************/ #ifdef DEBUG_XEMACS -void tty_output_end (struct device *d); +void tty_frame_output_end (struct frame *f); void #else static void #endif -tty_output_end (struct device *d) +tty_frame_output_end (struct frame *f) { - struct console *c = XCONSOLE (DEVICE_CONSOLE (d)); + struct console *c = XCONSOLE (FRAME_CONSOLE (f)); CONSOLE_TTY_CURSOR_X (c) = CONSOLE_TTY_FINAL_CURSOR_X (c); CONSOLE_TTY_CURSOR_Y (c) = CONSOLE_TTY_FINAL_CURSOR_Y (c); @@ -201,7 +196,7 @@ tty_output_display_block (struct window *w, struct display_line *dl, int block, int cursor_height) { struct frame *f = XFRAME (w->frame); - Emchar_dynarr *buf = Dynarr_new (Emchar); + Charc_dynarr *buf = Dynarr_new (Charc); struct display_block *db = Dynarr_atp (dl->display_blocks, block); rune_dynarr *rba = db->runes; @@ -241,18 +236,18 @@ tty_output_display_block (struct window *w, struct display_line *dl, int block, rb = Dynarr_atp (rba, elt); if (rb->findex == findex && rb->type == RUNE_CHAR - && rb->object.chr.ch != '\n' + && (!CHARC_ASCII_EQ (rb->object.cglyph, '\n')) && (rb->cursor_type != CURSOR_ON || NILP (w->text_cursor_visible_p))) { - Dynarr_add (buf, rb->object.chr.ch); + Dynarr_add (buf, rb->object.cglyph); elt++; } else { if (Dynarr_length (buf)) { - tty_output_emchar_dynarr (w, dl, buf, xpos, findex, 0); + tty_output_charc_dynarr (w, dl, buf, xpos, findex, 0); xpos = rb->xpos; } Dynarr_reset (buf); @@ -262,13 +257,12 @@ tty_output_display_block (struct window *w, struct display_line *dl, int block, findex = rb->findex; xpos = rb->xpos; - if (rb->object.chr.ch == '\n') + if (CHARC_ASCII_EQ (rb->object.cglyph, '\n')) { /* Clear in case a cursor was formerly here. */ - - Dynarr_add (buf, ' '); - tty_output_emchar_dynarr (w, dl, buf, rb->xpos, - DEFAULT_INDEX, 0); + Dynarr_add (buf, ASCII_TO_CHARC (' ')); + tty_output_charc_dynarr (w, dl, buf, rb->xpos, + DEFAULT_INDEX, 0); Dynarr_reset (buf); cmgoto (f, dl->ypos - 1, rb->xpos); @@ -279,8 +273,8 @@ tty_output_display_block (struct window *w, struct display_line *dl, int block, { /* There is not a distinct eol cursor on tty's. */ - Dynarr_add (buf, rb->object.chr.ch); - tty_output_emchar_dynarr (w, dl, buf, xpos, findex, 0); + Dynarr_add (buf, rb->object.cglyph); + tty_output_charc_dynarr (w, dl, buf, xpos, findex, 0); Dynarr_reset (buf); cmgoto (f, dl->ypos - 1, xpos); @@ -289,22 +283,22 @@ tty_output_display_block (struct window *w, struct display_line *dl, int block, elt++; } } - /* #### RUNE_HLINE is actualy a little more complicated than this + /* #### RUNE_HLINE is actually a little more complicated than this but at the moment it is only used to draw a turned off modeline and this will suffice for that. */ else if (rb->type == RUNE_BLANK || rb->type == RUNE_HLINE) { - Emchar ch_to_add; + Charc ec_to_add; int size = rb->width; if (rb->type == RUNE_BLANK) - ch_to_add = ' '; + ec_to_add = ASCII_TO_CHARC (' '); else - ch_to_add = '-'; + ec_to_add = ASCII_TO_CHARC ('-'); while (size--) - Dynarr_add (buf, ch_to_add); - tty_output_emchar_dynarr (w, dl, buf, rb->xpos, findex, 0); + Dynarr_add (buf, ec_to_add); + tty_output_charc_dynarr (w, dl, buf, rb->xpos, findex, 0); if (xpos >= cursor_start && cursor_start < xpos + Dynarr_length (buf)) @@ -333,77 +327,28 @@ tty_output_display_block (struct window *w, struct display_line *dl, int block, window, ERROR_ME_NOT, 1); if (IMAGE_INSTANCEP (instance)) - switch (XIMAGE_INSTANCE_TYPE (instance)) - { - case IMAGE_TEXT: + { + switch (XIMAGE_INSTANCE_TYPE (instance)) { - Bufbyte *temptemp; - Lisp_Object string = - XIMAGE_INSTANCE_TEXT_STRING (instance); - Bytecount len = XSTRING_LENGTH (string); - - /* In the unlikely instance that a garbage-collect - occurs during encoding, we at least need to - copy the string. - */ - temptemp = (Bufbyte *) alloca (len); - memcpy (temptemp, XSTRING_DATA (string), len); - { - int i; - - /* Now truncate the first rb->object.dglyph.xoffset - columns. */ - for (i = 0; i < rb->object.dglyph.xoffset;) - { -#ifdef MULE - Emchar ch = charptr_emchar (temptemp); - i += XCHARSET_COLUMNS (CHAR_CHARSET (ch)); -#else - i++; /* telescope this */ -#endif - INC_CHARPTR (temptemp); - } - - /* If we truncated one column too many, then - add a space at the beginning. */ - if (i > rb->object.dglyph.xoffset) - { - assert (i > 0); - *--temptemp = ' '; - i--; - } - len -= i; - } - - tty_output_bufbyte_string (w, dl, temptemp, len, - xpos, findex, 0); - - if (xpos >= cursor_start - && (cursor_start < - xpos + (bufbyte_string_displayed_columns - (temptemp, len)))) - { - cmgoto (f, dl->ypos - 1, cursor_start); - } + case IMAGE_MONO_PIXMAP: + case IMAGE_COLOR_PIXMAP: + case IMAGE_SUBWINDOW: + case IMAGE_WIDGET: + /* just do nothing here */ + break; + + case IMAGE_NOTHING: + /* nothing is as nothing does */ + break; + + case IMAGE_TEXT: + case IMAGE_POINTER: + default: + abort (); } - break; - - case IMAGE_MONO_PIXMAP: - case IMAGE_COLOR_PIXMAP: - case IMAGE_SUBWINDOW: - /* just do nothing here */ - break; - - case IMAGE_POINTER: - abort (); - - case IMAGE_NOTHING: - /* nothing is as nothing does */ - break; - - default: - abort (); - } + IMAGE_INSTANCE_OPTIMIZE_OUTPUT + (XIMAGE_INSTANCE (instance)) = 0; + } xpos += rb->width; elt++; @@ -414,7 +359,7 @@ tty_output_display_block (struct window *w, struct display_line *dl, int block, } if (Dynarr_length (buf)) - tty_output_emchar_dynarr (w, dl, buf, xpos, findex, 0); + tty_output_charc_dynarr (w, dl, buf, xpos, findex, 0); Dynarr_free (buf); } @@ -461,16 +406,14 @@ tty_output_vertical_divider (struct window *w, int clear) Clear the area in the box defined by the given parameters. ****************************************************************************/ static void -tty_clear_region (Lisp_Object window, face_index findex, int x, int y, - int width, int height) +tty_clear_region (Lisp_Object window, struct device* d, struct frame * f, + face_index findex, int x, int y, + int width, int height, Lisp_Object fcolor, Lisp_Object bcolor, + Lisp_Object background_pixmap) { - struct window *w = XWINDOW (window); - struct frame *f = XFRAME (w->frame); struct console *c = XCONSOLE (FRAME_CONSOLE (f)); int line; - - if (!width || !height) - return; + struct window* w = XWINDOW (window); tty_turn_on_face (w, findex); for (line = y; line < y + height; line++) @@ -534,7 +477,7 @@ tty_clear_to_window_end (struct window *w, int ypos1, int ypos2) Lisp_Object window; XSETWINDOW (window, w); - tty_clear_region (window, DEFAULT_INDEX, x, ypos1, width, ypos2 - ypos1); + redisplay_clear_region (window, DEFAULT_INDEX, x, ypos1, width, ypos2 - ypos1); } } @@ -566,7 +509,7 @@ tty_clear_frame (struct frame *f) clear_to_end (f); #else /* #### Not implemented. */ - fprintf (stderr, "Not yet.\n"); + stderr_out ("Not yet.\n"); #endif } tty_turn_off_frame_face (f, Vdefault_face); @@ -593,31 +536,31 @@ tty_output_bufbyte_string (struct window *w, struct display_line *dl, tty_turn_off_face (w, findex); } -static Bufbyte_dynarr *tty_output_emchar_dynarr_dynarr; +static Bufbyte_dynarr *tty_output_charc_dynarr_dynarr; /***************************************************************************** - tty_output_emchar_dynarr + tty_output_charc_dynarr Given a string and a starting position, output that string in the given face. If cursor is true, draw a cursor around the string. ****************************************************************************/ static void -tty_output_emchar_dynarr (struct window *w, struct display_line *dl, - Emchar_dynarr *buf, int xpos, face_index findex, - int cursor) +tty_output_charc_dynarr (struct window *w, struct display_line *dl, + Charc_dynarr *buf, int xpos, face_index findex, + int cursor) { - if (!tty_output_emchar_dynarr_dynarr) - tty_output_emchar_dynarr_dynarr = Dynarr_new (Bufbyte); + if (!tty_output_charc_dynarr_dynarr) + tty_output_charc_dynarr_dynarr = Dynarr_new (Bufbyte); else - Dynarr_reset (tty_output_emchar_dynarr_dynarr); + Dynarr_reset (tty_output_charc_dynarr_dynarr); - convert_emchar_string_into_bufbyte_dynarr (Dynarr_atp (buf, 0), + convert_charc_string_into_bufbyte_dynarr (Dynarr_atp (buf, 0), Dynarr_length (buf), - tty_output_emchar_dynarr_dynarr); + tty_output_charc_dynarr_dynarr); tty_output_bufbyte_string (w, dl, - Dynarr_atp (tty_output_emchar_dynarr_dynarr, 0), - Dynarr_length (tty_output_emchar_dynarr_dynarr), + Dynarr_atp (tty_output_charc_dynarr_dynarr, 0), + Dynarr_length (tty_output_charc_dynarr_dynarr), xpos, findex, cursor); } @@ -937,7 +880,13 @@ reset_tty_modes (struct console *c) OUTPUT1_IF (c, TTY_SD (c).keypad_off); OUTPUT1_IF (c, TTY_SD (c).cursor_normal); OUTPUT1_IF (c, TTY_SD (c).end_motion); - tty_output_end (XDEVICE (CONSOLE_SELECTED_DEVICE (c))); + + { + Lisp_Object frm = CONSOLE_SELECTED_FRAME (c); + + if (!NILP (frm)) + tty_frame_output_end (XFRAME (frm)); + } } /***************************************************************************** @@ -950,21 +899,21 @@ tty_redisplay_shutdown (struct console *c) { Lisp_Object dev = CONSOLE_SELECTED_DEVICE (c); - if (!GC_NILP (dev)) + if (!NILP (dev)) { Lisp_Object frm = DEVICE_SELECTED_FRAME (XDEVICE (dev)); - if (!GC_NILP (frm)) + if (!NILP (frm)) { struct frame *f = XFRAME (frm); /* Clear the bottom line of the frame. */ - tty_clear_region (FRAME_SELECTED_WINDOW (f), DEFAULT_INDEX, 0, + redisplay_clear_region (FRAME_SELECTED_WINDOW (f), DEFAULT_INDEX, 0, f->height, f->width, 1); /* And then stick the cursor there. */ tty_set_final_cursor_coords (f, f->height, 0); - tty_output_end (XDEVICE (dev)); + tty_frame_output_end (f); } } } @@ -974,15 +923,15 @@ tty_redisplay_shutdown (struct console *c) up or removed. */ +#ifdef NOT_YET /* FLAGS - these don't need to be console local since only one console - can be being updated at a time. */ + can be being updated at a time. */ static int insert_mode_on; /* nonzero if in insert mode */ static int standout_mode_on; /* nonzero if in standout mode */ static int underline_mode_on; /* nonzero if in underline mode */ static int alternate_mode_on; /* nonzero if in alternate char set */ static int attributes_on; /* nonzero if any attributes on */ -#ifdef NOT_YET static void turn_on_insert (struct frame *f) { @@ -1109,12 +1058,12 @@ init_tty_for_redisplay (struct device *d, char *terminal_type) CONSOLE_TTY_DATA (c)->term_entry_buffer = (char *) xmalloc (2044); bufptr = CONSOLE_TTY_DATA (c)->term_entry_buffer; -#if !defined(WIN32) +#ifdef SIGTTOU /* SIGTT* don't exist under win32 */ EMACS_BLOCK_SIGNAL (SIGTTOU); #endif status = tgetent (entry_buffer, terminal_type); -#if !defined(WIN32) +#ifdef SIGTTOU EMACS_UNBLOCK_SIGNAL (SIGTTOU); #endif #if 0 @@ -1268,6 +1217,7 @@ init_tty_for_redisplay (struct device *d, char *terminal_type) */ cm_cost_init (c); +#ifdef NOT_YET /* * Initialize local flags. */ @@ -1276,6 +1226,7 @@ init_tty_for_redisplay (struct device *d, char *terminal_type) underline_mode_on = 0; alternate_mode_on = 0; attributes_on = 0; +#endif /* * Attempt to initialize the function_key_map to @@ -1305,7 +1256,8 @@ init_tty_for_redisplay (struct device *d, char *terminal_type) struct fkey_table { - CONST char *cap, *name; + const char *cap; + const char *name; }; /* Termcap capability names that correspond directly to X keysyms. @@ -1437,7 +1389,7 @@ term_get_fkeys_1 (Lisp_Object function_key_map) char *sequence = tgetstr (keys[i].cap, address); if (sequence) Fdefine_key (function_key_map, - build_ext_string (sequence, FORMAT_BINARY), + build_ext_string (sequence, Qbinary), vector1 (intern (keys[i].name))); } @@ -1445,22 +1397,18 @@ term_get_fkeys_1 (Lisp_Object function_key_map) describes F10, whereas othertimes it describes F0 and "k;" describes F10. We will attempt to politely accommodate both systems by testing for "k;", and if it is present, assuming that "k0" denotes F0, otherwise F10. - */ + */ { - char *k_semi = tgetstr ("k;", address); - char *k0 = tgetstr ("k0", address); - CONST char *k0_name = "f10"; + const char *k_semi = tgetstr ("k;", address); + const char *k0 = tgetstr ("k0", address); if (k_semi) - { - Fdefine_key (function_key_map, build_ext_string (k_semi, FORMAT_BINARY), - vector1 (intern ("f10"))); - k0_name = "f0"; - } + Fdefine_key (function_key_map, build_ext_string (k_semi, Qbinary), + vector1 (intern ("f10"))); if (k0) - Fdefine_key (function_key_map, build_ext_string (k0, FORMAT_BINARY), - vector1 (intern (k0_name))); + Fdefine_key (function_key_map, build_ext_string (k0, Qbinary), + vector1 (intern (k_semi ? "f0" : "f10"))); } /* Set up cookies for numbered function keys above f10. */ @@ -1483,47 +1431,46 @@ term_get_fkeys_1 (Lisp_Object function_key_map) { sprintf (fkey, "f%d", i); Fdefine_key (function_key_map, - build_ext_string (sequence, FORMAT_BINARY), + build_ext_string (sequence, Qbinary), vector1 (intern (fkey))); } } } - } + } /* * Various mappings to try and get a better fit. */ - { -#define CONDITIONAL_REASSIGN(cap1, cap2, sym) \ - if (!tgetstr (cap1, address)) \ - { \ - char *sequence = tgetstr (cap2, address); \ - if (sequence) \ - Fdefine_key (function_key_map, \ - build_ext_string (sequence, FORMAT_BINARY), \ - vector1 (intern (sym))); \ - } +#define CONDITIONAL_REASSIGN(cap1, cap2, keyname) do { \ + if (!tgetstr (cap1, address)) \ + { \ + char *sequence = tgetstr (cap2, address); \ + if (sequence) \ + Fdefine_key (function_key_map, \ + build_ext_string (sequence, Qbinary), \ + vector1 (intern (keyname))); \ + } \ + } while (0) - /* if there's no key_next keycap, map key_npage to `next' keysym */ - CONDITIONAL_REASSIGN ("%5", "kN", "next"); - /* if there's no key_prev keycap, map key_ppage to `previous' keysym */ - CONDITIONAL_REASSIGN ("%8", "kP", "prior"); - /* if there's no key_dc keycap, map key_ic to `insert' keysym */ - CONDITIONAL_REASSIGN ("kD", "kI", "insert"); - - /* IBM has their own non-standard dialect of terminfo. - If the standard name isn't found, try the IBM name. */ - CONDITIONAL_REASSIGN ("kB", "KO", "backtab"); - CONDITIONAL_REASSIGN ("@4", "kJ", "execute"); /* actually "action" */ - CONDITIONAL_REASSIGN ("@4", "kc", "execute"); /* actually "command" */ - CONDITIONAL_REASSIGN ("%7", "ki", "menu"); - CONDITIONAL_REASSIGN ("@7", "kw", "end"); - CONDITIONAL_REASSIGN ("F1", "k<", "f11"); - CONDITIONAL_REASSIGN ("F2", "k>", "f12"); - CONDITIONAL_REASSIGN ("%1", "kq", "help"); - CONDITIONAL_REASSIGN ("*6", "kU", "select"); + /* if there's no key_next keycap, map key_npage to `next' keysym */ + CONDITIONAL_REASSIGN ("%5", "kN", "next"); + /* if there's no key_prev keycap, map key_ppage to `previous' keysym */ + CONDITIONAL_REASSIGN ("%8", "kP", "prior"); + /* if there's no key_dc keycap, map key_ic to `insert' keysym */ + CONDITIONAL_REASSIGN ("kD", "kI", "insert"); + + /* IBM has their own non-standard dialect of terminfo. + If the standard name isn't found, try the IBM name. */ + CONDITIONAL_REASSIGN ("kB", "KO", "backtab"); + CONDITIONAL_REASSIGN ("@4", "kJ", "execute"); /* actually "action" */ + CONDITIONAL_REASSIGN ("@4", "kc", "execute"); /* actually "command" */ + CONDITIONAL_REASSIGN ("%7", "ki", "menu"); + CONDITIONAL_REASSIGN ("@7", "kw", "end"); + CONDITIONAL_REASSIGN ("F1", "k<", "f11"); + CONDITIONAL_REASSIGN ("F2", "k>", "f12"); + CONDITIONAL_REASSIGN ("%1", "kq", "help"); + CONDITIONAL_REASSIGN ("*6", "kU", "select"); #undef CONDITIONAL_REASSIGN - } return Qnil; } @@ -1545,8 +1492,8 @@ console_type_create_redisplay_tty (void) CONSOLE_HAS_METHOD (tty, clear_to_window_end); CONSOLE_HAS_METHOD (tty, clear_region); CONSOLE_HAS_METHOD (tty, clear_frame); - CONSOLE_HAS_METHOD (tty, output_begin); - CONSOLE_HAS_METHOD (tty, output_end); + CONSOLE_HAS_METHOD (tty, frame_output_begin); + CONSOLE_HAS_METHOD (tty, frame_output_end); CONSOLE_HAS_METHOD (tty, flash); CONSOLE_HAS_METHOD (tty, ring_bell); CONSOLE_HAS_METHOD (tty, set_final_cursor_coords);