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

📄 display.c

📁 android-w.song.android.widget
💻 C
📖 第 1 页 / 共 5 页
字号:
		  CHECK_INV_LBREAKS ();		  inv_lbreaks[++newlines] = out + temp;		  lpos = 4 - temp;		}	      else		lpos += 4;	      out += 4;	    }	  else	    {	      line[out++] = c;	      CHECK_LPOS();	    }	}#if defined (DISPLAY_TABS)      else if (c == '\t')	{	  register int newout;#if 0	  newout = (out | (int)7) + 1;#else	  newout = out + 8 - lpos % 8;#endif	  temp = newout - out;	  if (lpos + temp >= _rl_screenwidth)	    {	      register int temp2;	      temp2 = _rl_screenwidth - lpos;	      CHECK_INV_LBREAKS ();	      inv_lbreaks[++newlines] = out + temp2;	      lpos = temp - temp2;	      while (out < newout)		line[out++] = ' ';	    }	  else	    {	      while (out < newout)		line[out++] = ' ';	      lpos += temp;	    }	}#endif      else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)	{	  line[out++] = '\0';	/* XXX - sentinel */	  CHECK_INV_LBREAKS ();	  inv_lbreaks[++newlines] = out;	  lpos = 0;	}      else if (CTRL_CHAR (c) || c == RUBOUT)	{	  line[out++] = '^';	  CHECK_LPOS();	  line[out++] = CTRL_CHAR (c) ? UNCTRL (c) : '?';	  CHECK_LPOS();	}      else	{#if defined (HANDLE_MULTIBYTE)	  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)	    {	      register int i;	      _rl_wrapped_multicolumn = 0;	      if (_rl_screenwidth < lpos + wc_width)		for (i = lpos; i < _rl_screenwidth; i++)		  {		    /* The space will be removed in update_line() */		    line[out++] = ' ';		    _rl_wrapped_multicolumn++;		    CHECK_LPOS();		  }	      if (in == rl_point)		{		  cpos_buffer_position = out;		  lb_linenum = newlines;		}	      for (i = in; i < in+wc_bytes; i++)		line[out++] = rl_line_buffer[i];	      for (i = 0; i < wc_width; i++)		CHECK_LPOS();	    }	  else	    {	      line[out++] = c;	      CHECK_LPOS();	    }#else	  line[out++] = c;	  CHECK_LPOS();#endif	}#if defined (HANDLE_MULTIBYTE)      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)	{	  in += wc_bytes;	  /* XXX - what if wc_bytes ends up <= 0? check for MB_INVALIDCH */	  wc_bytes = mbrtowc (&wc, rl_line_buffer + in, rl_end - in, &ps);	}      else        in++;#endif    }  line[out] = '\0';  if (cpos_buffer_position < 0)    {      cpos_buffer_position = out;      lb_linenum = newlines;    }  inv_botlin = lb_botlin = newlines;  CHECK_INV_LBREAKS ();  inv_lbreaks[newlines+1] = out;  cursor_linenum = lb_linenum;  /* CPOS_BUFFER_POSITION == position in buffer where cursor should be placed.     CURSOR_LINENUM == line number where the cursor should be placed. */  /* PWP: now is when things get a bit hairy.  The visible and invisible     line buffers are really multiple lines, which would wrap every     (screenwidth - 1) characters.  Go through each in turn, finding     the changed region and updating it.  The line order is top to bottom. */  /* If we can move the cursor up and down, then use multiple lines,     otherwise, let long lines display in a single terminal line, and     horizontally scroll it. */  if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)    {      int nleft, pos, changed_screen_line, tx;      if (!rl_display_fixed || forced_display)	{	  forced_display = 0;	  /* If we have more than a screenful of material to display, then	     only display a screenful.  We should display the last screen,	     not the first.  */	  if (out >= _rl_screenchars)	    {	      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)		out = _rl_find_prev_mbchar (line, _rl_screenchars, MB_FIND_ANY);	      else		out = _rl_screenchars - 1;	    }	  /* The first line is at character position 0 in the buffer.  The	     second and subsequent lines start at inv_lbreaks[N], offset by	     OFFSET (which has already been calculated above).  */#define INVIS_FIRST()	(prompt_physical_chars > _rl_screenwidth ? prompt_invis_chars_first_line : wrap_offset)#define WRAP_OFFSET(line, offset)  ((line == 0) \					? (offset ? INVIS_FIRST() : 0) \					: ((line == prompt_last_screen_line) ? wrap_offset-prompt_invis_chars_first_line : 0))#define W_OFFSET(line, offset) ((line) == 0 ? offset : 0)#define VIS_LLEN(l)	((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))#define INV_LLEN(l)	(inv_lbreaks[l+1] - inv_lbreaks[l])#define VIS_CHARS(line) (visible_line + vis_lbreaks[line])#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line)#define INV_LINE(line) (invisible_line + inv_lbreaks[line])#define OLD_CPOS_IN_PROMPT() (cpos_adjusted == 0 && \			_rl_last_c_pos != o_cpos && \			_rl_last_c_pos > wrap_offset && \			o_cpos < prompt_last_invisible)	  /* For each line in the buffer, do the updating display. */	  for (linenum = 0; linenum <= inv_botlin; linenum++)	    {	      /* This can lead us astray if we execute a program that changes		 the locale from a non-multibyte to a multibyte one. */	      o_cpos = _rl_last_c_pos;	      cpos_adjusted = 0;	      update_line (VIS_LINE(linenum), INV_LINE(linenum), linenum,			   VIS_LLEN(linenum), INV_LLEN(linenum), inv_botlin);	      /* update_line potentially changes _rl_last_c_pos, but doesn't		 take invisible characters into account, since _rl_last_c_pos		 is an absolute cursor position in a multibyte locale.  See		 if compensating here is the right thing, or if we have to		 change update_line itself.  There are several cases in which		 update_line adjusts _rl_last_c_pos itself (so it can pass		 _rl_move_cursor_relative accurate values); it communicates		 this back by setting cpos_adjusted.  If we assume that		 _rl_last_c_pos is correct (an absolute cursor position) each		 time update_line is called, then we can assume in our		 calculations that o_cpos does not need to be adjusted by		 wrap_offset. */	      if (linenum == 0 && (MB_CUR_MAX > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT())		_rl_last_c_pos -= prompt_invis_chars_first_line;	/* XXX - was wrap_offset */	      else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth &&			(MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&			cpos_adjusted == 0 &&			_rl_last_c_pos != o_cpos &&			_rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line))		_rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line);		  	      /* If this is the line with the prompt, we might need to		 compensate for invisible characters in the new line. Do		 this only if there is not more than one new line (which		 implies that we completely overwrite the old visible line)		 and the new line is shorter than the old.  Make sure we are		 at the end of the new line before clearing. */	      if (linenum == 0 &&		  inv_botlin == 0 && _rl_last_c_pos == out &&		  (wrap_offset > visible_wrap_offset) &&		  (_rl_last_c_pos < visible_first_line_len))		{		  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)		    nleft = _rl_screenwidth - _rl_last_c_pos;		  else		    nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos;		  if (nleft)		    _rl_clear_to_eol (nleft);		}#if 0	      /* This segment is intended to handle the case where the prompt		 has invisible characters on the second line and the new line		 to be displayed needs to clear the rest of the old characters		 out (e.g., when printing the i-search prompt).  In general,		 the case of the new line being shorter than the old.		 Incomplete */	      else if (linenum == prompt_last_screen_line &&		       prompt_physical_chars > _rl_screenwidth &&		       wrap_offset != prompt_invis_chars_first_line &&		       _rl_last_c_pos == out &&#endif	      /* Since the new first line is now visible, save its length. */	      if (linenum == 0)		visible_first_line_len = (inv_botlin > 0) ? inv_lbreaks[1] : out - wrap_offset;	    }	  /* We may have deleted some lines.  If so, clear the left over	     blank ones at the bottom out. */	  if (_rl_vis_botlin > inv_botlin)	    {	      char *tt;	      for (; linenum <= _rl_vis_botlin; linenum++)		{		  tt = VIS_CHARS (linenum);		  _rl_move_vert (linenum);		  _rl_move_cursor_relative (0, tt);		  _rl_clear_to_eol		    ((linenum == _rl_vis_botlin) ? strlen (tt) : _rl_screenwidth);		}	    }	  _rl_vis_botlin = inv_botlin;	  /* CHANGED_SCREEN_LINE is set to 1 if we have moved to a	     different screen line during this redisplay. */	  changed_screen_line = _rl_last_v_pos != cursor_linenum;	  if (changed_screen_line)	    {	      _rl_move_vert (cursor_linenum);	      /* If we moved up to the line with the prompt using _rl_term_up,		 the physical cursor position on the screen stays the same,		 but the buffer position needs to be adjusted to account		 for invisible characters. */	      if ((MB_CUR_MAX == 1 || rl_byte_oriented) && cursor_linenum == 0 && wrap_offset)		_rl_last_c_pos += wrap_offset;	    }	  /* We have to reprint the prompt if it contains invisible	     characters, since it's not generally OK to just reprint	     the characters from the current cursor position.  But we	     only need to reprint it if the cursor is before the last	     invisible character in the prompt string. */	  nleft = prompt_visible_length + wrap_offset;	  if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 &&#if 0	      _rl_last_c_pos <= PROMPT_ENDING_INDEX && local_prompt)#else	      _rl_last_c_pos < PROMPT_ENDING_INDEX && local_prompt)#endif	    {#if defined (__MSDOS__)	      putc ('\r', rl_outstream);#else	      if (_rl_term_cr)		tputs (_rl_term_cr, 1, _rl_output_character_function);#endif	      if (modmark)		_rl_output_some_chars ("*", 1);	      _rl_output_some_chars (local_prompt, nleft);	      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)		_rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft, 1) - wrap_offset + modmark;	      else		_rl_last_c_pos = nleft + modmark;	    }	  /* Where on that line?  And where does that line start	     in the buffer? */	  pos = inv_lbreaks[cursor_linenum];	  /* nleft == number of characters in the line buffer between the	     start of the line and the desired cursor position. */	  nleft = cpos_buffer_position - pos;	  /* NLEFT is now a number of characters in a buffer.  When in a	     multibyte locale, however, _rl_last_c_pos is an absolute cursor	     position that doesn't take invisible characters in the prompt	     into account.  We use a fudge factor to compensate. */	  /* Since _rl_backspace() doesn't know about invisible characters in the	     prompt, and there's no good way to tell it, we compensate for	     those characters here and call _rl_backspace() directly. */	  if (wrap_offset && cursor_linenum == 0 && nleft < _rl_last_c_pos)	    {	      /* TX == new physical cursor position in multibyte locale. */	      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)		tx = _rl_col_width (&visible_line[pos], 0, nleft, 1) - visible_wrap_offset;	      else		tx = nleft;	      if (tx >= 0 && _rl_last_c_pos > tx)		{	          _rl_backspace (_rl_last_c_pos - tx);	/* XXX */	          _rl_last_c_pos = tx;		}	    }	  /* We need to note that in a multibyte locale we are dealing with	     _rl_last_c_pos as an absolute cursor position, but moving to a	     point specified by a buffer position (NLEFT) that doesn't take	     invisible characters into account. */	  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)	    _rl_move_cursor_relative (nleft, &invisible_line[pos]);	  else if (nleft != _rl_last_c_pos)	    _rl_move_cursor_relative (nleft, &invisible_line[pos]);	}    }  else				/* Do horizontal scrolling. */    {#define M_OFFSET(margin, offset) ((margin) == 0 ? offset : 0)      int lmargin, ndisp, nleft, phys_c_pos, t;      /* Always at top line. */      _rl_last_v_pos = 0;      /* Compute where in the buffer the displayed line should start.  This	 will be LMARGIN. */      /* The number of characters that will be displayed before the cursor. */      ndisp = cpos_buffer_position - wrap_offset;      nleft  = prompt_visible_length + wrap_offset;      /* Where the new cursor position will be on the screen.  This can be	 longer than SCREENWIDTH; if it is, lmargin will be adjusted. */      phys_c_pos = cpos_buffer_position - (last_lmargin ? last_lmargin : wrap_offset);      t = _rl_screenwidth / 3;      /* If the number of characters had already exceeded the screenwidth,	 last_lmargin will be > 0. */      /* If the number of characters to be displayed is more than the screen	 width, compute the starting offset so that the cursor is about	 two-thirds of the way across the screen. */      if (phys_c_pos > _rl_screenwidth - 2)	{	  lmargin = cpos_buffer_position - (2 * t);	  if (lmargin < 0)	    lmargin = 0;	  /* If the left margin would be in the middle of a prompt with	     invisible characters, don't display the prompt at all. */	  if (wrap_offset && lmargin > 0 && lmargin < nleft)	    lmargin = nleft;	}      else if (ndisp < _rl_screenwidth - 2)		/* XXX - was -1 */	lmargin = 0;      else if (phys_c_pos < 1)	{	  /* If we are moving back towards the beginning of the line and	     the last margin is no longer correct, compute a new one. */	  lmargin = ((cpos_buffer_position - 1) / t) * t;	/* XXX */	  if (wrap_offset && lmargin > 0 && lmargin < nleft)	    lmargin = nleft;	}      else	lmargin = last_lmargin;      /* If the first character on the screen isn't the first character	 in the display line, indicate this with a special character. */      if (lmargin > 0)	line[lmargin] = '<';      /* If SCREENWIDTH characters starting at LMARGIN do not encompass	 the whole line, indicate that with a special character at the	 right edge of the screen.  If LMARGIN is 0, we need to take the	 wrap offset into account. */      t = lmargin + M_OFFSET (lmargin, wrap_offset) + _rl_screenwidth;      if (t < out)	line[t - 1] = '>';

⌨️ 快捷键说明

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