diff --git a/src/cmds.c b/src/cmds.c index fa85b310..2744a83f 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -331,7 +331,7 @@ void int_deletecol(int col, int mult) { * with the "pt" command. r1, c1, r2, and c2 define the range in which the * dr and dc values should be used. Special =='u' means special copy from * spreadsheet to undo struct. Since its mandatory to make isolated copies - * of p->expr->e.o.right.e.v.vp and p->expr->e.o.right.e.v.vp + * of p->expr->e.o.right.e.v.vp and p->expr->e.o.right.e.v.vp * * \param[in] n * \param[in] p @@ -655,7 +655,7 @@ struct enode * copye(register struct enode *e, int Rdelta, int Cdelta, int r1, i } /** - * \brief TODO Write brief function description + * \brief TODO Write brief function description * * \details Note: Modified 9/17/90 THA to handle more formats. * @@ -963,7 +963,7 @@ void int_deleterow(int row, int mult) { * \param[in] sc * \param[in] er * \param[in] ec - * + * * \return none */ @@ -996,7 +996,7 @@ void ljustify(int sr, int sc, int er, int ec) { /** * \brief TODO Document rjustify() - * + * * \param[in] sr * \param[in] sc * \param[in] er @@ -2010,7 +2010,7 @@ void valueize_area(int sr, int sc, int er, int ec) { * \param[in] vir_tlcol * \param[in] vir_brrow * \param[in] vir_brcol - * + * * \return none */ @@ -2529,7 +2529,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 && ( (! atoi(get_conf_value("overlap"))) || align == 1) ) { + if (str_len + num_len + padding > col_width && !atoi(get_conf_value("truncate")) && ( (! 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; @@ -2569,6 +2569,11 @@ void pad_and_align (char * str_value, char * numeric_value, int col_width, int a swprintf(str_out + wcslen(str_out), BUFFERSIZE, L"%s", numeric_value); } + // Similar condition to max width '*' condition above, but just trims instead + if (str_len + num_len + padding > col_width && atoi(get_conf_value("truncate"))) { + str_out[col_width] = '\0'; + } + return; } @@ -2746,7 +2751,7 @@ int is_single_command (struct block * buf, long timeout) { else if (buf->value == L'd' && bs == 2 && // cuts a cell buf->pnext->value == L'd') res = EDITION_CMD; - else if (buf->value == L'\'' && bs == 2 && // tick + else if (buf->value == L'\'' && bs == 2 && // tick ((buf->pnext->value - (L'a' - 1)) < 1 || buf->pnext->value > 26)) res = MOVEMENT_CMD; diff --git a/src/conf.c b/src/conf.c index 330abc26..fe30c52b 100644 --- a/src/conf.c +++ b/src/conf.c @@ -76,6 +76,7 @@ void store_default_config_values() { put(user_conf_d, "numeric_zero", "1"); put(user_conf_d, "numeric_decimal", "1"); put(user_conf_d, "overlap", "0"); + put(user_conf_d, "truncate", "0"); put(user_conf_d, "debug", "0"); put(user_conf_d, "ignorecase", "0"); put(user_conf_d, "trigger", "1"); diff --git a/src/doc b/src/doc index 5cbf1acb..b9fdacb2 100755 --- a/src/doc +++ b/src/doc @@ -1038,6 +1038,10 @@ Commands for handling cell content: If cell content exceedes column width it gets cut off to fit the column width. If overlap is set, the content overflows into the next column. + 'truncate' [default off] + If cell content exceedes column width it gets replaced by asterisks '*'. + If truncate is set, the content is cut off at the end of the cell. + 'debug' [default off] set this to see debug messages in screen diff --git a/src/gram.y b/src/gram.y index f971535f..e6b0a669 100755 --- a/src/gram.y +++ b/src/gram.y @@ -236,6 +236,8 @@ token S_YANKCOL %token K_NONUMERIC_ZERO %token K_OVERLAP %token K_NOOVERLAP +%token K_TRUNCATE +%token K_NOTRUNCATE %token K_QUIT_AFTERLOAD %token K_NOQUIT_AFTERLOAD %token K_XLSX_READFORMULAS @@ -1047,6 +1049,10 @@ setitem : else parse_str(user_conf_d, "overlap=1", TRUE); } | K_OVERLAP { parse_str(user_conf_d, "overlap=1", TRUE); } | K_NOOVERLAP { parse_str(user_conf_d, "overlap=0", TRUE); } + | K_TRUNCATE '=' NUMBER { if ($3 == 0) parse_str(user_conf_d, "truncate=0", TRUE); + else parse_str(user_conf_d, "truncate=1", TRUE); } + | K_TRUNCATE { parse_str(user_conf_d, "truncate=1", TRUE); } + | K_NOTRUNCATE { parse_str(user_conf_d, "truncate=0", TRUE); } | K_AUTOBACKUP '=' NUMBER { char cmd[MAXCMD]; sprintf(cmd, "autobackup=%d", $3);