# Adds support for the 'goto' and 'tab' commands to facilitate # text positioning. diff -Naurp torsmo-0.18-orig/README torsmo-0.18/README --- torsmo-0.18-orig/README 2005-09-17 23:17:42.000000000 +0200 +++ torsmo-0.18/README 2005-09-17 23:38:34.000000000 +0200 @@ -140,6 +140,8 @@ system available for users. fs_size (fs) File system size fs_used (fs) File system used space + goto x The next letter will be printed at + position 'x'. hr (height) Horizontal line, height is the height in pixels i2c (dev), type, n I2C sensor from sysfs (Linux 2.6). @@ -181,6 +183,8 @@ swapmax Total amount of swap swapperc Percentage of swap in use sysname System name, Linux for example + tab (width, (start)) Puts a tab of the specified width, + starting from column 'start'. time (format) Local time, see man strftime to get more information about format. Cf. utime. diff -Naurp torsmo-0.18-orig/torsmo.c torsmo-0.18/torsmo.c --- torsmo-0.18-orig/torsmo.c 2005-09-17 23:17:42.000000000 +0200 +++ torsmo-0.18/torsmo.c 2005-09-17 23:44:25.000000000 +0200 @@ -162,6 +162,8 @@ enum { FG, BG, OUTLINE, + TAB, + GOTO, }; static struct special_t { @@ -227,6 +229,16 @@ static inline void new_outline(char *buf new_special(buf, OUTLINE)->arg = c; } +static inline void new_tab(char *buf, int a, int b) { + struct special_t *s = new_special(buf, TAB); + s->width = a; + s->arg = b; +} + +static inline void new_goto(char *buf, int a) { + new_special(buf, GOTO)->arg = a; +} + /* quite boring functions */ static inline void for_each_line(char *b, void (*f)(char *)) { @@ -303,6 +315,7 @@ enum text_object_type { OBJ_fs_size, OBJ_fs_used, OBJ_fs_used_perc, + OBJ_goto, OBJ_hr, OBJ_i2c, OBJ_kernel, @@ -335,6 +348,7 @@ enum text_object_type { OBJ_swapmax, OBJ_swapperc, OBJ_sysname, + OBJ_tab, OBJ_temp1, /* i2c is used instead in these */ OBJ_temp2, OBJ_text, @@ -588,6 +602,15 @@ static void construct_text_object(const if (!arg) arg = "/"; obj->data.fs = prepare_fs_stat(arg); END + OBJ(goto, 0) + if(!arg) { + ERR("goto needs arguments"); + obj->type = OBJ_text; + obj->data.s = strdup("${goto}"); + return; + } + obj->data.i = atoi(arg); + END OBJ(hr, 0) obj->data.i = arg ? atoi(arg) : 1; END @@ -703,6 +726,16 @@ static void construct_text_object(const END OBJ(sysname, 0) END + OBJ(tab, 0) + int a = 10, b = 0; + if(arg) { + if(sscanf(arg, "%d %d", &a, &b) != 2) + sscanf(arg, "%d", &b); + } + if (a <= 0) a = 1; + obj->data.pair.a = a; + obj->data.pair.b = b; + END OBJ(temp1, INFO_I2C) obj->type = OBJ_i2c; obj->data.i2c.fd = open_i2c_sensor(0, "temp", 1, &obj->data.i2c.arg); @@ -1014,6 +1047,9 @@ static void generate_text() { snprintf(p, n, "0"); } } + OBJ(goto) { + new_goto(p, obj->data.i); + } OBJ(loadavg) { float *v = info.loadavg; @@ -1104,6 +1140,9 @@ static void generate_text() { OBJ(outlinecolor) { new_outline(p, obj->data.l); } + OBJ(tab) { + new_tab(p, obj->data.pair.a, obj->data.pair.b); + } OBJ(processes) { snprintf(p, n, "%d", cur->procs); } @@ -1371,6 +1410,18 @@ static void draw_line(char *s) { /* draw special */ switch (specials[special_index].type) { + case TAB: + { + int start = specials[special_index].arg; + int step = specials[special_index].width; + if (!step || step < 0) + step = 10; + w = step - (cur_x - text_start_x - start) % step; + } + break; + case GOTO: + w = specials[special_index].arg - cur_x; + break; case HORIZONTAL_LINE: { int h = specials[special_index].height;