Skip to content

Commit 651fca8

Browse files
committed
patch 8.2.3699: the +title feature adds a lot of #ifdef but little code
Problem: The +title feature adds a lot of #ifdef but little code. Solution: Graduate the +title feature.
1 parent 0c359af commit 651fca8

34 files changed

+56
-244
lines changed

runtime/doc/options.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4190,8 +4190,6 @@ A jump table for the options with a short description can be found at |Q_op|.
41904190
*'icon'* *'noicon'*
41914191
'icon' boolean (default off, on when title can be restored)
41924192
global
4193-
{not available when compiled without the |+title|
4194-
feature}
41954193
When on, the icon text of the window will be set to the value of
41964194
'iconstring' (if it is not empty), or to the name of the file
41974195
currently being edited. Only the last part of the name is used.
@@ -4208,8 +4206,6 @@ A jump table for the options with a short description can be found at |Q_op|.
42084206
*'iconstring'*
42094207
'iconstring' string (default "")
42104208
global
4211-
{not available when compiled without the |+title|
4212-
feature}
42134209
When this option is not empty, it will be used for the icon text of
42144210
the window. This happens only when the 'icon' option is on.
42154211
Only works if the terminal supports setting window icon text
@@ -8141,8 +8137,6 @@ A jump table for the options with a short description can be found at |Q_op|.
81418137
*'title'* *'notitle'*
81428138
'title' boolean (default off, on when title can be restored)
81438139
global
8144-
{not available when compiled without the |+title|
8145-
feature}
81468140
When on, the title of the window will be set to the value of
81478141
'titlestring' (if it is not empty), or to:
81488142
filename [+=-] (path) - VIM
@@ -8176,8 +8170,6 @@ A jump table for the options with a short description can be found at |Q_op|.
81768170
*'titlelen'*
81778171
'titlelen' number (default 85)
81788172
global
8179-
{not available when compiled without the |+title|
8180-
feature}
81818173
Gives the percentage of 'columns' to use for the length of the window
81828174
title. When the title is longer, only the end of the path name is
81838175
shown. A '<' character before the path name is used to indicate this.
@@ -8191,8 +8183,6 @@ A jump table for the options with a short description can be found at |Q_op|.
81918183
*'titleold'*
81928184
'titleold' string (default "Thanks for flying Vim")
81938185
global
8194-
{only available when compiled with the |+title|
8195-
feature}
81968186
This option will be used for the window title when exiting Vim if the
81978187
original title cannot be restored. Only happens if 'title' is on or
81988188
'titlestring' is not empty.
@@ -8201,8 +8191,6 @@ A jump table for the options with a short description can be found at |Q_op|.
82018191
*'titlestring'*
82028192
'titlestring' string (default "")
82038193
global
8204-
{not available when compiled without the |+title|
8205-
feature}
82068194
When this option is not empty, it will be used for the title of the
82078195
window. This happens only when the 'title' option is on.
82088196
Only works if the terminal supports setting window titles (currently

runtime/doc/various.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ N *+textobjects* |text-objects| selection
471471
N *+textprop* |text-properties|
472472
*+tgetent* non-Unix only: able to use external termcap
473473
N *+timers* the |timer_start()| function
474-
N *+title* Setting the window 'title' and 'icon'
474+
N *+title* Setting the window 'title' and 'icon'; Always enabled
475475
N *+toolbar* |gui-toolbar|
476476
T *+user_commands* User-defined commands. |user-commands|
477477
Always enabled since 8.1.1210.

src/alloc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,7 @@ free_all_mem(void)
421421
# endif
422422
}
423423

424-
# ifdef FEAT_TITLE
425424
free_titles();
426-
# endif
427425
# if defined(FEAT_SEARCHPATH)
428426
free_findfile();
429427
# endif

src/arglist.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -770,9 +770,7 @@ ex_argedit(exarg_T *eap)
770770

771771
if (do_arglist(eap->arg, AL_ADD, i, TRUE) == FAIL)
772772
return;
773-
#ifdef FEAT_TITLE
774773
maketitle();
775-
#endif
776774

