Add window_columns() function to determine number of columns used for splitting window output
Replaces two open-coded versions of the same pattern.
This commit is contained in:
parent
eb14b44413
commit
14a501bd04
|
@ -37,6 +37,7 @@
|
|||
Window *BX_new_window (struct ScreenStru *);
|
||||
void BX_delete_window (Window *);
|
||||
void BX_add_to_invisible_list (Window *);
|
||||
int window_columns(Window *window);
|
||||
Window *BX_add_to_window_list (struct ScreenStru *, Window *);
|
||||
void BX_remove_from_window_from_screen (Window *);
|
||||
void BX_recalculate_window_positions (struct ScreenStru *);
|
||||
|
|
|
@ -6308,12 +6308,9 @@ BUILT_IN_FUNCTION(function_numlines, input)
|
|||
char *s = NULL;
|
||||
if (input && *input)
|
||||
{
|
||||
int cols;
|
||||
int cols = window_columns(current_window);
|
||||
|
||||
s = LOCAL_COPY(input);
|
||||
if (current_window->screen)
|
||||
cols = current_window->screen->co;
|
||||
else
|
||||
cols = current_window->columns;
|
||||
for (lines = split_up_line(s, cols + 1); *lines; lines++)
|
||||
count++;
|
||||
}
|
||||
|
|
|
@ -218,10 +218,7 @@ void BX_add_to_window(Window *window, const char *str)
|
|||
display_standout(OFF);
|
||||
display_bold(OFF);
|
||||
|
||||
if (window->screen)
|
||||
cols = window->screen->co;
|
||||
else
|
||||
cols = window->columns;
|
||||
cols = window_columns(window);
|
||||
|
||||
for (lines = split_up_line(str, cols/* + 1*/); *lines; lines++)
|
||||
{
|
||||
|
|
|
@ -427,6 +427,18 @@ void BX_add_to_invisible_list(Window *window)
|
|||
window->screen = NULL;
|
||||
}
|
||||
|
||||
/* window_columns()
|
||||
*
|
||||
* Returns the number of columns in the window for wrapping output. For
|
||||
* visible windows, this is the number of columns on the screen; for
|
||||
* invisible windows, this is the saved size the window had when it was last
|
||||
* visible.
|
||||
*/
|
||||
int window_columns(Window *window)
|
||||
{
|
||||
return window->screen ? window->screen->co : window->columns;
|
||||
}
|
||||
|
||||
/*
|
||||
* add_to_window_list: This inserts the given window into the visible window
|
||||
* list (and thus adds it to the displayed windows on the screen). The
|
||||
|
|
Loading…
Reference in New Issue