summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormongo <mongo@iomega>2016-08-26 14:16:17 -0300
committermongo <mongo@iomega>2016-08-26 14:16:17 -0300
commit64f0f39f1907e95c8fab18e57f0c0d45d015cc76 (patch)
tree3a7578e3de60bbe58efd1089b63b2563a0d86963
parent2522fcb6fce3285a6e9284a3c019c0dfd0250def (diff)
new overlap configuration parameter.
If overlap is set to true, the cell content that exceedes column width continues to show in the following column. fix a bug when repaiting a cell that has a wide char size over than one.
-rw-r--r--src/conf.c1
-rw-r--r--src/doc6
-rw-r--r--src/screen.c34
3 files changed, 36 insertions, 5 deletions
diff --git a/src/conf.c b/src/conf.c
index f0adab0..5cb8546 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -16,6 +16,7 @@ void store_default_config_values() {
put(user_conf_d, "quit_afterload", "0");
put(user_conf_d, "numeric_zero", "0");
put(user_conf_d, "numeric_decimal", "0");
+ put(user_conf_d, "overlap", "0");
// we calc get gmtoffset
#ifdef USELOCALE
diff --git a/src/doc b/src/doc
index 487e809..617ec35 100644
--- a/src/doc
+++ b/src/doc
@@ -634,7 +634,6 @@ Commands for handling cell content:
NOTE: USELOCALE has to be enabled during build.
c-j auto resize column width to fit its contents.
-
&MAPPING&
mapping can be done in any SC-IM file or in .scimrc file in current home directory.
maps can be added with nmap and imap commands, and they can be removed with
@@ -703,6 +702,11 @@ Commands for handling cell content:
- external_functions
disabled by default, set this variable to enable external functions. see @ext function below.
+ - overlap [default off]
+ If cell content exceedes column width it gets cutoff to fill column width.
+ If overlap is set to true, the content continues to show in the following column.
+
+
&Built-in Range Functions&
@sum(r)
@sum(r,e)
diff --git a/src/screen.c b/src/screen.c
index 7ec23e0..c740eeb 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -1,10 +1,14 @@
/*
- main_win: window that loads the spreadsheet
+main_win: window that loads the spreadsheetssword:
+
input_win: stdin and state bar window
*/
+#define _XOPEN_SOURCE_EXTENDED = 1
+
+
#include <string.h>
-//#include <ncursesw/curses.h>
-#include <ncurses.h>
+#include <ncursesw/curses.h>
+//#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
@@ -528,6 +532,24 @@ void show_content(WINDOW * win, int mxrow, int mxcol) {
set_ucolor(win, &ucolors[STRG]); // When a long string does not fit in column.
#endif
}
+
+ // new implementation for wide char support
+ cchar_t cht[fieldlen];
+ wchar_t w;
+ int i, j;
+ for (i = 0; i < fieldlen; ) {
+ w = L' ';
+ j = mvwin_wchnstr (win, row + 1 - offscr_sc_rows - q_row_hidden, c + i, cht, 1);
+ if ( j== OK && cht[0].chars != NULL)
+ w = cht[0].chars[0];
+ mvwprintw(win, row + 1 - offscr_sc_rows - q_row_hidden, c+i, "%lc", w);
+ i+= wcwidth(w);
+ }
+
+/*
+ // old implementation for common char and
+ // not wide char
+
char caracter;
chtype cht[fieldlen];
int i;
@@ -541,10 +563,14 @@ void show_content(WINDOW * win, int mxrow, int mxcol) {
#endif
mvwprintw(win, row + 1 - offscr_sc_rows - q_row_hidden, c + i, "%c", caracter);
}
+ */
// we print text and number
} else {
pad_and_align(text, num, fwidth[col], align, (*p)->pad, out);
+ if (col == mxcol && wcswidth(out, wcslen(out)) > fwidth[col])
+ out[ count_width_widestring(out, fwidth[col]) ] = L'\0';
+
mvwprintw(win, row + 1 - offscr_sc_rows - q_row_hidden, c, "%ls", out);
wclrtoeol(win);
}
@@ -802,7 +828,7 @@ void pad_and_align (char * str_value, char * numeric_value, int col_width, int a
}
// If content exceedes column width, outputs n number of '*' needed to fill column width
- if (str_len + num_len + padding > col_width ) {
+ if (str_len + num_len + padding > col_width && ( (! atoi(get_conf_value("overlap"))) || align == 1) ) {
if (padding) wmemset(str_out + wcslen(str_out), L'#', padding);
wmemset(str_out + wcslen(str_out), L'*', col_width - padding);
return;