summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpgen <p.gen.progs@gmail.com>2023-03-28 23:31:49 +0200
committerpgen <p.gen.progs@gmail.com>2023-03-30 00:27:12 +0200
commit0afbb94750055656b38326201bd8cf419bd2eeb6 (patch)
tree5732bdb19c3a71af620ac585dde9b72de895023e
parentdc25ac071a0414f50aa7f7e9af590b21fa3039a7 (diff)
Add -the -sb|-sbw|-show_blank_words option
This option makes the blank words visible and usable even when we are not in column mode.
-rw-r--r--smenu.19
-rw-r--r--smenu.c23
-rw-r--r--smenu.h3
-rw-r--r--usage.c2
4 files changed, 32 insertions, 5 deletions
diff --git a/smenu.1 b/smenu.1
index 33e5760..ff99343 100644
--- a/smenu.1
+++ b/smenu.1
@@ -83,6 +83,7 @@ and outputs the selection to stdout.
\fInew_button_3\fP]
[\fB-dc\fP|\fB-dcd\fP|\fB-double_click\fP|\fB-double_click_delay\fP \
\fIdelay_in_ms\fP]
+ [\fB-sb\fP|\fB-sbw\fP|\fB-show_blank_words\fP]
selectors ::= \fIcol1\fP[-\fIcol2\fP],...|\fIrow1\fP[-\fIrow2\fP],...|\
@@ -1959,6 +1960,14 @@ The double-click capability can also be disabled by setting
This setting is also configurable in a configuration file, see the
[mouse] section in the example in the configuration sub-section.
+.IP "\fB-sb\fP|\fB-sbw\fP|\fB-show_blank_words\fP"
+(Allowed in all contexts.)
+
+Normally, blank words (words containing only space:.!fmt
+s) are only kept in column mode.
+When this option is present, these words are converted into a sequence
+of underscores so that they are visible and not ignored when not in
+column mode.
.SH NOTES
If tabulators (\fI\\t\fP) are embedded in the input, there is no way
to replace them with the original number of spaces.
diff --git a/smenu.c b/smenu.c
index d50777a..8af45e0 100644
--- a/smenu.c
+++ b/smenu.c
@@ -1791,7 +1791,10 @@ parse_selectors(char * str, filters_t * filter, char * unparsed,
default:
if (!isgraph(c))
+ {
+ my_strcpy(unparsed, str);
return;
+ }
type = IN;
*filter = INCLUDE_FILTER;
@@ -2938,8 +2941,10 @@ expand(char * src, char * dest, langinfo_t * langinfo, toggle_t * toggles,
default:
if (my_isprint(c))
{
- *(ptr++) = c;
- all_spaces = 0;
+ if (c != ' ')
+ all_spaces = 0;
+
+ *(ptr++) = c;
}
else
{
@@ -2958,8 +2963,8 @@ expand(char * src, char * dest, langinfo_t * langinfo, toggle_t * toggles,
/* If the word contains only spaces, replace them */
/* by underscores so that it can be seen. */
/* """""""""""""""""""""""""""""""""""""""""""""" */
- if (all_spaces)
- memset(dest, ' ', len);
+ if (toggles->show_blank_words && all_spaces)
+ memset(dest, '_', len);
*ptr = '\0'; /* Ensure that dest has a nul terminator. */
@@ -5594,6 +5599,7 @@ init_main_ds(attrib_t * init_attr, win_t * win, limit_t * limits,
toggles->visual_bell = 0;
toggles->incremental_search = 0;
toggles->no_mouse = 0;
+ toggles->show_blank_words = 0;
/* Misc default values. */
/* """""""""""""""""""" */
@@ -5864,6 +5870,8 @@ toggle_action(char * ctx_name, char * opt_name, char * param, int nb_values,
toggles->incremental_search = 1;
else if (strcmp(opt_name, "no_mouse") == 0)
toggles->no_mouse = 1;
+ else if (strcmp(opt_name, "show_blank_words") == 0)
+ toggles->show_blank_words = 1;
}
void
@@ -7763,7 +7771,8 @@ main(int argc, char * argv[])
"[forgotten_timeout #timeout] "
"[double_click_delay #delay] "
"[button_remapping #mapping...] "
- "[no_mouse] "; /* don't remove this space! */
+ "[no_mouse] "
+ "[show_blank_words] "; /* don't remove this space! */
main_spec_options = "[*copyright] "
"[*version] "
@@ -7930,6 +7939,8 @@ main(int argc, char * argv[])
"-br -buttons -button_remapping");
ctxopt_add_opt_settings(parameters, "double_click_delay",
"-dc -dcd -double_click -double_click_delay");
+ ctxopt_add_opt_settings(parameters, "show_blank_words",
+ "-sb -sbw -show_blank_words");
/* ctxopt options incompatibilities. */
/* """"""""""""""""""""""""""""""""" */
@@ -8093,6 +8104,8 @@ main(int argc, char * argv[])
&mouse, &disable_double_click, (char *)0);
ctxopt_add_opt_settings(actions, "no_mouse", toggle_action, &toggles,
(char *)0);
+ ctxopt_add_opt_settings(actions, "show_blank_words", toggle_action, &toggles,
+ (char *)0);
/* ctxopt constraints. */
/* """"""""""""""""""" */
diff --git a/smenu.h b/smenu.h
index 93e61fc..6670fbb 100644
--- a/smenu.h
+++ b/smenu.h
@@ -199,6 +199,9 @@ struct toggle_s
| 0 keeps it forgetful. */
int no_mouse; /* 1 to disable the possibly auto-detected *
| mouse, 0 to let smenu auto-detect it. */
+ int show_blank_words; /* 1 if blank words are allowed then they will *
+ | be filled by an underscore, 0 to leave them *
+ | blank. */
};
/* Structure to store the default or imposed smenu limits. */
diff --git a/usage.c b/usage.c
index 24a027a..cfcd2c5 100644
--- a/usage.c
+++ b/usage.c
@@ -106,6 +106,8 @@ common_help(void)
printf(" Remaps the left and right mouse buttons, default is 1 and 3.\n");
printf("-dc|-dcd|-double_click|-double_click_delay\n");
printf(" Change the mouse double-click delay which is 150 ms by default.\n");
+ printf("-sb|-sbw|-show_blank_words\n");
+ printf(" Make blank words visible and usable even in non column mode.\n");
}
void