Browse Source

Remove term-set and support for special terminal font escapes

K. Lange 3 years ago
parent
commit
3f39c0ad61
5 changed files with 16 additions and 123 deletions
  1. 0 74
      apps/term-set.c
  2. 0 11
      apps/terminal-vga.c
  3. 16 21
      apps/terminal.c
  4. 0 3
      base/usr/include/toaru/termemu.h
  5. 0 14
      lib/termemu.c

+ 0 - 74
apps/term-set.c

@@ -1,74 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int main(int argc, char * argv[]) {
-	char * term = getenv("TERM");
-	if (!term || strstr(term, "toaru") != term) {
-		fprintf(stderr, "Unrecognized terminal. These commands are for the ToaruOS terminal only.\n");
-		return 1;
-	}
-	if (argc < 2) {
-		fprintf(stderr, "%s: expected argument\n", argv[0]);
-		return 1;
-	}
-
-	if (!strcmp(argv[1], "alpha")) {
-		if (argc < 3) {
-			fprintf(stderr, "%s %s [0 or 1]\n", argv[0], argv[1]);
-			return 1;
-		}
-		int i = atoi(argv[2]);
-		if (i) {
-			printf("\033[2001z");
-		} else {
-			printf("\033[2000z");
-		}
-		fflush(stdout);
-		return 0;
-	} else if (!strcmp(argv[1], "scale")) {
-		if (argc < 3) {
-			fprintf(stderr, "%s %s [floating point size, 1.0 = normal]\n", argv[0], argv[1]);
-			return 1;
-		}
-		printf("\033[1555;%sz", argv[2]);
-		fflush(stdout);
-		return 0;
-	} else if (!strcmp(argv[1], "gamma")) {
-		if (argc < 3) {
-			fprintf(stderr, "%s %s [floating point gamma, 1.7 = normal]\n", argv[0], argv[1]);
-			return 1;
-		}
-		printf("\033[1556;%sz", argv[2]);
-		fflush(stdout);
-		return 0;
-	} else if (!strcmp(argv[1], "sdf")) {
-		if (argc < 3) {
-			fprintf(stderr, "%s %s [sdf enabled, 1 = yes]\n", argv[0], argv[1]);
-			return 1;
-		}
-		printf("\033[1557;%sz", argv[2]);
-		fflush(stdout);
-		return 0;
-	} else if (!strcmp(argv[1], "size")) {
-		if (argc < 4) {
-			fprintf(stderr, "%s %s [width] [height]\n", argv[0], argv[1]);
-			return 1;
-		}
-		printf("\033[3000;%s;%sz", argv[2], argv[3]);
-		fflush(stdout);
-		return 0;
-	} else if (!strcmp(argv[1], "--help")) {
-		fprintf(stderr, "Available arguments:\n"
-		                "  alpha - alpha transparency enabled / disabled\n"
-		                "  scale - font scaling\n"
-		                "  size - terminal width/height in characters\n"
-		                "  gamma - SDF font gamma\n"
-		                "  sdf - whether SDF is enabled\n"
-		);
-		return 0;
-	}
-
-	fprintf(stderr, "%s: unrecognized argument\n", argv[0]);
-	return 1;
-}

+ 0 - 11
apps/terminal-vga.c