777775
if (curwin->w_arg_idx == 0
778776
&& (curbuf->b_ml.ml_flags & ML_EMPTY)
@@ -792,9 +790,7 @@ ex_argadd(exarg_T *eap)
792790
do_arglist(eap->arg, AL_ADD,
793791
eap->addr_count > 0 ? (int)eap->line2 : curwin->w_arg_idx + 1,
794792
FALSE);
795-
#ifdef FEAT_TITLE
796793
maketitle();
797-
#endif
798794
}
799795

800796
/*
@@ -853,9 +849,7 @@ ex_argdelete(exarg_T *eap)
853849
}
854850
else
855851
do_arglist(eap->arg, AL_DEL, 0, FALSE);
856-
#ifdef FEAT_TITLE
857852
maketitle();
858-
#endif
859853
}
860854

861855
/*

src/autocmd.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,10 +2253,8 @@ apply_autocmds_group(
22532253
|| event == EVENT_VIMLEAVE
22542254
|| event == EVENT_VIMLEAVEPRE))
22552255
{
2256-
#ifdef FEAT_TITLE
22572256
if (curbuf->b_changed != save_changed)
22582257
need_maketitle = TRUE;
2259-
#endif
22602258
curbuf->b_changed = save_changed;
22612259
}
22622260

src/buffer.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ static int buf_same_ino(buf_T *buf, stat_T *stp);
4444
#else
4545
static int otherfile_buf(buf_T *buf, char_u *ffname);
4646
#endif
47-
#ifdef FEAT_TITLE
4847
static int value_changed(char_u *str, char_u **last);
49-
#endif
5048
static int append_arg_number(win_T *wp, char_u *buf, int buflen, int add_file);
5149
static void free_buffer(buf_T *);
5250
static void free_buffer_stuff(buf_T *buf, int free_options);
@@ -1856,9 +1854,7 @@ enter_buffer(buf_T *buf)
18561854
buflist_getfpos();
18571855

18581856
check_arg_idx(curwin); // check for valid arg_idx
1859-
#ifdef FEAT_TITLE
18601857
maketitle();
1861-
#endif
18621858
// when autocmds didn't change it
18631859
if (curwin->w_topline == 1 && !curwin->w_topline_was_set)
18641860
scroll_cursor_halfway(FALSE); // redisplay at correct position
@@ -3461,9 +3457,7 @@ buf_name_changed(buf_T *buf)
34613457

34623458
if (curwin->w_buffer == buf)
34633459
check_arg_idx(curwin); // check file name for arg list
3464-
#ifdef FEAT_TITLE
34653460
maketitle(); // set window title
3466-
#endif
34673461
status_redraw_all(); // status lines need to be redrawn
34683462
fmarks_check_names(buf); // check named file marks
34693463
ml_timestamp(buf); // reset timestamp
@@ -3780,7 +3774,6 @@ col_print(
37803774
vim_snprintf((char *)buf, buflen, "%d-%d", col, vcol);
37813775
}
37823776

3783-
#if defined(FEAT_TITLE) || defined(PROTO)
37843777
static char_u *lasttitle = NULL;
37853778
static char_u *lasticon = NULL;
37863779

@@ -4045,7 +4038,6 @@ free_titles(void)
40454038
}
40464039
# endif
40474040

4048-
#endif // FEAT_TITLE
40494041

40504042
#if defined(FEAT_STL_OPT) || defined(FEAT_GUI_TABLINE) || defined(PROTO)
40514043

src/bufwrite.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,9 +1630,7 @@ buf_write(
16301630
if (forceit && overwriting && vim_strchr(p_cpo, CPO_KEEPRO) == NULL)
16311631
{
16321632
buf->b_p_ro = FALSE;
1633-
#ifdef FEAT_TITLE
16341633
need_maketitle = TRUE; // set window title later
1635-
#endif
16361634
status_redraw_all(); // redraw status lines later
16371635
}
16381636

src/change.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,7 @@ changed_internal(void)
146146
ml_setflags(curbuf);
147147
check_status(curbuf);
148148
redraw_tabline = TRUE;
149-
#ifdef FEAT_TITLE
150149
need_maketitle = TRUE; // set window title later
151-
#endif
152150
}
153151

154152
#ifdef FEAT_EVAL
@@ -892,9 +890,7 @@ unchanged(buf_T *buf, int ff, int always_inc_changedtick)
892890
save_file_ff(buf);
893891
check_status(buf);
894892
redraw_tabline = TRUE;
895-
#ifdef FEAT_TITLE
896893
need_maketitle = TRUE; // set window title later
897-
#endif
898894
++CHANGEDTICK(buf);
899895
}
900896
else if (always_inc_changedtick)

src/drawscreen.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,15 +610,14 @@ showruler(int always)
610610
win_redr_ruler(curwin, always, FALSE);
611611
#endif
612612

613-
#ifdef FEAT_TITLE
614613
if (need_maketitle
615-
# ifdef FEAT_STL_OPT
614+
#ifdef FEAT_STL_OPT
616615
|| (p_icon && (stl_syntax & STL_IN_ICON))
617616
|| (p_title && (stl_syntax & STL_IN_TITLE))
618-
# endif
617+
#endif
619618
)
620619
maketitle();
621-
#endif
620+
622621
// Redraw the tab pages line if needed.
623622
if (redraw_tabline)
624623
draw_tabline();

src/evalfunc.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5787,13 +5787,7 @@ f_has(typval_T *argvars, typval_T *rettv)
57875787
0
57885788
#endif
57895789
},
5790-
{"title",
5791-
#ifdef FEAT_TITLE
5792-
1
5793-
#else
5794-
0
5795-
#endif
5796-
},
5790+
{"title", 1},
57975791
{"toolbar",
57985792
#ifdef FEAT_TOOLBAR
57995793
1

src/ex_cmds.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3082,9 +3082,7 @@ do_ecmd(
30823082
// Even when cursor didn't move we need to recompute topline.
30833083
changed_line_abv_curs();
30843084

3085-
#ifdef FEAT_TITLE
30863085
maketitle();
3087-
#endif
30883086
#if defined(FEAT_PROP_POPUP) && defined(FEAT_QUICKFIX)
30893087
if (WIN_IS_POPUP(curwin) && curwin->w_p_pvw && retval != FAIL)
30903088
popup_set_title(curwin);

src/ex_docmd.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6205,14 +6205,10 @@ ex_stop(exarg_T *eap)
62056205
out_flush();
62066206
stoptermcap();
62076207
out_flush(); // needed for SUN to restore xterm buffer
6208-
#ifdef FEAT_TITLE
62096208
mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles
6210-
#endif
62116209
ui_suspend(); // call machine specific function
6212-
#ifdef FEAT_TITLE
62136210
maketitle();
62146211
resettitle(); // force updating the title
6215-
#endif
62166212
starttermcap();
62176213
scroll_start(); // scroll screen before redrawing
62186214
redraw_later_clear();
@@ -7047,14 +7043,10 @@ do_exedit(
70477043
{
70487044
if (eap->do_ecmd_cmd != NULL)
70497045
do_cmd_argument(eap->do_ecmd_cmd);
7050-
#ifdef FEAT_TITLE
70517046
n = curwin->w_arg_idx_invalid;
7052-
#endif
70537047
check_arg_idx(curwin);
7054-
#ifdef FEAT_TITLE
70557048
if (n != curwin->w_arg_idx_invalid)
70567049
maketitle();
7057-
#endif
70587050
}
70597051

70607052
/*
@@ -8178,10 +8170,8 @@ ex_redraw(exarg_T *eap)
81788170
validate_cursor();
81798171
update_topline();
81808172
update_screen(eap->forceit ? CLEAR : VIsual_active ? INVERTED : 0);
8181-
#ifdef FEAT_TITLE
81828173
if (need_maketitle)
81838174
maketitle();
8184-
#endif
81858175
#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
81868176
# ifdef VIMDLL
81878177
if (!gui.in_use)

src/feature.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
* +insert_expand CTRL-N/CTRL-P/CTRL-X in insert mode.
110110
* +modify_fname modifiers for file name. E.g., "%:p:h".
111111
* +comments 'comments' option.
112+
* +title 'title' and 'icon' options
112113
*
113114
* Obsolete:
114115
* +tag_old_static Old style static tags: "file:tag file ..".
@@ -360,24 +361,21 @@
360361
#endif
361362

362363
/*
363-
* +title 'title' and 'icon' options
364364
* +statusline 'statusline', 'rulerformat' and special format of
365365
* 'titlestring' and 'iconstring' options.
366-
* +byte_offset '%o' in 'statusline' and builtin functions line2byte()
367-
* and byte2line().
368-
* Note: Required for Macintosh.
369366
*/
370-
#if defined(FEAT_NORMAL)
371-
# define FEAT_TITLE
372-
#endif
373-
374367
#ifdef FEAT_NORMAL
375368
# define FEAT_STL_OPT
376369
# ifndef FEAT_CMDL_INFO
377370
# define FEAT_CMDL_INFO // 'ruler' is required for 'statusline'
378371
# endif
379372
#endif
380373

