Commit: 017cb9bce003d519632563ff39e6d866ab73da02
Parent: 2adce5ffd6c96ecb6061d222e122a8bd77564849
Author: opask
Date: Thu, 23 Aug 2018 06:36:07 -0600
remove code for modifying terminal margins(job of the terminal emulator),
update TODO
Diffstat:
M | TODO | | | 2 | ++ |
M | default.c | | | 38 | +++++--------------------------------- |
M | menu.c | | | 115 | ------------------------------------------------------------------------------- |
M | terminal.c | | | 19 | ++++--------------- |
4 files changed, 11 insertions(+), 163 deletions(-)
diff --git a/TODO b/TODO
@@ -42,3 +42,5 @@
sites
- remove get_links_icon() in dip.c
+
+- remove remaining terminal margin modifying code
diff --git a/default.c b/default.c
@@ -114,21 +114,6 @@ static unsigned char *get_token(unsigned char **line)
return s;
}
-static int get_token_num(unsigned char **line)
-{
- long l;
- unsigned char *end;
- unsigned char *t = get_token(line);
- if (!t) return -1;
- l = strtolx(t, &end);
- if (*end || end == t || l < 0 || l != (int)l) {
- free(t);
- return -1;
- }
- free(t);
- return (int)l;
-}
-
static void parse_config_file(unsigned char *name, unsigned char *file, struct option **opt)
{
struct option *options;
@@ -689,7 +674,7 @@ static unsigned char *term_rd(struct option *o, unsigned char *c)
{
struct term_spec *ts;
unsigned char *w;
- int i, l;
+ int i;
if (!(w = get_token(&c))) goto err;
ts = new_term_spec(w);
free(w);
@@ -715,23 +700,10 @@ static unsigned char *term_rd(struct option *o, unsigned char *c)
goto err_f;
ts->character_set = i;
free(w);
- l = get_token_num(&c);
- if (l < 0) goto ret;
- if (l > 999) goto err;
- ts->left_margin = l;
- l = get_token_num(&c);
- if (l < 0) goto err;
- if (l > 999) goto err;
- ts->right_margin = l;
- l = get_token_num(&c);
- if (l < 0) goto err;
- if (l > 999) goto err;
- ts->top_margin = l;
- l = get_token_num(&c);
- if (l < 0) goto err;
- if (l > 999) goto err;
- ts->bottom_margin = l;
- ret:
+ ts->left_margin = 0;
+ ts->right_margin = 0;
+ ts->top_margin = 0;
+ ts->bottom_margin = 0;
return NULL;
err_f:
free(w);
diff --git a/menu.c b/menu.c
@@ -622,112 +622,6 @@ static void terminal_options(struct terminal *term, void *xxx, void *ses_)
do_dialog(term, d, getml(d, NULL));
}
-static unsigned char left_margin_str[5];
-static unsigned char right_margin_str[5];
-static unsigned char top_margin_str[5];
-static unsigned char bottom_margin_str[5];
-
-static void margins_ok(void *xxx)
-{
- struct terminal *term = xxx;
- int left, right, top, bottom;
- left = atoi(cast_const_char left_margin_str);
- right = atoi(cast_const_char right_margin_str);
- top = atoi(cast_const_char top_margin_str);
- bottom = atoi(cast_const_char bottom_margin_str);
- if (!F) {
- struct term_spec *ts = new_term_spec(term->term);
- if (left + right >= term->real_x ||
- top + bottom >= term->real_y) {
- goto error;
- }
- ts->left_margin = left;
- ts->right_margin = right;
- ts->top_margin = top;
- ts->bottom_margin = bottom;
- cls_redraw_all_terminals();
- }
- return;
-
-error:
- msg_box(
- term,
- NULL,
- TEXT_(T_MARGINS_TOO_LARGE),
- AL_CENTER,
- TEXT_(T_THE_ENTERED_VALUES_ARE_TOO_LARGE_FOR_THE_CURRENT_SCREEN), MSG_BOX_END,
- NULL,
- 1,
- TEXT_(T_CANCEL), msg_box_null, B_ENTER | B_ESC
- );
-}
-
-static unsigned char * const margins_labels[] = {
- TEXT_(T_LEFT_MARGIN),
- TEXT_(T_RIGHT_MARGIN),
- TEXT_(T_TOP_MARGIN),
- TEXT_(T_BOTTOM_MARGIN),
-};
-
-static void screen_margins(struct terminal *term, void *xxx, void *ses_)
-{
- struct dialog *d;
- struct term_spec *ts = term->spec;
- int string_len = !F ? 4 : 5;
- int max_value = !F ? 999 : 9999;
- int l = 0, r = 0, t = 0, b = 0;
- if (!F) {
- l = ts->left_margin;
- r = ts->right_margin;
- t = ts->top_margin;
- b = ts->bottom_margin;
- }
- snprint(left_margin_str, string_len, l);
- snprint(right_margin_str, string_len, r);
- snprint(top_margin_str, string_len, t);
- snprint(bottom_margin_str, string_len, b);
- d = mem_calloc(sizeof(struct dialog) + 6 * sizeof(struct dialog_item));
- d->title = TEXT_(T_SCREEN_MARGINS);
- d->fn = group_fn;
- d->udata = (void *)margins_labels;
- d->refresh = margins_ok;
- d->refresh_data = term;
- d->items[0].type = D_FIELD;
- d->items[0].dlen = string_len;
- d->items[0].data = left_margin_str;
- d->items[0].fn = check_number;
- d->items[0].gid = 0;
- d->items[0].gnum = max_value;
- d->items[1].type = D_FIELD;
- d->items[1].dlen = string_len;
- d->items[1].data = right_margin_str;
- d->items[1].fn = check_number;
- d->items[1].gid = 0;
- d->items[1].gnum = max_value;
- d->items[2].type = D_FIELD;
- d->items[2].dlen = string_len;
- d->items[2].data = top_margin_str;
- d->items[2].fn = check_number;
- d->items[2].gid = 0;
- d->items[2].gnum = max_value;
- d->items[3].type = D_FIELD;
- d->items[3].dlen = string_len;
- d->items[3].data = bottom_margin_str;
- d->items[3].fn = check_number;
- d->items[3].gid = 0;
- d->items[3].gnum = max_value;
- d->items[4].type = D_BUTTON;
- d->items[4].gid = B_ENTER;
- d->items[4].fn = ok_dialog;
- d->items[4].text = TEXT_(T_OK);
- d->items[5].type = D_BUTTON;
- d->items[5].gid = B_ESC;
- d->items[5].fn = cancel_dialog;
- d->items[5].text = TEXT_(T_CANCEL);
- d->items[6].type = D_END;
- do_dialog(term, d, getml(d, NULL));
-}
-
#ifndef G
static inline void reinit_video(void) { }
@@ -2950,10 +2844,6 @@ static const struct menu_item setup_menu_3[] = {
};
#endif
-static const struct menu_item setup_menu_4[] = {
- { TEXT_(T_SCREEN_MARGINS), cast_uchar "", TEXT_(T_HK_SCREEN_MARGINS), screen_margins, NULL, 0, 1 },
-};
-
static const struct menu_item setup_menu_5[] = {
{ TEXT_(T_NETWORK_OPTIONS), cast_uchar ">", TEXT_(T_HK_NETWORK_OPTIONS), network_menu, NULL, 1, 1 },
};
@@ -2985,7 +2875,6 @@ static void do_setup_menu(struct terminal *term, void *xxx, void *ses_)
#ifdef G
sizeof(setup_menu_3) +
#endif
- sizeof(setup_menu_4) +
sizeof(setup_menu_5) +
sizeof(setup_menu_6) +
sizeof(setup_menu_7) +
@@ -3001,10 +2890,6 @@ static void do_setup_menu(struct terminal *term, void *xxx, void *ses_)
e += sizeof(setup_menu_3) / sizeof(struct menu_item);
#endif
}
- if (!F) {
- memcpy(e, setup_menu_4, sizeof(setup_menu_4));
- e += sizeof(setup_menu_4) / sizeof(struct menu_item);
- }
if (!anonymous) {
memcpy(e, setup_menu_5, sizeof(setup_menu_5));
e += sizeof(setup_menu_5) / sizeof(struct menu_item);
diff --git a/terminal.c b/terminal.c
@@ -75,21 +75,10 @@ struct list_head terminals = {&terminals, &terminals};
static void set_margin(struct terminal *term)
{
- struct term_spec *ts = term->spec;
- if (term->real_x <= ts->left_margin + ts->right_margin) {
- term->left_margin = 0;
- term->x = term->real_x;
- } else {
- term->left_margin = ts->left_margin;
- term->x = term->real_x - (ts->left_margin + ts->right_margin);
- }
- if (term->real_y <= ts->top_margin + ts->bottom_margin) {
- term->top_margin = 0;
- term->y = term->real_y;
- } else {
- term->top_margin = ts->top_margin;
- term->y = term->real_y - (ts->top_margin + ts->bottom_margin);
- }
+ term->left_margin = 0;
+ term->x = term->real_x;
+ term->top_margin = 0;
+ term->y = term->real_y;
}