diff options
-rw-r--r-- | src/color.c | 2 | ||||
-rw-r--r-- | src/gram.y | 16 | ||||
-rw-r--r-- | src/pipe.c | 98 | ||||
-rw-r--r-- | src/pipe.h | 5 |
4 files changed, 112 insertions, 9 deletions
diff --git a/src/color.c b/src/color.c index fa1ed0a..f2dd405 100644 --- a/src/color.c +++ b/src/color.c @@ -40,7 +40,7 @@ void start_default_ucolors() { //ucolors[ DEFAULT ].bg = BLACK; ucolors[ HEADINGS ].fg = WHITE; ucolors[ HEADINGS ].bg = RED; - ucolors[ WELCOME ].fg = BLUE; + ucolors[ WELCOME ].fg = CYAN; ucolors[ WELCOME ].bg = BLACK; ucolors[ CELL_SELECTION ].fg = BLUE; // cell selection in headings ucolors[ CELL_SELECTION ].bg = WHITE; @@ -81,7 +81,6 @@ token S_INSERTCOL token S_OPENCOL token S_DELETECOL token S_YANKCOL -token S_GETFORMAT */ %token S_DATEFMT @@ -160,9 +159,6 @@ token S_GETFORMAT token S_PULLCOPY token S_WHEREAMI token S_FGETNUM - token S_GETSTRING - token S_GETEXP - token S_GETFMT token S_GETFRAME token S_GETRANGE token S_QUERY @@ -176,6 +172,10 @@ token S_GETFORMAT */ %token S_GETNUM +%token S_GETSTRING +%token S_GETEXP +%token S_GETFMT +%token S_GETFORMAT %token S_RECALC %token S_QUIT %token S_IMAP @@ -516,6 +516,14 @@ command: getnum($2.left.vp->row, $2.left.vp->col, $2.right.vp->row, $2.right.vp->col, fdoutput); } + | S_GETSTRING var_or_range { getstring($2.left.vp->row, $2.left.vp->col, $2.right.vp->row, $2.right.vp->col, fdoutput); } + + | S_GETEXP var_or_range { getexp($2.left.vp->row, $2.left.vp->col, $2.right.vp->row, $2.right.vp->col, fdoutput); } + + | S_GETFORMAT COL { getformat($2, fdoutput); } + + | S_GETFMT var_or_range { getfmt($2.left.vp->row, $2.left.vp->col, $2.right.vp->row, $2.right.vp->col, fdoutput); } + /* | S_SEVAL e { seval_result = seval($2); efree($2); @@ -1,9 +1,13 @@ +/* +Adaptation of Chuck Martin's code - <nrocinu@myrealbox.com> +*/ + #include <unistd.h> #include "sc.h" #include "conf.h" #include "main.h" -// FIXME pass fd is not neccesary? +// FIXME - pass fd is not neccesary? void getnum(int r0, int c0, int rn, int cn, FILE * fd) { struct ent ** pp; struct ent * p; @@ -29,16 +33,104 @@ void getnum(int r0, int c0, int rn, int cn, FILE * fd) { //if (get_conf_value("output") != NULL && fd != NULL) // fprintf(fd, "%s\n", line); //else - scdebug("resultado: %s", line); //fwrite(fd, line, strlen(line)); + scdebug("%s", line); + if (brokenpipe) { + linelim = -1; + return; + } + + } + } + linelim = -1; +} + +void getformat(int col, FILE * fd) { + sprintf(line, "%d %d %d\n", fwidth[col], precision[col], realfmt[col]); + //write(fd, line, strlen(line)); + scdebug("%s", line); + linelim = -1; +} + +void getfmt(int r0, int c0, int rn, int cn, FILE * fd) { + struct ent **pp; + int r, c; + + for (r = r0; r <= rn; r++) { + for (c = c0, pp = ATBL(tbl, r, c); c <= cn; pp++, c++) { + *line = '\0'; + if (*pp && (*pp)->format) sprintf(line, "%s", (*pp)->format); + + //if (c < cn) + // strcat(line, "\t"); + //else + // strcat(line, "\n"); + //write(fd, line, strlen(line)); + + scdebug("%s", line); + if (brokenpipe) { + linelim = -1; + return; + } + } + } + linelim = -1; +} + +void getstring(int r0, int c0, int rn, int cn, FILE * fd) { + struct ent **pp; + int r, c; + + for (r = r0; r <= rn; r++) { + for (c = c0, pp = ATBL(tbl, r, c); c <= cn; pp++, c++) { + *line = '\0'; + if (*pp && (*pp)->label) + sprintf(line, "%s", (*pp)->label); + //if (c < cn) + // strcat(line, "\t"); + //else + // strcat(line, "\n"); + //write(fd, line, strlen(line)); + + scdebug("%s", line); if (brokenpipe) { linelim = -1; return; } + } + } + linelim = -1; +} + +void getexp(int r0, int c0, int rn, int cn, FILE * fd) { + struct ent **pp; + struct ent *p; + int r, c; + for (r = r0; r <= rn; r++) { + for (c = c0, pp = ATBL(tbl, r, c); c <= cn; pp++, c++) { + *line = '\0'; + p = *pp; + if (p && p->expr) { + linelim = 0; + decompile(p->expr, 0); /* set line to expr */ + line[linelim] = '\0'; + if (*line == '?') + *line = '\0'; + } + //if (c < cn) + // strcat(line, "\t"); + //else + // strcat(line, "\n"); + //write(fd, line, strlen(line)); + + scdebug("%s", line); + if (brokenpipe) { + linelim = -1; + return; + } } } linelim = -1; } - @@ -1,2 +1,5 @@ void getnum(int r0, int c0, int rn, int cn, FILE * fd); - +void getformat(int col, FILE * fd); +void getfmt(int r0, int c0, int rn, int cn, FILE * fd); +void getstring(int r0, int c0, int rn, int cn, FILE * fd); +void getexp(int r0, int c0, int rn, int cn, FILE * fd); |