[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: setterm, without settleds
From: " Alastor \"CrazyEyes\" Santamaria" <alastors () gmail ! com>
Date: 2005-09-30 23:07:02
Message-ID: 2523efca0509301607x4f347cc0i () mail ! gmail ! com
[Download RAW message or body]
,,,,,
(o o)
*******************oOO**(_)**OOo***************
Finnaly, it's working, it doesn't have the setleds thing because it
didn't worked,
the terminal ended really weird and only reset turn it back to normal.
does anyonem has problems if I use ioctl's ? because that's what the
real setleds use. spite the man page sais ioctl's can change witout
warning.
but is not a real issue for me, maybe I just use gnu setleds because
it doesn't use ncurses like setterm, (that was the reason I coded this
setterm in the first place).
ok, opinions will be apreciated.
come on, critics to, don't be shy.
.oooO Oooo.
*******************( )****( )****************
\ ( ) /
\_) (_/
No corrijas al necio no sea cosa que te odie, corrije al sabio y te lo
agradecera.
Al que a buen =E1rbol se arrima buena sombra lo cobija.
Lo mejor que podemos hacer por otro no es s=F3lo compartir con =E9l
nuestras riquezas, sino mostrarle las suyas.
Atentamente Alastor
["SETTERM.DIFF" (text/plain)]
diff -urN busybox-1.01/console-tools/Config.in bb/console-tools/Config.in
--- busybox-1.01/console-tools/Config.in 2005-08-16 21:29:12.000000000 -0400
+++ bb/console-tools/Config.in 2003-01-03 08:22:40.000000000 -0500
@@ -65,4 +65,10 @@
This program loads entries into the kernel's scancode-to-keycode
map, allowing unusual keyboards to generate usable keycodes.
+config CONFIG_SETTERM
+ bool "setterm"
+ default n
+ help
+ This program manipulates the screen colors and other nice things.
+
endmenu
diff -urN busybox-1.01/console-tools/Makefile.in bb/console-tools/Makefile.in
--- busybox-1.01/console-tools/Makefile.in 2005-08-16 21:29:12.000000000 -0400
+++ bb/console-tools/Makefile.in 2005-09-13 15:28:37.000000000 -0400
@@ -33,6 +33,7 @@
CONSOLETOOLS_DIR-$(CONFIG_OPENVT) += openvt.o
CONSOLETOOLS_DIR-$(CONFIG_RESET) += reset.o
CONSOLETOOLS_DIR-$(CONFIG_SETKEYCODES) += setkeycodes.o
+CONSOLETOOLS_DIR-$(CONFIG_SETTERM) += setterm.o
libraries-y+=$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR)
diff -urN busybox-1.01/console-tools/setterm.c bb/console-tools/setterm.c
--- busybox-1.01/console-tools/setterm.c 1969-12-31 19:00:00.000000000 -0500
+++ bb/console-tools/setterm.c 2003-01-03 17:51:09.000000000 -0500
@@ -0,0 +1,101 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * setterm mini-implementation for busybox
+ *
+ * Copyright (c) 2005
+ * Mario Santamaria <Alastor@ufasta.edu.ar>
+ *
+ * Under GNU GPL
+ *
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "busybox.h"
+
+unsigned int which_option ( const char *opt_act, const char *options[] ) {
+ int i = 1;
+
+ while ((options[0]) != NULL ) {
+
+ if (strncmp( opt_act, options[0], strlen(options[0])) == 0)
+ //maybe replace this with a touched strcmp
+ return i;
+
+ options++;
+ i++;
+ }
+
+ return 0;
+}
+
+int setterm_main ( int argc, char **argv ) {
+
+ int opt;
+ char *bfopt[2];
+ llist_t *mod_listopt = NULL;
+ const char *gro_options[] = {
+ {"black"},
+ {"red"},
+ {"green"},
+ {"yellow"},
+ {"blue"},
+ {"magenta"},
+ {"cyan"},
+ {"white"},
+ {NULL}
+ };
+ const char *mod_options[] = {
+ {"bold"},
+ {"dark"},
+ {"store"},
+ {"underline"},
+ {"blink"},
+ {NULL}
+ };
+
+ bb_opt_complementaly = "m*";
+ opt = bb_getopt_ulflags(argc, argv, "b:f:m:", &bfopt[1], &bfopt[0], &mod_listopt );
+
+ if ( opt & 0x07 ) { //change terminal settings
+
+ char setings[20];
+ int store_flag = 0;
+ unsigned int i, the_option;
+ char *act = setings;
+
+ for ( i = 0 ; i < 2 ; i++ ) {
+ if ( opt & (i+1) ) {
+ the_option = which_option( bfopt[i], gro_options );
+ if ( the_option )
+ act += sprintf( act, "%d;", 29 + the_option + 10 * i);
+ else
+ bb_show_usage();
+ }
+ }
+
+ for ( ; mod_listopt != NULL ; mod_listopt = mod_listopt->link ) {
+ if (( the_option = which_option( mod_listopt->data, mod_options )) > 5 )
+ bb_show_usage();
+
+ if ( the_option == 3 )
+ store_flag = 1;
+ else
+ act += sprintf( act, "0%c;", (the_option + '0'));
+ }
+
+ (*(act - 1)) = 'm';
+ (* act) = '\0';
+ printf( "\033[%s" , setings);
+ if ( store_flag )
+ printf("\033[8]");
+
+ } else //reset
+ printf( "\033[0m");
+
+ return 0;
+
+}
+
diff -urN busybox-1.01/include/applets.h bb/include/applets.h
--- busybox-1.01/include/applets.h 2005-08-16 21:29:15.000000000 -0400
+++ bb/include/applets.h 2005-09-13 15:30:05.000000000 -0400
@@ -505,6 +505,9 @@
#ifdef CONFIG_SETKEYCODES
APPLET(setkeycodes, setkeycodes_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
#endif
+#ifdef CONFIG_SETTERM
+ APPLET(setterm, setterm_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
+#endif
#if defined(CONFIG_FEATURE_SH_IS_ASH) && defined(CONFIG_ASH)
APPLET_NOUSAGE("sh", ash_main, _BB_DIR_BIN, _BB_SUID_NEVER)
#elif defined(CONFIG_FEATURE_SH_IS_HUSH) && defined(CONFIG_HUSH)
diff -urN busybox-1.01/include/usage.h bb/include/usage.h
--- busybox-1.01/include/usage.h 2005-08-16 21:29:15.000000000 -0400
+++ bb/include/usage.h 2003-01-03 08:22:05.000000000 -0500
@@ -2132,6 +2132,21 @@
#define setkeycodes_example_usage \
"$ setkeycodes e030 127\n"
+#define setterm_trivial_usage \
+ "Change terminal setttings"
+#define setterm_full_usage \
+ "setterm\n" \
+ " [ -b black|red|green|yellow|blue|magenta|cyan|white ]\n" \
+ " sets the background\n" \
+ " [ -f black|red|green|yellow|blue|magenta|cyan|white ]\n" \
+ " sets the foreground\n" \
+ " [ -m blink|bold|dark|store|underline ]\n" \
+ " modify this\n" \
+ "setterm\n" \
+ " reset terminal settings\n"
+#define setterm_example_usage \
+ "\n\n$ setterm -f green -b black -m store\n"
+
#define lash_trivial_usage \
"[FILE]...\n" \
"or: sh -c command [args]..."
_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic