summaryrefslogtreecommitdiff
path: root/src/screen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/screen.c')
-rw-r--r--src/screen.c793
1 files changed, 395 insertions, 398 deletions
diff --git a/src/screen.c b/src/screen.c
index a737dc05d..2e8a6aa1f 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -94,20 +94,20 @@ conceal_cursor_line(win_T *wp)
void
conceal_check_cursor_line(int was_concealed)
{
- if (curwin->w_p_cole > 0 && conceal_cursor_line(curwin) != was_concealed)
- {
- int wcol = curwin->w_wcol;
+ if (curwin->w_p_cole <= 0 || conceal_cursor_line(curwin) == was_concealed)
+ return;
- need_cursor_line_redraw = TRUE;
- // Need to recompute cursor column, e.g., when starting Visual mode
- // without concealing.
- curs_columns(TRUE);
+ int wcol = curwin->w_wcol;
- // When concealing now w_wcol will be computed wrong, keep the previous
- // value, it will be updated in win_line().
- if (!was_concealed)
- curwin->w_wcol = wcol;
- }
+ need_cursor_line_redraw = TRUE;
+ // Need to recompute cursor column, e.g., when starting Visual mode
+ // without concealing.
+ curs_columns(TRUE);
+
+ // When concealing now w_wcol will be computed wrong, keep the previous
+ // value, it will be updated in win_line().
+ if (!was_concealed)
+ curwin->w_wcol = wcol;
}
#endif
@@ -906,14 +906,14 @@ draw_vsep_win(win_T *wp, int row)
int hl;
int c;
- if (wp->w_vsep_width)
- {
- // draw the vertical separator right of this window
- c = fillchar_vsep(&hl, wp);
- screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + wp->w_height,
- W_ENDCOL(wp), W_ENDCOL(wp) + 1,
- c, ' ', hl);
- }
+ if (!wp->w_vsep_width)
+ return;
+
+ // draw the vertical separator right of this window
+ c = fillchar_vsep(&hl, wp);
+ screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + wp->w_height,
+ W_ENDCOL(wp), W_ENDCOL(wp) + 1,
+ c, ' ', hl);
}
/*
@@ -960,36 +960,34 @@ get_keymap_str(
if (wp->w_buffer->b_p_iminsert != B_IMODE_LMAP)
return FALSE;
- {
#ifdef FEAT_EVAL
- buf_T *old_curbuf = curbuf;
- win_T *old_curwin = curwin;
- char_u *s;
-
- curbuf = wp->w_buffer;
- curwin = wp;
- STRCPY(buf, "b:keymap_name"); // must be writable
- ++emsg_skip;
- s = p = eval_to_string(buf, FALSE, FALSE);
- --emsg_skip;
- curbuf = old_curbuf;
- curwin = old_curwin;
- if (p == NULL || *p == NUL)
+ buf_T *old_curbuf = curbuf;
+ win_T *old_curwin = curwin;
+ char_u *s;
+
+ curbuf = wp->w_buffer;
+ curwin = wp;
+ STRCPY(buf, "b:keymap_name"); // must be writable
+ ++emsg_skip;
+ s = p = eval_to_string(buf, FALSE, FALSE);
+ --emsg_skip;
+ curbuf = old_curbuf;
+ curwin = old_curwin;
+ if (p == NULL || *p == NUL)
#endif
- {
+ {
#ifdef FEAT_KEYMAP
- if (wp->w_buffer->b_kmap_state & KEYMAP_LOADED)
- p = wp->w_buffer->b_p_keymap;
- else
+ if (wp->w_buffer->b_kmap_state & KEYMAP_LOADED)
+ p = wp->w_buffer->b_p_keymap;
+ else
#endif
- p = (char_u *)"lang";
- }
- if (vim_snprintf((char *)buf, len, (char *)fmt, p) > len - 1)
- buf[0] = NUL;
+ p = (char_u *)"lang";
+ }
+ if (vim_snprintf((char *)buf, len, (char *)fmt, p) > len - 1)
+ buf[0] = NUL;
#ifdef FEAT_EVAL
- vim_free(s);
+ vim_free(s);
#endif
- }
return buf[0] != NUL;
}
@@ -1208,26 +1206,26 @@ screen_getbytes(int row, int col, char_u *bytes, int *attrp)
unsigned off;
// safety check
- if (ScreenLines != NULL && row < screen_Rows && col < screen_Columns)
+ if (ScreenLines == NULL || row >= screen_Rows || col >= screen_Columns)
+ return;
+
+ off = LineOffset[row] + col;
+ *attrp = ScreenAttrs[off];
+ bytes[0] = ScreenLines[off];
+ bytes[1] = NUL;
+
+ if (enc_utf8 && ScreenLinesUC[off] != 0)
+ bytes[utfc_char2bytes(off, bytes)] = NUL;
+ else if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e)
{
- off = LineOffset[row] + col;
- *attrp = ScreenAttrs[off];
bytes[0] = ScreenLines[off];
- bytes[1] = NUL;
-
- if (enc_utf8 && ScreenLinesUC[off] != 0)
- bytes[utfc_char2bytes(off, bytes)] = NUL;
- else if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e)
- {
- bytes[0] = ScreenLines[off];
- bytes[1] = ScreenLines2[off];
- bytes[2] = NUL;
- }
- else if (enc_dbcs && MB_BYTE2LEN(bytes[0]) > 1)
- {
- bytes[1] = ScreenLines[off + 1];
- bytes[2] = NUL;
- }
+ bytes[1] = ScreenLines2[off];
+ bytes[2] = NUL;
+ }
+ else if (enc_dbcs && MB_BYTE2LEN(bytes[0]) > 1)
+ {
+ bytes[1] = ScreenLines[off + 1];
+ bytes[2] = NUL;
}
}
@@ -1538,12 +1536,12 @@ screen_puts_len(
void
start_search_hl(void)
{
- if (p_hls && !no_hlsearch)
- {
- end_search_hl(); // just in case it wasn't called before
- last_pat_prog(&screen_search_hl.rm);
- screen_search_hl.attr = HL_ATTR(HLF_L);
- }
+ if (!p_hls || no_hlsearch)
+ return;
+
+ end_search_hl(); // just in case it wasn't called before
+ last_pat_prog(&screen_search_hl.rm);
+ screen_search_hl.attr = HL_ATTR(HLF_L);
}
/*
@@ -1552,11 +1550,11 @@ start_search_hl(void)
void
end_search_hl(void)
{
- if (screen_search_hl.rm.regprog != NULL)
- {
- vim_regfree(screen_search_hl.rm.regprog);
- screen_search_hl.rm.regprog = NULL;
- }
+ if (screen_search_hl.rm.regprog == NULL)
+ return;
+
+ vim_regfree(screen_search_hl.rm.regprog);
+ screen_search_hl.rm.regprog = NULL;
}
#endif
@@ -1566,153 +1564,152 @@ screen_start_highlight(int attr)
attrentry_T *aep = NULL;
screen_attr = attr;
- if (full_screen
+ if (!full_screen
#ifdef MSWIN
- && termcap_active
+ || !termcap_active
#endif
- )
- {
+ )
+ return;
+
#ifdef FEAT_GUI
- if (gui.in_use)
- {
- char buf[20];
+ if (gui.in_use)
+ {
+ char buf[20];
- // The GUI handles this internally.
- sprintf(buf, "\033|%dh", attr);
- OUT_STR(buf);
- }
- else
+ // The GUI handles this internally.
+ sprintf(buf, "\033|%dh", attr);
+ OUT_STR(buf);
+ return;
+ }
#endif
- {
- if (attr > HL_ALL) // special HL attr.
- {
- if (IS_CTERM)
- aep = syn_cterm_attr2entry(attr);
- else
- aep = syn_term_attr2entry(attr);
- if (aep == NULL) // did ":syntax clear"
- attr = 0;
- else
- attr = aep->ae_attr;
- }
+
+ if (attr > HL_ALL) // special HL attr.
+ {
+ if (IS_CTERM)
+ aep = syn_cterm_attr2entry(attr);
+ else
+ aep = syn_term_attr2entry(attr);
+ if (aep == NULL) // did ":syntax clear"
+ attr = 0;
+ else
+ attr = aep->ae_attr;
+ }
#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
- if (use_vtp())
- {
- guicolor_T defguifg, defguibg;
- int defctermfg, defctermbg;
+ if (use_vtp())
+ {
+ guicolor_T defguifg, defguibg;
+ int defctermfg, defctermbg;
- // If FG and BG are unset, the color is undefined when
- // BOLD+INVERSE. Use Normal as the default value.
- get_default_console_color(&defctermfg, &defctermbg, &defguifg,
- &defguibg);
+ // If FG and BG are unset, the color is undefined when
+ // BOLD+INVERSE. Use Normal as the default value.
+ get_default_console_color(&defctermfg, &defctermbg, &defguifg,
+ &defguibg);
- if (p_tgc)
- {
- if (aep == NULL || COLOR_INVALID(aep->ae_u.cterm.fg_rgb))
- term_fg_rgb_color(defguifg);
- if (aep == NULL || COLOR_INVALID(aep->ae_u.cterm.bg_rgb))
- term_bg_rgb_color(defguibg);
- }
- else if (t_colors >= 256)
- {
- if (aep == NULL || aep->ae_u.cterm.fg_color == 0)
- term_fg_color(defctermfg);
- if (aep == NULL || aep->ae_u.cterm.bg_color == 0)
- term_bg_color(defctermbg);
- }
- }
+ if (p_tgc)
+ {
+ if (aep == NULL || COLOR_INVALID(aep->ae_u.cterm.fg_rgb))
+ term_fg_rgb_color(defguifg);
+ if (aep == NULL || COLOR_INVALID(aep->ae_u.cterm.bg_rgb))
+ term_bg_rgb_color(defguibg);
+ }
+ else if (t_colors >= 256)
+ {
+ if (aep == NULL || aep->ae_u.cterm.fg_color == 0)
+ term_fg_color(defctermfg);
+ if (aep == NULL || aep->ae_u.cterm.bg_color == 0)
+ term_bg_color(defctermbg);
+ }
+ }
#endif
- if ((attr & HL_BOLD) && *T_MD != NUL) // bold
- out_str(T_MD);
- else if (aep != NULL && cterm_normal_fg_bold && (
+ if ((attr & HL_BOLD) && *T_MD != NUL) // bold
+ out_str(T_MD);
+ else if (aep != NULL && cterm_normal_fg_bold && (
#ifdef FEAT_TERMGUICOLORS
- p_tgc && aep->ae_u.cterm.fg_rgb != CTERMCOLOR
- ? aep->ae_u.cterm.fg_rgb != INVALCOLOR
- :
+ p_tgc && aep->ae_u.cterm.fg_rgb != CTERMCOLOR
+ ? aep->ae_u.cterm.fg_rgb != INVALCOLOR
+ :
#endif
- t_colors > 1 && aep->ae_u.cterm.fg_color))
- // If the Normal FG color has BOLD attribute and the new HL
- // has a FG color defined, clear BOLD.
- out_str(T_ME);
- if ((attr & HL_STANDOUT) && *T_SO != NUL) // standout
- out_str(T_SO);
- if ((attr & HL_UNDERCURL) && *T_UCS != NUL) // undercurl
- out_str(T_UCS);
- if ((attr & HL_UNDERDOUBLE) && *T_USS != NUL) // double underline
- out_str(T_USS);
- if ((attr & HL_UNDERDOTTED) && *T_DS != NUL) // dotted underline
- out_str(T_DS);
- if ((attr & HL_UNDERDASHED) && *T_CDS != NUL) // dashed underline
- out_str(T_CDS);
- if (((attr & HL_UNDERLINE) // underline or undercurl, etc.
- || ((attr & HL_UNDERCURL) && *T_UCS == NUL)
- || ((attr & HL_UNDERDOUBLE) && *T_USS == NUL)
- || ((attr & HL_UNDERDOTTED) && *T_DS == NUL)
- || ((attr & HL_UNDERDASHED) && *T_CDS == NUL))
- && *T_US != NUL)
- out_str(T_US);
- if ((attr & HL_ITALIC) && *T_CZH != NUL) // italic
- out_str(T_CZH);
- if ((attr & HL_INVERSE) && *T_MR != NUL) // inverse (reverse)
- out_str(T_MR);
- if ((attr & HL_STRIKETHROUGH) && *T_STS != NUL) // strike
- out_str(T_STS);
+ t_colors > 1 && aep->ae_u.cterm.fg_color))
+ // If the Normal FG color has BOLD attribute and the new HL
+ // has a FG color defined, clear BOLD.
+ out_str(T_ME);
+ if ((attr & HL_STANDOUT) && *T_SO != NUL) // standout
+ out_str(T_SO);
+ if ((attr & HL_UNDERCURL) && *T_UCS != NUL) // undercurl
+ out_str(T_UCS);
+ if ((attr & HL_UNDERDOUBLE) && *T_USS != NUL) // double underline
+ out_str(T_USS);
+ if ((attr & HL_UNDERDOTTED) && *T_DS != NUL) // dotted underline
+ out_str(T_DS);
+ if ((attr & HL_UNDERDASHED) && *T_CDS != NUL) // dashed underline
+ out_str(T_CDS);
+ if (((attr & HL_UNDERLINE) // underline or undercurl, etc.
+ || ((attr & HL_UNDERCURL) && *T_UCS == NUL)
+ || ((attr & HL_UNDERDOUBLE) && *T_USS == NUL)
+ || ((attr & HL_UNDERDOTTED) && *T_DS == NUL)
+ || ((attr & HL_UNDERDASHED) && *T_CDS == NUL))
+ && *T_US != NUL)
+ out_str(T_US);
+ if ((attr & HL_ITALIC) && *T_CZH != NUL) // italic
+ out_str(T_CZH);
+ if ((attr & HL_INVERSE) && *T_MR != NUL) // inverse (reverse)
+ out_str(T_MR);
+ if ((attr & HL_STRIKETHROUGH) && *T_STS != NUL) // strike
+ out_str(T_STS);
- /*
- * Output the color or start string after bold etc., in case the
- * bold etc. override the color setting.
- */
- if (aep != NULL)
- {
+ /*
+ * Output the color or start string after bold etc., in case the
+ * bold etc. override the color setting.
+ */
+ if (aep != NULL)
+ {
#ifdef FEAT_TERMGUICOLORS
- // When 'termguicolors' is set but fg or bg is unset,
- // fall back to the cterm colors. This helps for SpellBad,
- // where the GUI uses a red undercurl.
- if (p_tgc && aep->ae_u.cterm.fg_rgb != CTERMCOLOR)
- {
- if (aep->ae_u.cterm.fg_rgb != INVALCOLOR)
- term_fg_rgb_color(aep->ae_u.cterm.fg_rgb);
- }
- else
+ // When 'termguicolors' is set but fg or bg is unset,
+ // fall back to the cterm colors. This helps for SpellBad,
+ // where the GUI uses a red undercurl.
+ if (p_tgc && aep->ae_u.cterm.fg_rgb != CTERMCOLOR)
+ {
+ if (aep->ae_u.cterm.fg_rgb != INVALCOLOR)
+ term_fg_rgb_color(aep->ae_u.cterm.fg_rgb);
+ }
+ else
#endif
- if (t_colors > 1)
- {
- if (aep->ae_u.cterm.fg_color)
- term_fg_color(aep->ae_u.cterm.fg_color - 1);
- }
+ if (t_colors > 1)
+ {
+ if (aep->ae_u.cterm.fg_color)
+ term_fg_color(aep->ae_u.cterm.fg_color - 1);
+ }
#ifdef FEAT_TERMGUICOLORS
- if (p_tgc && aep->ae_u.cterm.bg_rgb != CTERMCOLOR)
- {
- if (aep->ae_u.cterm.bg_rgb != INVALCOLOR)
- term_bg_rgb_color(aep->ae_u.cterm.bg_rgb);
- }
- else
+ if (p_tgc && aep->ae_u.cterm.bg_rgb != CTERMCOLOR)
+ {
+ if (aep->ae_u.cterm.bg_rgb != INVALCOLOR)
+ term_bg_rgb_color(aep->ae_u.cterm.bg_rgb);
+ }
+ else
#endif
- if (t_colors > 1)
- {
- if (aep->ae_u.cterm.bg_color)
- term_bg_color(aep->ae_u.cterm.bg_color - 1);
- }
+ if (t_colors > 1)
+ {
+ if (aep->ae_u.cterm.bg_color)
+ term_bg_color(aep->ae_u.cterm.bg_color - 1);
+ }
#ifdef FEAT_TERMGUICOLORS
- if (p_tgc && aep->ae_u.cterm.ul_rgb != CTERMCOLOR)
- {
- if (aep->ae_u.cterm.ul_rgb != INVALCOLOR)
- term_ul_rgb_color(aep->ae_u.cterm.ul_rgb);
- }
- else
+ if (p_tgc && aep->ae_u.cterm.ul_rgb != CTERMCOLOR)
+ {
+ if (aep->ae_u.cterm.ul_rgb != INVALCOLOR)
+ term_ul_rgb_color(aep->ae_u.cterm.ul_rgb);
+ }
+ else
#endif
- if (t_colors > 1)
- {
- if (aep->ae_u.cterm.ul_color)
- term_ul_color(aep->ae_u.cterm.ul_color - 1);
- }
-
- if (!IS_CTERM)
- {
- if (aep->ae_u.term.start != NULL)
- out_str(aep->ae_u.term.start);
- }
+ if (t_colors > 1)
+ {
+ if (aep->ae_u.cterm.ul_color)
+ term_ul_color(aep->ae_u.cterm.ul_color - 1);
}
+
+ if (!IS_CTERM)
+ {
+ if (aep->ae_u.term.start != NULL)
+ out_str(aep->ae_u.term.start);
}
}
}
@@ -1895,13 +1892,14 @@ screen_stop_highlight(void)
void
reset_cterm_colors(void)
{
- if (IS_CTERM)
- {
- // set Normal cterm colors
+ if (!IS_CTERM)
+ return;
+
+ // set Normal cterm colors
#ifdef FEAT_TERMGUICOLORS
- if (p_tgc ? (cterm_normal_fg_gui_color != INVALCOLOR
- || cterm_normal_bg_gui_color != INVALCOLOR)
- : (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0))
+ if (p_tgc ? (cterm_normal_fg_gui_color != INVALCOLOR
+ || cterm_normal_bg_gui_color != INVALCOLOR)
+ : (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0))
#else
if (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0)
#endif
@@ -1909,11 +1907,10 @@ reset_cterm_colors(void)
out_str(T_OP);
screen_attr = -1;
}
- if (cterm_normal_fg_bold)
- {
- out_str(T_ME);
- screen_attr = -1;
- }
+ if (cterm_normal_fg_bold)
+ {
+ out_str(T_ME);
+ screen_attr = -1;
}
}
@@ -2954,223 +2951,223 @@ windgoto(int row, int col)
// Can't use ScreenLines unless initialized
if (ScreenLines == NULL)
return;
- if (col != screen_cur_col || row != screen_cur_row)
- {
- // Check for valid position.
- if (row < 0) // window without text lines?
- row = 0;
- if (row >= screen_Rows)
- row = screen_Rows - 1;
- if (col >= screen_Columns)
- col = screen_Columns - 1;
-
- // check if no cursor movement is allowed in highlight mode
- if (screen_attr && *T_MS == NUL)
- noinvcurs = HIGHL_COST;
- else
- noinvcurs = 0;
- goto_cost = GOTO_COST + noinvcurs;
+ if (col == screen_cur_col && row == screen_cur_row)
+ return;
+
+ // Check for valid position.
+ if (row < 0) // window without text lines?
+ row = 0;
+ if (row >= screen_Rows)
+ row = screen_Rows - 1;
+ if (col >= screen_Columns)
+ col = screen_Columns - 1;
+
+ // check if no cursor movement is allowed in highlight mode
+ if (screen_attr && *T_MS == NUL)
+ noinvcurs = HIGHL_COST;
+ else
+ noinvcurs = 0;
+ goto_cost = GOTO_COST + noinvcurs;
+ /*
+ * Plan how to do the positioning:
+ * 1. Use CR to move it to column 0, same row.
+ * 2. Use T_LE to move it a few columns to the left.
+ * 3. Use NL to move a few lines down, column 0.
+ * 4. Move a few columns to the right with T_ND or by writing chars.
+ *
+ * Don't do this if the cursor went beyond the last column, the cursor
+ * position is unknown then (some terminals wrap, some don't )
+ *
+ * First check if the highlighting attributes allow us to write
+ * characters to move the cursor to the right.
+ */
+ if (row >= screen_cur_row && screen_cur_col < Columns)
+ {
/*
- * Plan how to do the positioning:
- * 1. Use CR to move it to column 0, same row.
- * 2. Use T_LE to move it a few columns to the left.
- * 3. Use NL to move a few lines down, column 0.
- * 4. Move a few columns to the right with T_ND or by writing chars.
- *
- * Don't do this if the cursor went beyond the last column, the cursor
- * position is unknown then (some terminals wrap, some don't )
- *
- * First check if the highlighting attributes allow us to write
- * characters to move the cursor to the right.
+ * If the cursor is in the same row, bigger col, we can use CR
+ * or T_LE.
*/
- if (row >= screen_cur_row && screen_cur_col < Columns)
+ bs = NULL; // init for GCC
+ attr = screen_attr;
+ if (row == screen_cur_row && col < screen_cur_col)
{
- /*
- * If the cursor is in the same row, bigger col, we can use CR
- * or T_LE.
- */
- bs = NULL; // init for GCC
- attr = screen_attr;
- if (row == screen_cur_row && col < screen_cur_col)
+ // "le" is preferred over "bc", because "bc" is obsolete
+ if (*T_LE)
+ bs = T_LE; // "cursor left"
+ else
+ bs = T_BC; // "backspace character (old)
+ if (*bs)
+ cost = (screen_cur_col - col) * (int)STRLEN(bs);
+ else
+ cost = 999;
+ if (col + 1 < cost) // using CR is less characters
{
- // "le" is preferred over "bc", because "bc" is obsolete
- if (*T_LE)
- bs = T_LE; // "cursor left"
- else
- bs = T_BC; // "backspace character (old)
- if (*bs)
- cost = (screen_cur_col - col) * (int)STRLEN(bs);
- else
- cost = 999;
- if (col + 1 < cost) // using CR is less characters
- {
- plan = PLAN_CR;
- wouldbe_col = 0;
- cost = 1; // CR is just one character
- }
- else
- {
- plan = PLAN_LE;
- wouldbe_col = col;
- }
- if (noinvcurs) // will stop highlighting
- {
- cost += noinvcurs;
- attr = 0;
- }
+ plan = PLAN_CR;
+ wouldbe_col = 0;
+ cost = 1; // CR is just one character
}
-
- /*
- * If the cursor is above where we want to be, we can use CR LF.
- */
- else if (row > screen_cur_row)
+ else
{
- plan = PLAN_NL;
- wouldbe_col = 0;
- cost = (row - screen_cur_row) * 2; // CR LF
- if (noinvcurs) // will stop highlighting
- {
- cost += noinvcurs;
- attr = 0;
- }
+ plan = PLAN_LE;
+ wouldbe_col = col;
+ }
+ if (noinvcurs) // will stop highlighting
+ {
+ cost += noinvcurs;
+ attr = 0;
}
+ }
- /*
- * If the cursor is in the same row, smaller col, just use write.
- */
- else
+ /*
+ * If the cursor is above where we want to be, we can use CR LF.
+ */
+ else if (row > screen_cur_row)
+ {
+ plan = PLAN_NL;
+ wouldbe_col = 0;
+ cost = (row - screen_cur_row) * 2; // CR LF
+ if (noinvcurs) // will stop highlighting
{
- plan = PLAN_WRITE;
- wouldbe_col = screen_cur_col;
- cost = 0;
+ cost += noinvcurs;
+ attr = 0;
}
+ }
+
+ /*
+ * If the cursor is in the same row, smaller col, just use write.
+ */
+ else
+ {
+ plan = PLAN_WRITE;
+ wouldbe_col = screen_cur_col;
+ cost = 0;
+ }
+ /*
+ * Check if any characters that need to be written have the
+ * correct attributes. Also avoid UTF-8 characters.
+ */
+ i = col - wouldbe_col;
+ if (i > 0)
+ cost += i;
+ if (cost < goto_cost && i > 0)
+ {
/*
- * Check if any characters that need to be written have the
- * correct attributes. Also avoid UTF-8 characters.
+ * Check if the attributes are correct without additionally
+ * stopping highlighting.
*/
- i = col - wouldbe_col;
- if (i > 0)
- cost += i;
- if (cost < goto_cost && i > 0)
+ p = ScreenAttrs + LineOffset[row] + wouldbe_col;
+ while (i && *p++ == attr)
+ --i;
+ if (i != 0)
{
/*
- * Check if the attributes are correct without additionally
- * stopping highlighting.
+ * Try if it works when highlighting is stopped here.
*/
- p = ScreenAttrs + LineOffset[row] + wouldbe_col;
- while (i && *p++ == attr)
- --i;
- if (i != 0)
+ if (*--p == 0)
{
- /*
- * Try if it works when highlighting is stopped here.
- */
- if (*--p == 0)
+ cost += noinvcurs;
+ while (i && *p++ == 0)
+ --i;
+ }
+ if (i != 0)
+ cost = 999; // different attributes, don't do it
+ }
+ if (enc_utf8)
+ {
+ // Don't use an UTF-8 char for positioning, it's slow.
+ for (i = wouldbe_col; i < col; ++i)
+ if (ScreenLinesUC[LineOffset[row] + i] != 0)
{
- cost += noinvcurs;
- while (i && *p++ == 0)
- --i;
+ cost = 999;
+ break;
}
- if (i != 0)
- cost = 999; // different attributes, don't do it
- }
- if (enc_utf8)
- {
- // Don't use an UTF-8 char for positioning, it's slow.
- for (i = wouldbe_col; i < col; ++i)
- if (ScreenLinesUC[LineOffset[row] + i] != 0)
- {
- cost = 999;
- break;
- }
- }
}
+ }
- /*
- * We can do it without term_windgoto()!
- */
- if (cost < goto_cost)
+ /*
+ * We can do it without term_windgoto()!
+ */
+ if (cost < goto_cost)
+ {
+ if (plan == PLAN_LE)
{
- if (plan == PLAN_LE)
+ if (noinvcurs)
+ screen_stop_highlight();
+ while (screen_cur_col > col)
{
- if (noinvcurs)
- screen_stop_highlight();
- while (screen_cur_col > col)
- {
- out_str(bs);
- --screen_cur_col;
- }
+ out_str(bs);
+ --screen_cur_col;
}
- else if (plan == PLAN_CR)
+ }
+ else if (plan == PLAN_CR)
+ {
+ if (noinvcurs)
+ screen_stop_highlight();
+ out_char('\r');
+ screen_cur_col = 0;
+ }
+ else if (plan == PLAN_NL)
+ {
+ if (noinvcurs)
+ screen_stop_highlight();
+ while (screen_cur_row < row)
{
- if (noinvcurs)
- screen_stop_highlight();
- out_char('\r');
- screen_cur_col = 0;
+ out_char('\n');
+ ++screen_cur_row;
}
- else if (plan == PLAN_NL)
+ screen_cur_col = 0;
+ }
+
+ i = col - screen_cur_col;
+ if (i > 0)
+ {
+ /*
+ * Use cursor-right if it's one character only. Avoids
+ * removing a line of pixels from the last bold char, when
+ * using the bold trick in the GUI.
+ */
+ if (T_ND[0] != NUL && T_ND[1] == NUL)
{
- if (noinvcurs)
- screen_stop_highlight();
- while (screen_cur_row < row)
- {
- out_char('\n');
- ++screen_cur_row;
- }
- screen_cur_col = 0;
+ while (i-- > 0)
+ out_char(*T_ND);
}
-
- i = col - screen_cur_col;
- if (i > 0)
+ else
{
- /*
- * Use cursor-right if it's one character only. Avoids
- * removing a line of pixels from the last bold char, when
- * using the bold trick in the GUI.
- */
- if (T_ND[0] != NUL && T_ND[1] == NUL)
- {
- while (i-- > 0)
- out_char(*T_ND);
- }
- else
- {
- int off;
+ int off;
- off = LineOffset[row] + screen_cur_col;
- while (i-- > 0)
- {
- if (ScreenAttrs[off] != screen_attr)
- screen_stop_highlight();
- out_flush_check();
- out_char(ScreenLines[off]);
- if (enc_dbcs == DBCS_JPNU
- && ScreenLines[off] == 0x8e)
- out_char(ScreenLines2[off]);
- ++off;
- }
+ off = LineOffset[row] + screen_cur_col;
+ while (i-- > 0)
+ {
+ if (ScreenAttrs[off] != screen_attr)
+ screen_stop_highlight();
+ out_flush_check();
+ out_char(ScreenLines[off]);
+ if (enc_dbcs == DBCS_JPNU
+ && ScreenLines[off] == 0x8e)
+ out_char(ScreenLines2[off]);
+ ++off;
}
}
}
}
- else
- cost = 999;
+ }
+ else
+ cost = 999;
- if (cost >= goto_cost)
- {
- if (noinvcurs)
- screen_stop_highlight();
- if (row == screen_cur_row && (col > screen_cur_col)
- && *T_CRI != NUL)
- term_cursor_right(col - screen_cur_col);
- else
- term_windgoto(row, col);
- }
- screen_cur_row = row;
- screen_cur_col = col;
+ if (cost >= goto_cost)
+ {
+ if (noinvcurs)
+ screen_stop_highlight();
+ if (row == screen_cur_row && (col > screen_cur_col)
+ && *T_CRI != NUL)
+ term_cursor_right(col - screen_cur_col);
+ else
+ term_windgoto(row, col);
}
+ screen_cur_row = row;
+ screen_cur_col = col;
}
/*
@@ -4222,13 +4219,13 @@ clearmode(void)
recording_mode(int attr)
{
msg_puts_attr(_("recording"), attr);
- if (!shortmess(SHM_RECORDING))
- {
- char s[4];
+ if (shortmess(SHM_RECORDING))
+ return;
- sprintf(s, " @%c", reg_recording);
- msg_puts_attr(s, attr);
- }
+ char s[4];
+
+ sprintf(s, " @%c", reg_recording);
+ msg_puts_attr(s, attr);
}
/*