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

📄 display.c

📁 gcc-2.95.3 Linux下最常用的C编译器
💻 C
📖 第 1 页 / 共 2 页
字号:
          if (rep_carried_over)            for (; rep[pl_index]; pl_index++)              printed_line[pl_index] = rep[pl_index];          /* If this window has chosen not to wrap lines, skip to the end             of the physical line in the buffer, and start a new line here. */          if (pl_index && (win->flags & W_NoWrap))            {              char *begin;              pl_index = 0;              printed_line[0] = '\0';              begin = nodetext;                            while ((nodetext < last_node_char) && (*nodetext != '\n'))                nodetext++;            }        }    } done_with_node_display:  /* We have reached the end of the node or the end of the window.  If it     is the end of the node, then clear the lines of the window from here     to the end of the window. */  for (; line_index < win->height; line_index++)    {      DISPLAY_LINE *entry = display[line_index + win->first_row];      /* If this line has text on it then make it go away. */      if (entry && entry->textlen)        {          entry->textlen = 0;          entry->text[0] = '\0';          terminal_goto_xy (0, line_index + win->first_row);          terminal_clear_to_eol ();        }    }  /* Finally, if this window has a modeline it might need to be redisplayed.     Check the window's modeline against the one in the display, and update     if necessary. */  if ((win->flags & W_InhibitMode) == 0)    {      window_make_modeline (win);      line_index = win->first_row + win->height;      /* This display line must both be in inverse, and have the same         contents. */      if ((!display[line_index]->inverse) ||          (strcmp (display[line_index]->text, win->modeline) != 0))        {          terminal_goto_xy (0, line_index);          terminal_begin_inverse ();          terminal_put_text (win->modeline);          terminal_end_inverse ();          strcpy (display[line_index]->text, win->modeline);          display[line_index]->inverse = 1;          display[line_index]->textlen = strlen (win->modeline);          fflush (stdout);        }    }  /* Okay, this window doesn't need updating anymore. */  win->flags &= ~W_UpdateWindow;  free (printed_line);  fflush (stdout);}/* Scroll the region of the_display starting at START, ending at END, and   moving the lines AMOUNT lines.  If AMOUNT is less than zero, the lines   are moved up in the screen, otherwise down.  Actually, it is possible   for no scrolling to take place in the case that the terminal doesn't   support it.  This doesn't matter to us. */voiddisplay_scroll_display (start, end, amount)     int start, end, amount;{  register int i, last;  DISPLAY_LINE *temp;  /* If this terminal cannot do scrolling, give up now. */  if (!terminal_can_scroll)    return;  /* If there isn't anything displayed on the screen because it is too     small, quit now. */  if (!the_display[0])    return;  /* If there is typeahead pending, then don't actually do any scrolling. */  if (info_any_buffered_input_p ())    return;  /* Do it on the screen. */  terminal_scroll_terminal (start, end, amount);  /* Now do it in the display buffer so our contents match the screen. */  if (amount > 0)    {      last = end + amount;      /* Shift the lines to scroll right into place. */      for (i = 0; i < (end - start); i++)        {          temp = the_display[last - i];          the_display[last - i] = the_display[end - i];          the_display[end - i] = temp;        }      /* The lines have been shifted down in the buffer.  Clear all of the         lines that were vacated. */      for (i = start; i != (start + amount); i++)        {          the_display[i]->text[0] = '\0';          the_display[i]->textlen = 0;          the_display[i]->inverse = 0;        }    }  if (amount < 0)    {      last = start + amount;      for (i = 0; i < (end - start); i++)        {          temp = the_display[last + i];          the_display[last + i] = the_display[start + i];          the_display[start + i] = temp;        }      /* The lines have been shifted up in the buffer.  Clear all of the         lines that are left over. */      for (i = end + amount; i != end; i++)        {          the_display[i]->text[0] = '\0';          the_display[i]->textlen = 0;          the_display[i]->inverse = 0;        }    }}/* Try to scroll lines in WINDOW.  OLD_PAGETOP is the pagetop of WINDOW before   having had its line starts recalculated.  OLD_STARTS is the list of line   starts that used to appear in this window.  OLD_COUNT is the number of lines   that appear in the OLD_STARTS array. */voiddisplay_scroll_line_starts (window, old_pagetop, old_starts, old_count)     WINDOW *window;     int old_pagetop, old_count;     char **old_starts;{  register int i, old, new;     /* Indices into the line starts arrays. */  int last_new, last_old;       /* Index of the last visible line. */  int old_first, new_first;     /* Index of the first changed line. */  int unchanged_at_top = 0;  int already_scrolled = 0;  /* Locate the first line which was displayed on the old window. */  old_first = old_pagetop;  new_first = window->pagetop;  /* Find the last line currently visible in this window. */  last_new = window->pagetop + (window->height - 1);  if (last_new > window->line_count)    last_new = window->line_count - 1;  /* Find the last line which used to be currently visible in this window. */  last_old = old_pagetop + (window->height - 1);  if (last_old > old_count)    last_old = old_count - 1;  for (old = old_first, new = new_first;       old < last_old && new < last_new;       old++, new++)    if (old_starts[old] != window->line_starts[new])      break;    else      unchanged_at_top++;  /* Loop through the old lines looking for a match in the new lines. */  for (old = old_first + unchanged_at_top; old < last_old; old++)    {      for (new = new_first; new < last_new; new++)        if (old_starts[old] == window->line_starts[new])          {            /* Find the extent of the matching lines. */            for (i = 0; (old + i) < last_old; i++)              if (old_starts[old + i] != window->line_starts[new + i])                break;            /* Scroll these lines if there are enough of them. */            {              int start, end, amount;              start = (window->first_row                       + ((old + already_scrolled) - old_pagetop));              amount = new - (old + already_scrolled);              end = window->first_row + window->height;              /* If we are shifting the block of lines down, then the last                 AMOUNT lines will become invisible.  Thus, don't bother                 scrolling them. */              if (amount > 0)                end -= amount;              if ((end - start) > 0)                {                  display_scroll_display (start, end, amount);                  /* Some lines have been scrolled.  Simulate the scrolling                     by offsetting the value of the old index. */                  old += i;                  already_scrolled += amount;                }            }          }    }}/* Move the screen cursor to directly over the current character in WINDOW. */voiddisplay_cursor_at_point (window)     WINDOW *window;{  int vpos, hpos;  vpos = window_line_of_point (window) - window->pagetop + window->first_row;  hpos = window_get_cursor_column (window);  terminal_goto_xy (hpos, vpos);  fflush (stdout);}/* **************************************************************** *//*                                                                  *//*                   Functions Static to this File                  *//*                                                                  *//* **************************************************************** *//* Make a DISPLAY_LINE ** with width and height. */static DISPLAY_LINE **make_display (width, height)     int width, height;{  register int i;  DISPLAY_LINE **display;  display = (DISPLAY_LINE **)xmalloc ((1 + height) * sizeof (DISPLAY_LINE *));  for (i = 0; i < height; i++)    {      display[i] = (DISPLAY_LINE *)xmalloc (sizeof (DISPLAY_LINE));      display[i]->text = (char *)xmalloc (1 + width);      display[i]->textlen = 0;      display[i]->inverse = 0;    }  display[i] = (DISPLAY_LINE *)NULL;  return (display);}/* Free the storage allocated to DISPLAY. */static voidfree_display (display)     DISPLAY_LINE **display;{  register int i;  register DISPLAY_LINE *display_line;  if (!display)    return;  for (i = 0; (display_line = display[i]); i++)    {      free (display_line->text);      free (display_line);    }  free (display);}

⌨️ 快捷键说明

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