@@ -140,14 +140,6 @@ static int best_match(uint32_t a) {
 
 volatile int exit_application = 0;
 
-static void set_term_font_size(float s) {
-	/* do nothing */
-}
-
-static void set_term_font_mode(int i) {
-	/* do nothing */
-}
-
 /* Returns the lower of two shorts */
 uint16_t min(uint16_t a, uint16_t b) {
 	return (a < b) ? a : b;
@@ -907,14 +899,11 @@ term_callbacks_t term_callbacks = {
 	term_scroll,
 	term_redraw_cursor,
 	input_buffer_stuff,
-	set_term_font_size,
 	set_title,
 	unsupported,
 	unsupported_int,
 	unsupported_int,
 	term_set_csr_show,
-	set_term_font_size,
-	set_term_font_mode,
 };
 
 void reinit(int send_sig) {

+ 16 - 21
apps/terminal.c

@@ -146,22 +146,6 @@ static void display_flip(void) {
 	}
 }
 
-static void set_term_font_size(float s) {
-	scale_fonts  = 1;
-	font_scaling = s;
-	reinit(1);
-}
-
-static void set_term_font_gamma(float s) {
-	font_gamma = s;
-	reinit(1);
-}
-
-static void set_term_font_mode(int i) {
-	_use_sdf = i;
-	reinit(1);
-}
-
 /* Returns the lower of two shorts */
 int32_t min(int32_t a, int32_t b) {
 	return (a < b) ? a : b;
@@ -1450,14 +1434,11 @@ term_callbacks_t term_callbacks = {
 	term_scroll,
 	term_redraw_cursor,
 	input_buffer_stuff,
-	set_term_font_size,
 	set_title,
 	term_set_cell_contents,
 	term_get_cell_width,
 	term_get_cell_height,
 	term_set_csr_show,
-	set_term_font_gamma,
-	set_term_font_mode,
 };
 
 void reinit(int send_sig) {
@@ -1787,10 +1768,21 @@ void _menu_action_exit(struct MenuEntry * self) {
 	exit_application = 1;
 }
 
+static struct MenuEntry * _menu_toggle_borders_context = NULL;
+static struct MenuEntry * _menu_toggle_borders_bar = NULL;
+
 void _menu_action_hide_borders(struct MenuEntry * self) {
 	_no_frame = !(_no_frame);
 	window_width = window->width - decor_width() * (!_no_frame);
 	window_height = window->height - (decor_height() + menu_bar_height) * (!_no_frame);
+	menu_update_title(_menu_toggle_borders_context, _no_frame ? "Show borders" : "Hide borders");
+	menu_update_title(_menu_toggle_borders_bar, _no_frame ? "Show borders" : "Hide borders");
+	reinit(1);
+}
+
+void _menu_action_toggle_sdf(struct MenuEntry * self) {
+	_use_sdf = !(_use_sdf);
+	menu_update_title(self, _use_sdf ? "Bitmap font" : "Anti-aliased font");
 	reinit(1);
 }
 
@@ -1962,7 +1954,8 @@ int main(int argc, char ** argv) {
 	menu_insert(menu_right_click, _menu_copy);
 	menu_insert(menu_right_click, _menu_paste);
 	menu_insert(menu_right_click, menu_create_separator());
-	menu_insert(menu_right_click, menu_create_normal(NULL, NULL, "Toggle borders", _menu_action_hide_borders));
+	_menu_toggle_borders_context = menu_create_normal(NULL, NULL, _no_frame ? "Show borders" : "Hide borders", _menu_action_hide_borders);
+	menu_insert(menu_right_click, _menu_toggle_borders_context);
 	menu_insert(menu_right_click, menu_create_separator());
 	menu_insert(menu_right_click, _menu_exit);
 
@@ -1986,8 +1979,10 @@ int main(int argc, char ** argv) {
 	menu_set_insert(terminal_menu_bar.set, "zoom", m);
 
 	m = menu_create();
-	menu_insert(m, menu_create_normal(NULL, NULL, "Hide borders", _menu_action_hide_borders));
+	_menu_toggle_borders_bar = menu_create_normal(NULL, NULL, _no_frame ? "Show borders" : "Hide borders", _menu_action_hide_borders);
+	menu_insert(m, _menu_toggle_borders_bar);
 	menu_insert(m, menu_create_submenu(NULL,"zoom","Set zoom..."));
+	menu_insert(m, menu_create_normal(NULL, NULL, _use_sdf ? "Bitmap font" : "Anti-aliased font", _menu_action_toggle_sdf));
 	menu_set_insert(terminal_menu_bar.set, "view", m);
 
 	m = menu_create();

+ 0 - 3
base/usr/include/toaru/termemu.h

@@ -27,14 +27,11 @@ typedef struct {
 	void (*scroll)(int);
 	void (*redraw_cursor)(void);
 	void (*input_buffer_stuff)(char *);
-	void (*set_font_size)(float);
 	void (*set_title)(char *);
 	void (*set_cell_contents)(int,int,char *);
 	int  (*get_cell_width)(void);
 	int  (*get_cell_height)(void);
 	void (*set_csr_on)(int);
-	void (*set_font_gamma)(float);
-	void (*set_font_mode)(int);
 } term_callbacks_t;
 
 typedef struct {

+ 0 - 14
lib/termemu.c

@@ -181,20 +181,6 @@ static void _ansi_put(term_state_t * s, char c) {
 									case 1:
 										callbacks->redraw_cursor();
 										break;
-									case 1555:
-										if (argc > 1) {
-											callbacks->set_font_size(atof(argv[1]));
-										}
-										break;
-									case 1556:
-										if (argc > 1) {
-											callbacks->set_font_gamma(atof(argv[1]));
-										}
-										break;
-									case 1557:
-										if (argc > 1) {
-											callbacks->set_font_mode(atoi(argv[1]));
-										}
 									default:
 										break;
 								}