⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 display.c

📁 gcc-2.95.3 Linux下最常用的C编译器
💻 C
📖 第 1 页 / 共 2 页
字号:
/* display.c -- How to display Info windows.   $Id: display.c,v 1.1.1.2 1998/03/22 20:42:23 law Exp $   Copyright (C) 1993, 97 Free Software Foundation, Inc.   This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2, or (at your option)   any later version.   This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.   Written by Brian Fox (bfox@ai.mit.edu). */#include "info.h"#include "display.h"extern int info_any_buffered_input_p (); /* Found in session.c. */static void free_display ();static DISPLAY_LINE **make_display ();/* An array of display lines which tell us what is currently visible on   the display.  */DISPLAY_LINE **the_display = (DISPLAY_LINE **)NULL;/* Non-zero means do no output. */int display_inhibited = 0;/* Initialize THE_DISPLAY to WIDTH and HEIGHT, with nothing in it. */voiddisplay_initialize_display (width, height)     int width, height;{  free_display (the_display);  the_display = make_display (width, height);  display_clear_display (the_display);}/* Clear all of the lines in DISPLAY making the screen blank. */voiddisplay_clear_display (display)     DISPLAY_LINE **display;{  register int i;  register DISPLAY_LINE *display_line;  for (i = 0; (display_line = display[i]); i++)    {      display[i]->text[0] = '\0';      display[i]->textlen = 0;      display[i]->inverse = 0;    }}/* Non-zero if we didn't completely redisplay a window. */int display_was_interrupted_p = 0;/* Update the windows pointed to by WINDOW in the_display.  This actually   writes the text on the screen. */voiddisplay_update_display (window)     WINDOW *window;{  register WINDOW *win;  display_was_interrupted_p = 0;  /* For every window in the list, check contents against the display. */  for (win = window; win; win = win->next)    {      /* Only re-display visible windows which need updating. */      if (((win->flags & W_WindowVisible) == 0) ||          ((win->flags & W_UpdateWindow) == 0) ||          (win->height == 0))        continue;      display_update_one_window (win);      if (display_was_interrupted_p)        break;    }  /* Always update the echo area. */  display_update_one_window (the_echo_area);}/* Display WIN on the_display.  Unlike display_update_display (), this   function only does one window. */voiddisplay_update_one_window (win)     WINDOW *win;{  register char *nodetext;      /* Current character to display. */  register char *last_node_char; /* Position of the last character in node. */  register int i;               /* General use index. */  char *printed_line;           /* Buffer for a printed line. */  int pl_index = 0;             /* Index into PRINTED_LINE. */  int line_index = 0;           /* Number of lines done so far. */  DISPLAY_LINE **display = the_display;  /* If display is inhibited, that counts as an interrupted display. */  if (display_inhibited)    display_was_interrupted_p = 1;  /* If the window has no height, or display is inhibited, quit now. */  if (!win->height || display_inhibited)    return;  /* If the window's first row doesn't appear in the_screen, then it     cannot be displayed.  This can happen when the_echo_area is the     window to be displayed, and the screen has shrunk to less than one     line. */  if ((win->first_row < 0) || (win->first_row > the_screen->height))    return;  /* Print each line in the window into our local buffer, and then     check the contents of that buffer against the display.  If they     differ, update the display. */  printed_line = (char *)xmalloc (1 + win->width);  if (!win->node || !win->line_starts)    goto done_with_node_display;  nodetext = win->line_starts[win->pagetop];  last_node_char = win->node->contents + win->node->nodelen;  for (; nodetext < last_node_char; nodetext++)    {      char *rep, *rep_carried_over, rep_temp[2];      int replen;      if (isprint (*nodetext))        {          rep_temp[0] = *nodetext;          replen = 1;          rep_temp[1] = '\0';          rep = rep_temp;        }      else        {          if (*nodetext == '\r' || *nodetext == '\n')            {              replen = win->width - pl_index;            }          else            {              rep = printed_representation (*nodetext, pl_index);              replen = strlen (rep);            }        }      /* If this character can be printed without passing the width of         the line, then stuff it into the line. */      if (replen + pl_index < win->width)        {          /* Optimize if possible. */          if (replen == 1)            {              printed_line[pl_index++] = *rep;            }          else            {              for (i = 0; i < replen; i++)                printed_line[pl_index++] = rep[i];            }        }      else        {          DISPLAY_LINE *entry;          /* If this character cannot be printed in this line, we have             found the end of this line as it would appear on the screen.             Carefully print the end of the line, and then compare. */          if (*nodetext == '\n' || *nodetext == '\r' || *nodetext == '\t')            {              printed_line[pl_index] = '\0';              rep_carried_over = (char *)NULL;            }          else            {              /* The printed representation of this character extends into                 the next line.  Remember the offset of the last character                 printed out of REP so that we can carry the character over                 to the next line. */              for (i = 0; pl_index < (win->width - 1);)                printed_line[pl_index++] = rep[i++];                            rep_carried_over = rep + i;              /* If printing the last character in this window couldn't                 possibly cause the screen to scroll, place a backslash                 in the rightmost column. */              if (1 + line_index + win->first_row < the_screen->height)                {                  if (win->flags & W_NoWrap)                    printed_line[pl_index++] = '$';                  else                    printed_line[pl_index++] = '\\';                }              printed_line[pl_index] = '\0';            }          /* We have the exact line as it should appear on the screen.             Check to see if this line matches the one already appearing             on the screen. */          entry = display[line_index + win->first_row];          /* If the screen line is inversed, then we have to clear             the line from the screen first.  Why, I don't know. */          if (entry->inverse)            {              terminal_goto_xy (0, line_index + win->first_row);              terminal_clear_to_eol ();              entry->inverse = 0;              entry->text[0] = '\0';              entry->textlen = 0;            }          /* Find the offset where these lines differ. */          for (i = 0; i < pl_index; i++)            if (printed_line[i] != entry->text[i])              break;          /* If the lines are not the same length, or if they differed             at all, we must do some redrawing. */          if ((i != pl_index) || (pl_index != entry->textlen))            {              /* Move to the proper point on the terminal. */              terminal_goto_xy (i, line_index + win->first_row);              /* If there is any text to print, print it. */              if (i != pl_index)                terminal_put_text (printed_line + i);              /* If the printed text didn't extend all the way to the edge                 of the window, and text was appearing between here and the                 edge of the window, clear from here to the end of the line. */              if ((pl_index < win->width && pl_index < entry->textlen) ||                  (entry->inverse))                terminal_clear_to_eol ();              fflush (stdout);              /* Update the display text buffer. */              strcpy (entry->text + i, printed_line + i);              entry->textlen = pl_index;              /* Lines showing node text are not in inverse.  Only modelines                 have that distinction. */              entry->inverse = 0;            }          /* We have done at least one line.  Increment our screen line             index, and check against the bottom of the window. */          if (++line_index == win->height)            break;          /* A line has been displayed, and the screen reflects that state.             If there is typeahead pending, then let that typeahead be read             now, instead of continuing with the display. */          if (info_any_buffered_input_p ())            {              free (printed_line);              display_was_interrupted_p = 1;              return;            }          /* Reset PL_INDEX to the start of the line. */          pl_index = 0;          /* If there are characters from REP left to print, stuff them             into the buffer now. */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -