mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
buffer: Beautify code a bit
This commit is contained in:
parent
1fc09b5b98
commit
414ef75ee6
@ -22,6 +22,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include "nvim/api/private/handle.h"
|
#include "nvim/api/private/handle.h"
|
||||||
#include "nvim/api/private/helpers.h"
|
#include "nvim/api/private/helpers.h"
|
||||||
@ -2913,7 +2914,6 @@ void maketitle(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t_str = buf;
|
|
||||||
if (*p_titlestring != NUL) {
|
if (*p_titlestring != NUL) {
|
||||||
if (stl_syntax & STL_IN_TITLE) {
|
if (stl_syntax & STL_IN_TITLE) {
|
||||||
int use_sandbox = FALSE;
|
int use_sandbox = FALSE;
|
||||||
@ -2921,43 +2921,48 @@ void maketitle(void)
|
|||||||
|
|
||||||
use_sandbox = was_set_insecurely((char_u *)"titlestring", 0);
|
use_sandbox = was_set_insecurely((char_u *)"titlestring", 0);
|
||||||
called_emsg = FALSE;
|
called_emsg = FALSE;
|
||||||
build_stl_str_hl(curwin, t_str, sizeof(buf),
|
build_stl_str_hl(curwin, buf, sizeof(buf),
|
||||||
p_titlestring, use_sandbox,
|
p_titlestring, use_sandbox,
|
||||||
0, maxlen, NULL, NULL);
|
0, maxlen, NULL, NULL);
|
||||||
if (called_emsg)
|
t_str = buf;
|
||||||
set_string_option_direct((char_u *)"titlestring", -1,
|
if (called_emsg) {
|
||||||
(char_u *)"", OPT_FREE, SID_ERROR);
|
set_string_option_direct((char_u *)"titlestring", -1, (char_u *)"",
|
||||||
|
OPT_FREE, SID_ERROR);
|
||||||
|
}
|
||||||
called_emsg |= save_called_emsg;
|
called_emsg |= save_called_emsg;
|
||||||
} else
|
} else {
|
||||||
t_str = p_titlestring;
|
t_str = p_titlestring;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* format: "fname + (path) (1 of 2) - VIM" */
|
/* format: "fname + (path) (1 of 2) - VIM" */
|
||||||
|
|
||||||
#define SPACE_FOR_FNAME (IOSIZE - 100)
|
#define SPACE_FOR_FNAME (sizeof(buf) - 100)
|
||||||
#define SPACE_FOR_DIR (IOSIZE - 20)
|
#define SPACE_FOR_DIR (sizeof(buf) - 20)
|
||||||
#define SPACE_FOR_ARGNR (IOSIZE - 10) /* at least room for " - VIM" */
|
#define SPACE_FOR_ARGNR (sizeof(buf) - 10) // At least room for " - VIM"
|
||||||
if (curbuf->b_fname == NULL)
|
if (curbuf->b_fname == NULL) {
|
||||||
STRLCPY(buf, _("[No Name]"), SPACE_FOR_FNAME + 1);
|
STRLCPY(buf, _("[No Name]"), SPACE_FOR_FNAME + 1);
|
||||||
else {
|
} else {
|
||||||
p = transstr(path_tail(curbuf->b_fname));
|
p = transstr(path_tail(curbuf->b_fname));
|
||||||
STRLCPY(buf, p, SPACE_FOR_FNAME + 1);
|
STRLCPY(buf, p, SPACE_FOR_FNAME + 1);
|
||||||
xfree(p);
|
xfree(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (bufIsChanged(curbuf)
|
switch (bufIsChanged(curbuf)
|
||||||
+ (curbuf->b_p_ro * 2)
|
| (curbuf->b_p_ro << 1)
|
||||||
+ (!MODIFIABLE(curbuf) * 4)) {
|
| (!MODIFIABLE(curbuf) << 2)) {
|
||||||
case 1: STRCAT(buf, " +"); break;
|
case 0: break;
|
||||||
case 2: STRCAT(buf, " ="); break;
|
case 1: STRCAT(buf, " +"); break;
|
||||||
case 3: STRCAT(buf, " =+"); break;
|
case 2: STRCAT(buf, " ="); break;
|
||||||
case 4:
|
case 3: STRCAT(buf, " =+"); break;
|
||||||
case 6: STRCAT(buf, " -"); break;
|
case 4:
|
||||||
case 5:
|
case 6: STRCAT(buf, " -"); break;
|
||||||
case 7: STRCAT(buf, " -+"); break;
|
case 5:
|
||||||
|
case 7: STRCAT(buf, " -+"); break;
|
||||||
|
default: assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curbuf->b_fname != NULL) {
|
if (curbuf->b_fname != NULL) {
|
||||||
/* Get path of file, replace home dir with ~ */
|
// Get path of file, replace home dir with ~.
|
||||||
off = (int)STRLEN(buf);
|
off = (int)STRLEN(buf);
|
||||||
buf[off++] = ' ';
|
buf[off++] = ' ';
|
||||||
buf[off++] = '(';
|
buf[off++] = '(';
|
||||||
@ -2998,6 +3003,10 @@ void maketitle(void)
|
|||||||
if (vim_strsize(buf) > maxlen)
|
if (vim_strsize(buf) > maxlen)
|
||||||
trunc_string(buf, buf, maxlen, IOSIZE);
|
trunc_string(buf, buf, maxlen, IOSIZE);
|
||||||
}
|
}
|
||||||
|
t_str = buf;
|
||||||
|
#undef SPACE_FOR_FNAME
|
||||||
|
#undef SPACE_FOR_DIR
|
||||||
|
#undef SPACE_FOR_ARGNR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mustset = ti_change(t_str, &lasttitle);
|
mustset = ti_change(t_str, &lasttitle);
|
||||||
|
Loading…
Reference in New Issue
Block a user