#if defined(FEAT_TABPANEL) || defined(PROTO)
static void do_by_tplmode(int tplmode, int col_start, int col_end,
- int* pcurtab_row, int* ptabpagenr);
+ int *pcurtab_row, int *ptabpagenr);
// set pcurtab_row. don't redraw tabpanel.
#define TPLMODE_GET_CURTAB_ROW 0
#define VERT_LEN 1
-// tpl_vert's values
-#define VERT_OFF 0
-#define VERT_ON 1
-
// tpl_align's values
#define ALIGN_LEFT 0
#define ALIGN_RIGHT 1
static int opt_scope = OPT_LOCAL;
static int tpl_align = ALIGN_LEFT;
static int tpl_columns = 20;
-static int tpl_vert = VERT_OFF;
+static int tpl_is_vert = FALSE;
typedef struct {
win_T *wp;
char_u *p;
int new_align = ALIGN_LEFT;
int new_columns = 20;
- int new_vert = VERT_OFF;
+ int new_is_vert = FALSE;
p = p_tplo;
while (*p != NUL)
else if (STRNCMP(p, "vert", 4) == 0)
{
p += 4;
- new_vert = VERT_ON;
+ new_is_vert = TRUE;
}
if (*p != ',' && *p != NUL)
tpl_align = new_align;
tpl_columns = new_columns;
- tpl_vert = new_vert;
+ tpl_is_vert = new_is_vert;
return OK;
}
int
tabpanel_leftcol(win_T *wp)
{
- if (cmdline_pum_active())
- return 0;
- else if (wp != NULL && WIN_IS_POPUP(wp))
+ if (cmdline_pum_active() || (wp != NULL && WIN_IS_POPUP(wp)))
return 0;
else
return tpl_align == ALIGN_RIGHT ? 0 : tabpanel_width();
int vsrow = 0;
int is_right = tpl_align == ALIGN_RIGHT;
- if (0 == maxwidth)
+ if (maxwidth == 0)
return;
#ifndef MSWIN
else
off = LineOffset[row];
- vim_memset(ScreenLines + off, ' ',
- (size_t)maxwidth * sizeof(schar_T));
+ vim_memset(ScreenLines + off, ' ', (size_t)maxwidth * sizeof(schar_T));
if (enc_utf8)
vim_memset(ScreenLinesUC + off, -1,
(size_t)maxwidth * sizeof(u8char_T));
// Reset got_int to avoid build_stl_str_hl() isn't evaluted.
got_int = FALSE;
- if (tpl_vert == VERT_ON)
+ if (tpl_is_vert)
{
if (is_right)
{
int curtab_row = 0;
int tabpagenr = 0;
- if (0 == maxwidth)
+ if (maxwidth == 0)
return -1;
do_by_tplmode(TPLMODE_GET_CURTAB_ROW, 0, maxwidth, &curtab_row, NULL);
int attr)
{
int is_right = tpl_align == ALIGN_RIGHT;
- if (TPLMODE_REDRAW == tplmode)
+ if (tplmode == TPLMODE_REDRAW)
screen_fill(row_start, row_end,
(is_right ? COLUMNS_WITHOUT_TPL() : 0) + col_start,
(is_right ? COLUMNS_WITHOUT_TPL() : 0) + col_end,
int chlen;
int chcells;
char_u buf[IOSIZE];
- char_u* temp;
+ char_u *temp;
for (j = 0; j < len;)
{
- if ((TPLMODE_GET_CURTAB_ROW != tplmode)
- && (pargs->maxrow <= (*pargs->prow - pargs->offsetrow)))
+ if (tplmode != TPLMODE_GET_CURTAB_ROW
+ && pargs->maxrow <= *pargs->prow - pargs->offsetrow)
break;
- if ((p[j] == '\n') || (p[j] == '\r'))
+ if (p[j] == '\n' || p[j] == '\r')
{
// fill the tailing area of current row.
- if (0 <= (*pargs->prow - pargs->offsetrow)
- && (*pargs->prow - pargs->offsetrow) < pargs->maxrow)
+ if (*pargs->prow - pargs->offsetrow >= 0
+ && *pargs->prow - pargs->offsetrow < pargs->maxrow)
screen_fill_tailing_area(tplmode,
*pargs->prow - pargs->offsetrow,
*pargs->prow - pargs->offsetrow + 1,
if (pargs->col_end < (*pargs->pcol) + chcells)
{
// fill the tailing area of current row.
- if (0 <= (*pargs->prow - pargs->offsetrow)
- && (*pargs->prow - pargs->offsetrow) < pargs->maxrow)
+ if (*pargs->prow - pargs->offsetrow >= 0
+ && *pargs->prow - pargs->offsetrow < pargs->maxrow)
screen_fill_tailing_area(tplmode,
*pargs->prow - pargs->offsetrow,
*pargs->prow - pargs->offsetrow + 1,
break;
}
- if ((*pargs->pcol) + chcells <= pargs->col_end)
+ if (*pargs->pcol + chcells <= pargs->col_end)
{
int off = (tpl_align == ALIGN_RIGHT)
? COLUMNS_WITHOUT_TPL()
: 0;
- if ((TPLMODE_REDRAW == tplmode)
- && (0 <= (*pargs->prow - pargs->offsetrow)
- && (*pargs->prow - pargs->offsetrow) < pargs->maxrow))
+ if (TPLMODE_REDRAW == tplmode
+ && (*pargs->prow - pargs->offsetrow >= 0
+ && *pargs->prow - pargs->offsetrow < pargs->maxrow))
screen_puts(buf, *pargs->prow - pargs->offsetrow,
*pargs->pcol + off, attr);
- (*pargs->pcol) += chcells;
+ *pargs->pcol += chcells;
}
}
}
if (bufIsChanged(pargs->wp->w_buffer))
modified = TRUE;
- if (modified || 1 < wincount)
+ if (modified || wincount > 1)
{
- if (1 < wincount)
+ if (wincount > 1)
{
vim_snprintf((char *)NameBuff, MAXPATHL, "%d", wincount);
len = (int)STRLEN(NameBuff);
screen_puts_len_for_tabpanel(tplmode, NameBuff, len, pargs->attr, pargs);
// fill the tailing area of current row.
- if (0 <= (*pargs->prow - pargs->offsetrow)
- && (*pargs->prow - pargs->offsetrow) < pargs->maxrow)
+ if (*pargs->prow - pargs->offsetrow >= 0
+ && *pargs->prow - pargs->offsetrow < pargs->maxrow)
screen_fill_tailing_area(tplmode, *pargs->prow - pargs->offsetrow,
*pargs->prow - pargs->offsetrow + 1,
*pargs->pcol, pargs->col_end, pargs->attr);
screen_puts_len_for_tabpanel(tplmode, p, (int)STRLEN(p), curattr, pargs);
// fill the tailing area of current row.
- if (0 <= (*pargs->prow - pargs->offsetrow)
- && (*pargs->prow - pargs->offsetrow) < pargs->maxrow)
+ if (*pargs->prow - pargs->offsetrow >= 0
+ && *pargs->prow - pargs->offsetrow < pargs->maxrow)
screen_fill_tailing_area(tplmode, *pargs->prow - pargs->offsetrow,
*pargs->prow - pargs->offsetrow + 1, *pargs->pcol,
pargs->col_end, curattr);
// When the format starts with "%!" then evaluate it as an expression and
// use the result as the actual format string.
- if (1 < len && usefmt[0] == '%' && usefmt[1] == '!')
+ if (len > 1 && usefmt[0] == '%' && usefmt[1] == '!')
{
typval_T tv;
char_u *p = NULL;
int row = 0;
tabpage_T *tp = NULL;
typval_T v;
- tabpanel_T args;
+ tabpanel_T args;
args.maxrow = cmdline_row;
args.offsetrow = 0;
args.col_start = col_start;
args.col_end = col_end;
- if (TPLMODE_GET_CURTAB_ROW != tplmode)
- if (0 < args.maxrow)
- while (args.offsetrow + args.maxrow <= *pcurtab_row)
- args.offsetrow += args.maxrow;
+ if (tplmode != TPLMODE_GET_CURTAB_ROW && args.maxrow > 0)
+ while (args.offsetrow + args.maxrow <= *pcurtab_row)
+ args.offsetrow += args.maxrow;
tp = first_tabpage;
for (row = 0; tp != NULL; row++)
{
- if ((TPLMODE_GET_CURTAB_ROW != tplmode)
- && (args.maxrow <= (row - args.offsetrow)))
+ if (tplmode != TPLMODE_GET_CURTAB_ROW
+ && args.maxrow <= row - args.offsetrow)
break;
col = col_start;
if (tp->tp_topframe == topframe)
{
args.attr = attr_tpls;
- if (TPLMODE_GET_CURTAB_ROW == tplmode)
+ if (tplmode == TPLMODE_GET_CURTAB_ROW)
{
*pcurtab_row = row;
break;
args.wp = tp->tp_firstwin;
}
- char_u* usefmt = starts_with_percent_and_bang(&args);
+ char_u *usefmt = starts_with_percent_and_bang(&args);
if (usefmt != NULL)
{
char_u buf[IOSIZE];
char_u *p = usefmt;
size_t i = 0;
- while (p[i] != '\0')
+ while (p[i] != NUL)
{
- while ((p[i] == '\n') || (p[i] == '\r'))
+ while (p[i] == '\n' || p[i] == '\r')
{
// fill the tailing area of current row.
- if (0 <= (row - args.offsetrow)
- && (row - args.offsetrow) < args.maxrow)
+ if (row - args.offsetrow >= 0
+ && row - args.offsetrow < args.maxrow)
screen_fill_tailing_area(tplmode,
row - args.offsetrow,
row - args.offsetrow + 1,
p++;
}
- while ((p[i] != '\n') && (p[i] != '\r')
- && (p[i] != '\0'))
+ while (p[i] != '\n' && p[i] != '\r' && (p[i] != NUL))
{
if (i + 1 >= sizeof(buf))
break;
buf[i] = p[i];
i++;
}
- buf[i] = '\0';
+ buf[i] = NUL;
args.user_defined = buf;
args.prow = &row;
tp = tp->tp_next;
- if ((TPLMODE_GET_TABPAGENR == tplmode)
+ if ((tplmode == TPLMODE_GET_TABPAGENR)
&& (mouse_row <= (row - args.offsetrow)))
{
*ptabpagenr = v.vval.v_number;
source screendump.vim
CheckFeature tabpanel
-function! s:reset()
+function s:reset()
set tabpanel&
set tabpanelopt&
set showtabpanel&
endfunc
-function! Test_tabpanel_mouse()
+function Test_tabpanel_mouse()
let save_showtabline = &showtabline
let save_mouse = &mouse
set showtabline=0 mouse=a
let &showtabline = save_showtabline
endfunc
-function! Test_tabpanel_drawing()
+function Test_tabpanel_drawing()
CheckScreendump
let lines =<< trim END
- function! MyTabPanel()
+ function MyTabPanel()
let n = g:actual_curtabpage
let hi = n == tabpagenr() ? 'TabLineSel' : 'TabLine'
let label = printf("\n%%#%sTabNumber#%d:%%#%s#", hi, n, hi)
call StopVimInTerminal(buf)
endfunc
-function! Test_tabpanel_drawing_with_popupwin()
+function Test_tabpanel_drawing_with_popupwin()
CheckScreendump
let lines =<< trim END
call StopVimInTerminal(buf)
endfunc
-function! Test_tabpanel_drawing_fill_tailing()
+function Test_tabpanel_drawing_fill_tailing()
CheckScreendump
let lines =<< trim END
call StopVimInTerminal(buf)
endfunc
-function! Test_tabpanel_drawing_pum()
+function Test_tabpanel_drawing_pum()
CheckScreendump
let lines =<< trim END
call term_sendkeys(buf, "i\<C-x>\<C-v>")
call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_0', {})
- call term_sendkeys(buf, "\<cr> ab\<C-x>\<C-v>")
+ call term_sendkeys(buf, "\<CR> ab\<C-x>\<C-v>")
call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_1', {})
call StopVimInTerminal(buf)
endfunc
-function! Test_tabpanel_scrolling()
+function Test_tabpanel_scrolling()
CheckScreendump
let lines =<< trim END
let buf = RunVimInTerminal('-S XTest_tabpanel_scrolling', {'rows': 10, 'cols': 45})
let n = 0
for c in ['H', 'J', 'K', 'L']
- call term_sendkeys(buf, ":wincmd " .. c .. "\<cr>")
+ call term_sendkeys(buf, ":wincmd " .. c .. "\<CR>")
call term_sendkeys(buf, "\<C-d>\<C-d>")
call term_sendkeys(buf, "r@")
call VerifyScreenDump(buf, 'Test_tabpanel_drawing_scrolling_' .. n, {})
call StopVimInTerminal(buf)
endfunc
-function! Test_tabpanel_many_tabpages()
+function Test_tabpanel_many_tabpages()
CheckScreendump
let lines =<< trim END
call term_sendkeys(buf, "gt")
call VerifyScreenDump(buf, 'Test_tabpanel_many_tabpages_' .. n, {})
endfor
- call term_sendkeys(buf, ":tabnext +10\<cr>")
- call term_sendkeys(buf, ":tabnext -3\<cr>")
+ call term_sendkeys(buf, ":tabnext +10\<CR>")
+ call term_sendkeys(buf, ":tabnext -3\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_many_tabpages_4', {})
call StopVimInTerminal(buf)
endfunc
-function! Test_tabpanel_visual()
+function Test_tabpanel_visual()
CheckScreendump
let lines =<< trim END
let buf = RunVimInTerminal('-S XTest_tabpanel_visual', {'rows': 10, 'cols': 45})
call term_sendkeys(buf, "v2w")
call VerifyScreenDump(buf, 'Test_tabpanel_visual_0', {})
- call term_sendkeys(buf, "\<esc>0jw")
+ call term_sendkeys(buf, "\<Esc>0jw")
call term_sendkeys(buf, "v2wge")
call VerifyScreenDump(buf, 'Test_tabpanel_visual_1', {})
- call term_sendkeys(buf, "y:echo @\"\<cr>")
+ call term_sendkeys(buf, "y:echo @\"\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_visual_2', {})
call StopVimInTerminal(buf)
endfunc
-function! Test_tabpanel_commandline()
+function Test_tabpanel_commandline()
CheckScreendump
let lines =<< trim END
call writefile(lines, 'XTest_tabpanel_commandline', 'D')
let buf = RunVimInTerminal('-S XTest_tabpanel_commandline', {'rows': 10, 'cols': 45})
- call term_sendkeys(buf, ":ab\<tab>")
+ call term_sendkeys(buf, ":ab\<Tab>")
call VerifyScreenDump(buf, 'Test_tabpanel_commandline_0', {})
- call term_sendkeys(buf, "\<esc>")
- call term_sendkeys(buf, ":set wildoptions=pum\<cr>")
- call term_sendkeys(buf, ":ab\<tab>")
+ call term_sendkeys(buf, "\<Esc>")
+ call term_sendkeys(buf, ":set wildoptions=pum\<CR>")
+ call term_sendkeys(buf, ":ab\<Tab>")
call VerifyScreenDump(buf, 'Test_tabpanel_commandline_1', {})
call StopVimInTerminal(buf)
endfunc
-function! Test_tabpanel_tabline_and_tabpanel()
+function Test_tabpanel_tabline_and_tabpanel()
CheckScreendump
let lines =<< trim END
call StopVimInTerminal(buf)
endfunc
-function! Test_tabpanel_dont_overflow_into_tabpanel()
+function Test_tabpanel_dont_overflow_into_tabpanel()
CheckScreendump
let lines =<< trim END
call StopVimInTerminal(buf)
endfunc
-function! Test_tabpanel_dont_vert_is_multibytes_left()
+function Test_tabpanel_dont_vert_is_multibytes_left()
CheckScreendump
let lines =<< trim END
let buf = RunVimInTerminal('-S XTest_tabpanel_vert_is_multibyte_lefts', {'rows': 10, 'cols': 45})
call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_0', {})
- call term_sendkeys(buf, ":set tabpanelopt=columns:1,vert\<cr>")
+ call term_sendkeys(buf, ":set tabpanelopt=columns:1,vert\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_1', {})
- call term_sendkeys(buf, ":set tabpanelopt=columns:10,vert\<cr>")
+ call term_sendkeys(buf, ":set tabpanelopt=columns:10,vert\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_2', {})
- call term_sendkeys(buf, ":set tabpanelopt=columns:2,vert\<cr>")
+ call term_sendkeys(buf, ":set tabpanelopt=columns:2,vert\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_3', {})
call StopVimInTerminal(buf)
endfunc
-function! Test_tabpanel_dont_vert_is_multibytes_right()
+function Test_tabpanel_dont_vert_is_multibytes_right()
CheckScreendump
let lines =<< trim END
let buf = RunVimInTerminal('-S XTest_tabpanel_vert_is_multibytes_right', {'rows': 10, 'cols': 45})
call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_0', {})
- call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:1,vert\<cr>")
+ call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:1,vert\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_1', {})
- call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:10,vert\<cr>")
+ call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:10,vert\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_2', {})
- call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:2,vert\<cr>")
+ call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:2,vert\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_3', {})
call StopVimInTerminal(buf)
endfunc
-function! Test_tabpanel_eval_tabpanel_statusline_tabline()
+function Test_tabpanel_eval_tabpanel_statusline_tabline()
CheckScreendump
let lines =<< trim END
- function! Expr()
+ function Expr()
return "$%=[%f]%=$"
endfunction
set laststatus=2
let buf = RunVimInTerminal('-S XTest_tabpanel_eval_tabpanel_statusline_tabline', {'rows': 10, 'cols': 45})
call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_statusline_tabline_0', {})
- call term_sendkeys(buf, ":set tabpanelopt+=align:right\<cr>")
+ call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_statusline_tabline_1', {})
call StopVimInTerminal(buf)
endfunc
-function! Test_tabpanel_noeval_tabpanel_statusline_tabline()
+function Test_tabpanel_noeval_tabpanel_statusline_tabline()
CheckScreendump
let lines =<< trim END
let buf = RunVimInTerminal('-S XTest_tabpanel_noeval_tabpanel_statusline_tabline', {'rows': 10, 'cols': 45})
call VerifyScreenDump(buf, 'Test_tabpanel_noeval_tabpanel_statusline_tabline_0', {})
- call term_sendkeys(buf, ":set tabpanelopt+=align:right\<cr>")
+ call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_noeval_tabpanel_statusline_tabline_1', {})
call StopVimInTerminal(buf)
endfunc
-function! Test_tabpanel_eval_tabpanel_with_linebreaks()
+function Test_tabpanel_eval_tabpanel_with_linebreaks()
CheckScreendump
let lines =<< trim END
- function! Expr()
+ function Expr()
return "top\n$%=[%f]%=$\nbottom"
endfunction
set showtabpanel=2
let buf = RunVimInTerminal('-S XTest_tabpanel_eval_tabpanel_with_linebreaks', {'rows': 10, 'cols': 45})
call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_with_linebreaks_0', {})
- call term_sendkeys(buf, ":set tabpanelopt+=align:right\<cr>")
+ call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_with_linebreaks_1', {})
call StopVimInTerminal(buf)
endfunc
+function Test_tabpanel_tabonly()
+ CheckScreendump
+
+ let lines =<< trim END
+ tabnew
+ set showtabpanel=1
+ norm 100oasdf
+ vsplit
+ END
+ call writefile(lines, 'XTest_tabpanel_tabonly', 'D')
+
+ let buf = RunVimInTerminal('-S XTest_tabpanel_tabonly', {'rows': 10, 'cols': 80})
+ call VerifyScreenDump(buf, 'Test_tabpanel_only_0', {})
+ call term_sendkeys(buf, ":tabonly\<CR>")
+ call VerifyScreenDump(buf, 'Test_tabpanel_only_1', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab