Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa7009d5 authored by Sam Ravnborg's avatar Sam Ravnborg
Browse files

kconfig: Add print_title helper in lxdialog



Simplify check for long title and use a helper function in util.c

Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
parent a06104af
Loading
Loading
Loading
Loading
+1 −14
Original line number Original line Diff line number Diff line
@@ -158,20 +158,7 @@ int dialog_checklist(const char *title, const char *prompt, int height,
	wattrset(dialog, dialog_attr);
	wattrset(dialog, dialog_attr);
	waddch(dialog, ACS_RTEE);
	waddch(dialog, ACS_RTEE);


	if (title != NULL && strlen(title) >= width - 2) {
	print_title(dialog, title, width);
		/* truncate long title -- mec */
		char *title2 = malloc(width - 2 + 1);
		memcpy(title2, title, width - 2);
		title2[width - 2] = '\0';
		title = title2;
	}

	if (title != NULL) {
		wattrset(dialog, title_attr);
		mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' ');
		waddstr(dialog, (char *)title);
		waddch(dialog, ' ');
	}


	wattrset(dialog, dialog_attr);
	wattrset(dialog, dialog_attr);
	print_autowrap(dialog, prompt, width - 2, 1, 3);
	print_autowrap(dialog, prompt, width - 2, 1, 3);
+1 −0
Original line number Original line Diff line number Diff line
@@ -145,6 +145,7 @@ void dialog_clear(void);
void color_setup(void);
void color_setup(void);
void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x);
void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x);
void print_button(WINDOW * win, const char *label, int y, int x, int selected);
void print_button(WINDOW * win, const char *label, int y, int x, int selected);
void print_title(WINDOW *dialog, const char *title, int width);
void draw_box(WINDOW * win, int y, int x, int height, int width, chtype box,
void draw_box(WINDOW * win, int y, int x, int height, int width, chtype box,
	      chtype border);
	      chtype border);
void draw_shadow(WINDOW * win, int y, int x, int height, int width);
void draw_shadow(WINDOW * win, int y, int x, int height, int width);
+1 −14
Original line number Original line Diff line number Diff line
@@ -66,20 +66,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
	wattrset(dialog, dialog_attr);
	wattrset(dialog, dialog_attr);
	waddch(dialog, ACS_RTEE);
	waddch(dialog, ACS_RTEE);


	if (title != NULL && strlen(title) >= width - 2) {
	print_title(dialog, title, width);
		/* truncate long title -- mec */
		char *title2 = malloc(width - 2 + 1);
		memcpy(title2, title, width - 2);
		title2[width - 2] = '\0';
		title = title2;
	}

	if (title != NULL) {
		wattrset(dialog, title_attr);
		mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' ');
		waddstr(dialog, (char *)title);
		waddch(dialog, ' ');
	}


	wattrset(dialog, dialog_attr);
	wattrset(dialog, dialog_attr);
	print_autowrap(dialog, prompt, width - 2, 1, 3);
	print_autowrap(dialog, prompt, width - 2, 1, 3);
+1 −14
Original line number Original line Diff line number Diff line
@@ -189,20 +189,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width,
	wbkgdset(dialog, dialog_attr & A_COLOR);
	wbkgdset(dialog, dialog_attr & A_COLOR);
	waddch(dialog, ACS_RTEE);
	waddch(dialog, ACS_RTEE);


	if (title != NULL && strlen(title) >= width - 2) {
	print_title(dialog, title, width);
		/* truncate long title -- mec */
		char *title2 = malloc(width - 2 + 1);
		memcpy(title2, title, width - 2);
		title2[width - 2] = '\0';
		title = title2;
	}

	if (title != NULL) {
		wattrset(dialog, title_attr);
		mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' ');
		waddstr(dialog, (char *)title);
		waddch(dialog, ' ');
	}


	wattrset(dialog, dialog_attr);
	wattrset(dialog, dialog_attr);
	print_autowrap(dialog, prompt, width - 2, 1, 3);
	print_autowrap(dialog, prompt, width - 2, 1, 3);
+1 −13
Original line number Original line Diff line number Diff line
@@ -42,20 +42,8 @@ int dialog_msgbox(const char *title, const char *prompt, int height, int width,


	draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
	draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);


	if (title != NULL && strlen(title) >= width - 2) {
	print_title(dialog, title, width);
		/* truncate long title -- mec */
		char *title2 = malloc(width - 2 + 1);
		memcpy(title2, title, width - 2);
		title2[width - 2] = '\0';
		title = title2;
	}


	if (title != NULL) {
		wattrset(dialog, title_attr);
		mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' ');
		waddstr(dialog, (char *)title);
		waddch(dialog, ' ');
	}
	wattrset(dialog, dialog_attr);
	wattrset(dialog, dialog_attr);
	print_autowrap(dialog, prompt, width - 2, 1, 2);
	print_autowrap(dialog, prompt, width - 2, 1, 2);


Loading