summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrés <andmarti@gmail.com>2021-05-21 11:55:19 -0300
committerAndrés <andmarti@gmail.com>2021-05-21 11:55:19 -0300
commitdb761e74380fafaf27a35a03156a168c3be711fa (patch)
tree876426765e146ce94ccb5b2528a1d7fc78118e5e
parentdb3789f37c92b75161912b738c1ff7b24b6c4d00 (diff)
changes to support multisheet
-rw-r--r--CHANGES4
-rw-r--r--src/cmds.c2
-rw-r--r--src/cmds_command.c8
-rw-r--r--src/cmds_normal.c11
-rw-r--r--src/color.c5
-rw-r--r--src/color.h30
-rw-r--r--src/conf.c1
-rwxr-xr-xsrc/doc12
-rwxr-xr-xsrc/gram.y21
-rw-r--r--src/macros.h26
-rw-r--r--src/main.c3
-rw-r--r--src/range.c1
-rw-r--r--src/tui.c15
-rw-r--r--src/undo.c1
14 files changed, 97 insertions, 43 deletions
diff --git a/CHANGES b/CHANGES
index a4980cc..d5bad4e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,10 @@ Changes
Renamed auto_justify to auto_fit
Save triggers in files
ui optimizations
+adding support for multisheet
+gt command of normal mode renamed to go
+gt and gT commands in normal mode are now used for moving between sheets`
+added new colors types SHEET and CURRENT_SHEET
For v0.8.3 release
diff --git a/src/cmds.c b/src/cmds.c
index 66ae4c0..1fd870a 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -2739,6 +2739,8 @@ int is_single_command (struct block * buf, long timeout) {
buf->pnext->value == L'G' ||
buf->pnext->value == L'0' ||
buf->pnext->value == L'l' ||
+ buf->pnext->value == L't' ||
+ buf->pnext->value == L'T' ||
buf->pnext->value == L'$'))
result = MOVEMENT_CMD;
diff --git a/src/cmds_command.c b/src/cmds_command.c
index b12656c..aa3dcf5 100644
--- a/src/cmds_command.c
+++ b/src/cmds_command.c
@@ -138,12 +138,15 @@ L"iunmap",
L"load!",
L"load",
L"lock",
+L"newsheet",
+L"nextsheet",
L"nmap",
L"nnoremap",
L"nunmap",
L"pad",
L"plot",
L"plotedit",
+L"prevsheet",
L"q!",
L"q",
L"quit!",
@@ -972,6 +975,11 @@ void do_commandmode(struct block * sb) {
get_mappings(valores);
ui_show_text(valores);
+ } else if ( ! wcsncmp(inputline, L"newsheet", 8) ||
+ ! wcsncmp(inputline, L"nextsheet", 9) ||
+ ! wcsncmp(inputline, L"prevsheet", 9)) {
+ send_to_interp(inputline);
+
} else if ( ! wcsncmp(inputline, L"nmap", 4) ||
! wcsncmp(inputline, L"imap", 4) ||
! wcsncmp(inputline, L"vmap", 4) ||
diff --git a/src/cmds_normal.c b/src/cmds_normal.c
index e02b736..7152cc9 100644
--- a/src/cmds_normal.c
+++ b/src/cmds_normal.c
@@ -394,7 +394,16 @@ void do_normalmode(struct block * buf) {
sh->currow = sh->lastrow;
sh->lastrow = newlr;
sh->lastcol = newlc;
- } else if (buf->pnext->value == L't') { // gtA4 (goto cell A4)
+
+ } else if (buf->pnext->value == L't') { // gt
+ (void) swprintf(interp_line, BUFFERSIZE, L"nextsheet");
+ send_to_interp(interp_line);
+
+ } else if (buf->pnext->value == L'T') { // gT
+ (void) swprintf(interp_line, BUFFERSIZE, L"prevsheet");
+ send_to_interp(interp_line);
+
+ } else if (buf->pnext->value == L'o') { // goA4 (goto cell A4)
(void) swprintf(interp_line, BUFFERSIZE, L"goto %s", parse_cell_name(2, buf));
send_to_interp(interp_line);
}
diff --git a/src/color.c b/src/color.c
index dc2ea26..288e7fb 100644
--- a/src/color.c
+++ b/src/color.c
@@ -153,6 +153,11 @@ void start_default_ucolors() {
ucolors[ CELL_NEGATIVE ].bg = DEFAULT_COLOR;
ucolors[ HELP_HIGHLIGHT ].fg = BLACK; // cell selection in spreadsheet
ucolors[ HELP_HIGHLIGHT ].bg = YELLOW;
+ ucolors[ CURRENT_SHEET ].fg = CYAN;
+ ucolors[ CURRENT_SHEET ].bg = DEFAULT_COLOR;
+ ucolors[ CURRENT_SHEET ].bold = 1;
+ ucolors[ SHEET ].fg = MAGENTA;
+ ucolors[ SHEET ].bg = DEFAULT_COLOR;
ui_start_colors(); // call specific ui startup routine
}
diff --git a/src/color.h b/src/color.h
index 20ffe1e..45e18fb 100644
--- a/src/color.h
+++ b/src/color.h
@@ -47,7 +47,35 @@
#include <math.h>
#define RGB(r, g, b) r*999/255, g*999/255, b*999/255
-#define N_INIT_PAIRS 25
+#define N_INIT_PAIRS 27
+
+#define HEADINGS 0
+#define WELCOME 1
+#define CELL_SELECTION 2
+#define CELL_SELECTION_SC 3
+#define NUMB 4
+#define STRG 5
+#define DATEF 6
+#define EXPRESSION 7
+#define INFO_MSG 8
+#define ERROR_MSG 9
+#define MODE 10
+#define CELL_ID 11
+#define CELL_FORMAT 12
+#define CELL_CONTENT 13
+#define INPUT 14
+#define NORMAL 15
+#define CELL_ERROR 16
+#define CELL_NEGATIVE 17
+#define DEFAULT 18
+#define DEBUG_MSG 19
+#define VALUE_MSG 20
+#define GRID_EVEN 21
+#define GRID_ODD 22
+#define HEADINGS_ODD 23
+#define HELP_HIGHLIGHT 24
+#define SHEET 25
+#define CURRENT_SHEET 26
struct ucolor {
int fg;
diff --git a/src/conf.c b/src/conf.c
index 70bb9c6..14b1ede 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -73,6 +73,7 @@ const char default_config[] =
"autowrap=0\n"
"debug=0\n"
"ignorecase=0\n"
+ "show_cursor=0\n"
"trigger=1\n"
"version=0\n"
"help=0\n"
diff --git a/src/doc b/src/doc
index 7ef4730..c7a9353 100755
--- a/src/doc
+++ b/src/doc
@@ -54,7 +54,7 @@ Navigation commands:
w Go forward to the next valid cell.
'{a-zA-Z} Go to the cell or range marked previously with the character.
See 'm' for details.
- gtab24 Go to cell AB24. (There is no need to press <ENTER>.)
+ goab24 Go to cell AB24. (There is no need to press <ENTER>.)
g0 Go to the leftmost column visible on screen.
g$ Go to the rightmost column visible on screen.
gM Go to the middle column on the screen.
@@ -66,6 +66,8 @@ Navigation commands:
gg c-a Go to the first cell of sheet.
G gG Go to last valid cell of sheet.
gl Go to the last (previously occupied) cell position.
+ gt Move to next sheet in file.
+ gT Move to previous sheet in file.
c-f c-b Scrolls down and up full screen.
:set half_page_scroll=1 to scroll by half a page instead.
half_page_scroll=0 (default) scrolls by a full page.
@@ -536,6 +538,14 @@ Commands for handling cell content:
:set nonumeric (same as :set numeric=0)
:set default_paste_from_clipboard_cmd="xsel"
+ :newsheet "{name}"
+ create a new sheet in file and move to it.
+
+ :nextsheet
+ move to next sheet in file
+ :prevsheet
+ move to previous sheet in file
+
:showmaps Show all key mappings.
:nmap {lhs} {rhs}
diff --git a/src/gram.y b/src/gram.y
index 7a8f585..cff15c0 100755
--- a/src/gram.y
+++ b/src/gram.y
@@ -621,21 +621,20 @@ command:
}
}
| S_NEXTSHEET {
- if (roman->cur_sh->next != NULL) {
+ if (roman->cur_sh->next != NULL)
roman->cur_sh = roman->cur_sh->next;
- chg_mode('.');
- ui_update(TRUE);
- } else
- sc_info("we are already in last sheet of file");
+ else
+ roman->cur_sh = roman->first_sh;
+ chg_mode('.');
+ ui_update(TRUE);
}
-
| S_PREVSHEET {
- if (roman->cur_sh->prev != NULL) {
+ if (roman->cur_sh->prev != NULL)
roman->cur_sh = roman->cur_sh->prev;
- chg_mode('.');
- ui_update(TRUE);
- } else
- sc_info("we are already in first sheet of file");
+ else
+ roman->cur_sh = roman->last_sh;
+ chg_mode('.');
+ ui_update(TRUE);
}
| S_NMAP STRING STRING {
diff --git a/src/macros.h b/src/macros.h
index b05cad2..6401ab6 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -92,32 +92,6 @@
#define EDITION_CMD 1
#define MOVEMENT_CMD 2
-#define HEADINGS 0
-#define WELCOME 1
-#define CELL_SELECTION 2
-#define CELL_SELECTION_SC 3
-#define NUMB 4
-#define STRG 5
-#define DATEF 6
-#define EXPRESSION 7
-#define INFO_MSG 8
-#define ERROR_MSG 9
-#define MODE 10
-#define CELL_ID 11
-#define CELL_FORMAT 12
-#define CELL_CONTENT 13
-#define INPUT 14
-#define NORMAL 15
-#define CELL_ERROR 16
-#define CELL_NEGATIVE 17
-#define DEFAULT 18
-#define DEBUG_MSG 19
-#define VALUE_MSG 20
-#define GRID_EVEN 21
-#define GRID_ODD 22
-#define HEADINGS_ODD 23
-#define HELP_HIGHLIGHT 24
-
void ui_sc_msg(char * s, int type, ...);
#define sc_error(x, ...) ui_sc_msg(x, ERROR_MSG, ##__VA_ARGS__)
#define sc_debug(x, ...) ui_sc_msg(x, DEBUG_MSG, ##__VA_ARGS__)
diff --git a/src/main.c b/src/main.c
index 12fdeb7..d478e33 100644
--- a/src/main.c
+++ b/src/main.c
@@ -288,8 +288,7 @@ int main (int argc, char ** argv) {
roman->cur_sh = NULL;
// malloc a sheet
- new_sheet(roman, NULL);
- //roman->first_sh = malloc(sizeof(struct sheet));
+ new_sheet(roman, "Sheet 1");
roman->cur_sh = roman->first_sh;
roman->flags &= is_empty;
diff --git a/src/range.c b/src/range.c
index 14bf4f9..1826b4b 100644
--- a/src/range.c
+++ b/src/range.c
@@ -51,6 +51,7 @@
#include "sc.h"
#include "marks.h"
#include "macros.h"
+#include "color.h"
#include "conf.h"
#include "xmalloc.h" // for scxfree
diff --git a/src/tui.c b/src/tui.c
index cf9c084..d22fcbe 100644
--- a/src/tui.c
+++ b/src/tui.c
@@ -1114,12 +1114,25 @@ void ui_show_celldetails() {
char head[FBUFLEN];
int il_pos = 0;
+ // show sheets
+ for (struct sheet * sh = roman->first_sh; sh != NULL; sh = sh->next) {
+ #ifdef USECOLORS
+ if (sh == roman->cur_sh) {
+ ui_set_ucolor(input_win, &ucolors[CURRENT_SHEET], DEFAULT_COLOR);
+ if (get_conf_int("show_cursor")) mvwprintw(input_win, 0, il_pos++, "*");
+ } else
+ ui_set_ucolor(input_win, &ucolors[SHEET], DEFAULT_COLOR);
+ #endif
+ mvwprintw(input_win, 0, il_pos, "{%s} ", sh->name);
+ il_pos += strlen(sh->name) + 3;
+ }
+
// show cell in header
#ifdef USECOLORS
ui_set_ucolor(input_win, &ucolors[CELL_ID], DEFAULT_COLOR);
#endif
sprintf(head, "%s%d ", coltoa(sh->curcol), sh->currow);
- mvwprintw(input_win, 0, 0, "%s", head);
+ mvwprintw(input_win, 0, il_pos, "%s", head);
il_pos += strlen(head);
// show the current cell's format
diff --git a/src/undo.c b/src/undo.c
index 2824674..ddcd2d6 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -142,6 +142,7 @@
#include <stdlib.h>
#include "undo.h"
#include "macros.h"
+#include "color.h"
#include "curses.h"
#include "conf.h"
#include "sc.h"