Commits

Ilya Arkhipov  committed 209f6b3

6 its a magic border value ^_^ it include all spaces with border, button spaces, etc

  • Participants
  • Parent commits 8b0ad6e

Comments (0)

Files changed (3)

File dialog4ports.c

 			err(EXIT_FAILURE, "Need more memory!");
 	}
 
-	/* XXX: add more checks */
 	(*items)[list_no].name = strdup(name);
 	(*items)[list_no].text = strdup(text);
 	(*items)[list_no].state = state;
 	char buf[256];
 	int i, res, ch;
 	int align_center = 0;
-	int height = 0, width = 80; // default value
+	int height = 0, width = 80; // default values
 	int min_height = 0;
 	char *helpfile;
 	dialog_mixedlist* items;
 	temp = getenv("D4PMINHEIGHT");
 	if (temp != NULL && height == 0) {
 		errno = 0;
-		/*
-		 * 6 it is magic number, it include all borders
-		 * buttons space etc.
-		 * */
-		min_height = strtol(temp, NULL, 0) + 6;
+		min_height = strtol(temp, NULL, 0) + MAGIC_BORDER;
 		if (errno != 0)
 			min_height = 0;
 	}
 	dlg_clear();
 	res = mixedlist_show(buf, "", height, min_height, width, items, align_center);
 
+	err(EXIT_FAILURE, "%d", res);
 	if (res == 0) {
 		/* return all active items */
 		for (i = 0; i < list_no; i++) {
 		else
 			*list_height = rows - (*height);
 	}
-	(*height) = (*list_height) + 6; // XXX: add checks for prompt
+	(*height) = (*list_height) + MAGIC_BORDER; // XXX: add checks for prompt
 }
 
 static void
 
 			if ((int) strlen(items->name) > indx[1]) {
 				limit = dlg_limit_columns(items->name,
-						(item_x - check_x - 6), 1);
+						(item_x - check_x - MAGIC_BORDER), 1);
 				if (limit > 1) {
 					wattrset(win, selected ? tag_selected_attr : tag_attr);
 					waddnstr(win,
 	wattrset(dialog, dialog_attr);
 	dlg_print_autowrap(dialog, prompt, height, width);
 
-	list_width = width - 6;
+	list_width = width - MAGIC_BORDER;
 	getyx(dialog, cur_y, cur_x);
 	box_y = cur_y + 1;
 	box_x = (width - list_width) / 2 - 1;
 	 * one or both of them.  If the name is no wider than 1/4 of the list,
 	 * leave it intact.
 	 */
-	use_width = (list_width - 6);
+	use_width = (list_width - MAGIC_BORDER);
 	if (text_width + name_width > use_width) {
 		int need = (int) (0.25 * use_width);
 		if (name_width > need) {
 	} else {
 		check_x = 1;
 	}
-	item_x = name_width + check_x + 6;
+	item_x = name_width + check_x + MAGIC_BORDER;
 
 	/* ensure we are scrolled to show the current choice */
 	if (choice >= (max_choice + scrollamt)) {
 #define CTRL_R				18
 #define F1					265
 
+/* Include all borders, buttons spaces etc.. in dialog window */
+#define MAGIC_BORDER		6
+
 typedef struct {
         char *name;
         char *text;
         bool new;
 } dialog_mixedlist;
 
-/*
- *	List of items
- */
+/* List of items */
 #define ITEM_CHECK			1
 #define ITEM_RADIO			2
 #define ITEM_SEPARATOR		3