mirror of
https://github.com/neovim/neovim.git
synced 2024-12-31 17:13:26 -07:00
options,tui: don't hardcode default terminal size
also, include some checks.
This commit is contained in:
parent
5732340c20
commit
a95a5ba839
@ -59,7 +59,7 @@
|
||||
/* Values for "starting" */
|
||||
#define NO_SCREEN 2 /* no screen updating yet */
|
||||
#define NO_BUFFERS 1 /* not all buffers loaded yet */
|
||||
/* 0 not starting anymore */
|
||||
/* 0 not starting anymore */
|
||||
|
||||
/*
|
||||
* Number of Rows and Columns in the screen.
|
||||
@ -68,12 +68,16 @@
|
||||
* They may have different values when the screen wasn't (re)allocated yet
|
||||
* after setting Rows or Columns (e.g., when starting up).
|
||||
*/
|
||||
|
||||
#define DFLT_COLS 80 /* default value for 'columns' */
|
||||
#define DFLT_ROWS 24 /* default value for 'lines' */
|
||||
|
||||
EXTERN long Rows /* nr of rows in the screen */
|
||||
#ifdef DO_INIT
|
||||
= 24L
|
||||
= DFLT_ROWS
|
||||
#endif
|
||||
;
|
||||
EXTERN long Columns INIT(= 80); /* nr of columns in the screen */
|
||||
EXTERN long Columns INIT(= DFLT_COLS); /* nr of columns in the screen */
|
||||
|
||||
/*
|
||||
* The characters and attributes cached for the screen.
|
||||
|
@ -537,7 +537,7 @@ static vimoption_T
|
||||
{(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
|
||||
{"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
|
||||
(char_u *)&Columns, PV_NONE,
|
||||
{(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
|
||||
{(char_u *)DFLT_COLS, (char_u *)0L} SCRIPTID_INIT},
|
||||
{"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP|
|
||||
P_CURSWANT,
|
||||
(char_u *)&p_com, PV_COM,
|
||||
@ -1025,7 +1025,7 @@ static vimoption_T
|
||||
{"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
|
||||
(char_u *)&Rows, PV_NONE,
|
||||
{
|
||||
(char_u *)24L,
|
||||
(char_u *)DFLT_ROWS,
|
||||
(char_u *)0L
|
||||
} SCRIPTID_INIT},
|
||||
{"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <uv.h>
|
||||
#include <unibilium.h>
|
||||
@ -648,7 +649,9 @@ static void update_size(UI *ui)
|
||||
int width = 0, height = 0;
|
||||
|
||||
// 1 - look for non-default 'columns' and 'lines' options during startup
|
||||
if (starting && (Columns != 80 || Rows != 24)) {
|
||||
if (starting != 0 && (Columns != DFLT_COLS || Rows != DFLT_ROWS)) {
|
||||
assert(Columns >= INT_MIN && Columns <= INT_MAX);
|
||||
assert(Rows >= INT_MIN && Rows <= INT_MAX);
|
||||
width = (int)Columns;
|
||||
height = (int)Rows;
|
||||
goto end;
|
||||
@ -675,9 +678,9 @@ static void update_size(UI *ui)
|
||||
|
||||
end:
|
||||
if (width <= 0 || height <= 0) {
|
||||
// use a default of 80x24
|
||||
width = 80;
|
||||
height = 24;
|
||||
// use the defaults
|
||||
width = DFLT_COLS;
|
||||
height = DFLT_ROWS;
|
||||
}
|
||||
|
||||
ui->width = width;
|
||||
|
Loading…
Reference in New Issue
Block a user