コード例 #1
0
ファイル: term_redisplay.c プロジェクト: M1lan/zile
void
term_redisplay (void)
{
  /* Calculate the start column if the line at point has to be truncated. */
  Buffer bp = get_window_bp (cur_wp);
  size_t lastcol = 0, t = tab_width (bp);
  size_t o = window_o (cur_wp);
  size_t lineo = o - get_buffer_line_o (bp);

  col = 0;
  o -= lineo;
  set_window_start_column (cur_wp, 0);

  size_t ew = get_window_ewidth (cur_wp);
  for (size_t lp = lineo; lp != SIZE_MAX; --lp)
    {
      col = 0;
      for (size_t p = lp; p < lineo; ++p)
        {
          char c = get_buffer_char (bp, o + p);
          if (isprint (c))
            col++;
          else
            col += strlen (make_char_printable (get_buffer_char (bp, o + p), col, t));
        }

      if (col >= ew - 1 || (lp / (ew / 3)) + 2 < lineo / (ew / 3))
        {
          set_window_start_column (cur_wp, lp + 1);
          col = lastcol;
          break;
        }

      lastcol = col;
    }

  /* Draw the windows. */
  cur_topline = 0;
  size_t topline = 0;
  for (Window wp = head_wp; wp != NULL; wp = get_window_next (wp))
    {
      if (wp == cur_wp)
        cur_topline = topline;

      draw_window (topline, wp);

      topline += get_window_fheight (wp);
    }

  term_redraw_cursor ();
}
コード例 #2
0
ファイル: term_redisplay.c プロジェクト: M1lan/zile
static void
draw_line (size_t line, size_t startcol, Window wp,
           size_t o, Region r, int highlight, size_t cur_tab_width)
{
  term_move (line, 0);

  /* Draw body of line. */
  size_t x, i, line_len = buffer_line_len (get_window_bp (wp), o);
  for (x = 0, i = startcol;; i++)
    {
      term_attrset (highlight && region_contains (r, o + i) ? FONT_REVERSE : FONT_NORMAL);
      if (i >= line_len || x >= get_window_ewidth (wp))
        break;
      char c = get_buffer_char (get_window_bp (wp), o + i);
      if (isprint (c))
        {
          term_addch (c);
          x++;
        }
      else
        {
          const char *s = make_char_printable (c, x, cur_tab_width);
          term_addstr (s);
          x += strlen (s);
        }
    }

  /* Draw end of line. */
  if (x >= term_width ())
    {
      term_move (line, term_width () - 1);
      term_attrset (FONT_NORMAL);
      term_addstr ("$");
    }
  else
    term_addstr (xasprintf ("%*s", (int) (get_window_ewidth (wp) - x), ""));
  term_attrset (FONT_NORMAL);
}
コード例 #3
0
ファイル: completion.c プロジェクト: gvvaughan/luajit-zile
/*
 * Print the list of completions in a set of columns.
 */
static void
completion_print (gl_list_t l, size_t size)
{
  size_t i, j, col, max, numcols;

  max = calculate_max_length (l, size) + 5;
  numcols = (get_window_ewidth (cur_wp) - 1) / max;

  bprintf ("Possible completions are:\n");
  for (i = col = 0; i < MIN (size, gl_list_size (l)); i++)
    {
      char *s = (char *) gl_list_get_at (l, i);
      size_t len = strlen (s);
      if (col >= numcols)
        {
          col = 0;
          insert_newline ();
        }
      insert_nstring (s, len);
      for (j = max - len; j > 0; --j)
        insert_char_in_insert_mode (' ');
      ++col;
    }
}
コード例 #4
0
ファイル: term_redisplay.c プロジェクト: M1lan/zile
static void
draw_status_line (size_t line, Window wp)
{
  term_attrset (FONT_REVERSE);

  term_move (line, 0);
  for (size_t i = 0; i < get_window_ewidth (wp); ++i)
    term_addstr ("-");

  const char *eol_type;
  if (get_buffer_eol (cur_bp) == coding_eol_cr)
    eol_type = "(Mac)";
  else if (get_buffer_eol (cur_bp) == coding_eol_crlf)
    eol_type = "(DOS)";
  else
    eol_type = ":";

  term_move (line, 0);
  size_t n = offset_to_line (get_window_bp (wp), window_o (wp));
  astr as = astr_fmt ("--%s%2s  %-15s   %s %-9s (Fundamental",
                      eol_type, make_mode_line_flags (wp), get_buffer_name (get_window_bp (wp)),
                      make_screen_pos (wp), astr_cstr (astr_fmt ("(%zu,%zu)", n + 1,
                                                                 get_goalc_bp (get_window_bp (wp), window_o (wp)))));

  if (get_buffer_autofill (get_window_bp (wp)))
    astr_cat_cstr (as, " Fill");
  if (thisflag & FLAG_DEFINING_MACRO)
    astr_cat_cstr (as, " Def");
  if (get_buffer_isearch (get_window_bp (wp)))
    astr_cat_cstr (as, " Isearch");

  astr_cat_char (as, ')');
  term_addstr (astr_cstr (as));

  term_attrset (FONT_NORMAL);
}