forked from github/server
fixed error with option window dimensions in gmtool
This commit is contained in:
parent
168e1d08d4
commit
7fd2852f3b
1 changed files with 12 additions and 3 deletions
|
@ -11,10 +11,13 @@
|
||||||
/* wenn platform.h nicht vor curses included wird, kompiliert es unter windows nicht */
|
/* wenn platform.h nicht vor curses included wird, kompiliert es unter windows nicht */
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
|
#include <kernel/config.h>
|
||||||
|
|
||||||
#include "listbox.h"
|
#include "listbox.h"
|
||||||
#include "gmtool_structs.h"
|
#include "gmtool_structs.h"
|
||||||
|
|
||||||
|
#include <util/log.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
@ -63,8 +66,8 @@ push_selection(list_selection ** p_sel, char * str, void * payload)
|
||||||
return p_sel;
|
return p_sel;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SX (stdscr->_maxx)
|
#define SX (getmaxx(stdscr))
|
||||||
#define SY (stdscr->_maxy)
|
#define SY (getmaxy(stdscr))
|
||||||
|
|
||||||
list_selection *
|
list_selection *
|
||||||
do_selection(list_selection * sel, const char * title, void (*perform)(list_selection *, void *), void * data)
|
do_selection(list_selection * sel, const char * title, void (*perform)(list_selection *, void *), void * data)
|
||||||
|
@ -79,11 +82,16 @@ do_selection(list_selection * sel, const char * title, void (*perform)(list_sele
|
||||||
for (s=sel;s;s=s->next) {
|
for (s=sel;s;s=s->next) {
|
||||||
if ((int)strlen(s->str)>width) width = (int)strlen(s->str);
|
if ((int)strlen(s->str)>width) width = (int)strlen(s->str);
|
||||||
++height;
|
++height;
|
||||||
|
if (verbosity>=5)
|
||||||
|
log_info((1, "s %s w %d h %d\n", s->str, width, height));
|
||||||
}
|
}
|
||||||
if (height==0 || width==0) return NULL;
|
if (height==0 || width==0) return NULL;
|
||||||
if (width+3>SX) width=SX-4;
|
if (width+3>SX) width=SX-4;
|
||||||
if (height+2>SY) height=SY-2;
|
if (height+2>SY) height=SY-2;
|
||||||
|
|
||||||
|
if (verbosity>=5)
|
||||||
|
log_info((1, "w %d h %d\n", width, height));
|
||||||
|
|
||||||
wn = newwin(height+2, width+4, (SY - height - 2) / 2, (SX - width - 4) / 2);
|
wn = newwin(height+2, width+4, (SY - height - 2) / 2, (SX - width - 4) / 2);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -95,6 +103,7 @@ do_selection(list_selection * sel, const char * title, void (*perform)(list_sele
|
||||||
waddnstr(wn, s->str, -1);
|
waddnstr(wn, s->str, -1);
|
||||||
wclrtoeol(wn);
|
wclrtoeol(wn);
|
||||||
}
|
}
|
||||||
|
wclrtobot(wn);
|
||||||
wxborder(wn);
|
wxborder(wn);
|
||||||
mvwprintw(wn, 0, 2, "[ %s ]", title);
|
mvwprintw(wn, 0, 2, "[ %s ]", title);
|
||||||
update = false;
|
update = false;
|
||||||
|
@ -104,7 +113,7 @@ do_selection(list_selection * sel, const char * title, void (*perform)(list_sele
|
||||||
wmove(wn, i + 1, 2);
|
wmove(wn, i + 1, 2);
|
||||||
waddstr(wn, "->");
|
waddstr(wn, "->");
|
||||||
wmove(wn, i + 1, 4);
|
wmove(wn, i + 1, 4);
|
||||||
waddnstr(wn, current->str, -1);
|
waddnstr(wn, current->str, width-2);
|
||||||
wattroff(wn, A_BOLD | COLOR_PAIR(COLOR_YELLOW));
|
wattroff(wn, A_BOLD | COLOR_PAIR(COLOR_YELLOW));
|
||||||
|
|
||||||
wrefresh(wn);
|
wrefresh(wn);
|
||||||
|
|
Loading…
Reference in a new issue