374+
/*
375+
* +byte_offset '%o' in 'statusline' and builtin functions line2byte()
376+
* and byte2line().
377+
* Note: Required for Macintosh.
378+
*/
381379
#ifdef FEAT_NORMAL
382380
# define FEAT_BYTEOFF
383381
#endif

src/globals.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,7 @@ EXTERN int no_wait_return INIT(= 0); // don't wait for return for now
252252
EXTERN int need_wait_return INIT(= 0); // need to wait for return later
253253
EXTERN int did_wait_return INIT(= FALSE); // wait_return() was used and
254254
// nothing written since then
255-
#ifdef FEAT_TITLE
256255
EXTERN int need_maketitle INIT(= TRUE); // call maketitle() soon
257-
#endif
258256

259257
EXTERN int quit_more INIT(= FALSE); // 'q' hit at "--more--" msg
260258
#if defined(UNIX) || defined(VMS) || defined(MACOS_X)
@@ -1037,17 +1035,26 @@ EXTERN vimconv_T output_conv; // type of output conversion
10371035
*/
10381036
// length of char in bytes, including following composing chars
10391037
EXTERN int (*mb_ptr2len)(char_u *p) INIT(= latin_ptr2len);
1038+
10401039
// idem, with limit on string length
10411040
EXTERN int (*mb_ptr2len_len)(char_u *p, int size) INIT(= latin_ptr2len_len);
1041+
10421042
// byte length of char
10431043
EXTERN int (*mb_char2len)(int c) INIT(= latin_char2len);
1044-
// convert char to bytes, return the length
1044+
1045+
// Convert char "c" to bytes in "buf", return the length. "buf" must have room
1046+
// for at least 6 bytes.
10451047
EXTERN int (*mb_char2bytes)(int c, char_u *buf) INIT(= latin_char2bytes);
1048+
10461049
EXTERN int (*mb_ptr2cells)(char_u *p) INIT(= latin_ptr2cells);
10471050
EXTERN int (*mb_ptr2cells_len)(char_u *p, int size) INIT(= latin_ptr2cells_len);
10481051
EXTERN int (*mb_char2cells)(int c) INIT(= latin_char2cells);
10491052
EXTERN int (*mb_off2cells)(unsigned off, unsigned max_off) INIT(= latin_off2cells);
10501053
EXTERN int (*mb_ptr2char)(char_u *p) INIT(= latin_ptr2char);
1054+
1055+
// Byte offset from "p" to the start of a character, including any composing
1056+
// characters. "base" must be the start of the string, which must be NUL
1057+
// terminated.
10511058
EXTERN int (*mb_head_off)(char_u *base, char_u *p) INIT(= latin_head_off);
10521059

10531060
# if defined(USE_ICONV) && defined(DYNAMIC_ICONV)
@@ -1402,7 +1409,7 @@ EXTERN struct subs_expr_S *substitute_instr INIT(= NULL);
14021409
// table to store parsed 'wildmode'
14031410
EXTERN char_u wim_flags[4];
14041411

1405-
#if defined(FEAT_TITLE) && defined(FEAT_STL_OPT)
1412+
#if defined(FEAT_STL_OPT)
14061413
// whether titlestring and iconstring contains statusline syntax
14071414
# define STL_IN_ICON 1
14081415
# define STL_IN_TITLE 2

0 commit comments

Comments
 (0)