aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/vis.12
-rw-r--r--sam.c6
-rw-r--r--vis-cmds.c3
-rw-r--r--vis-core.h1
-rw-r--r--vis-prompt.c3
-rw-r--r--vis.c3
6 files changed, 16 insertions, 2 deletions
diff --git a/man/vis.1 b/man/vis.1
index 07469f4..10ad5bb 100644
--- a/man/vis.1
+++ b/man/vis.1
@@ -1409,6 +1409,8 @@ lager ones.
WARNING: modifying a memory mapped file in-place will cause data loss.
.It Ic layout Op Do v Dc or Do h Dc
Whether to use vertical or horizontal layout.
+.It Cm ignorecase , Cm ic Op Cm off
+Whether to ignore case when searching.
.El
.
.Sh COMMAND and SEARCH PROMPT
diff --git a/sam.c b/sam.c
index 6909020..b1be53b 100644
--- a/sam.c
+++ b/sam.c
@@ -300,6 +300,7 @@ enum {
OPTION_LOAD_METHOD,
OPTION_CHANGE_256COLORS,
OPTION_LAYOUT,
+ OPTION_IGNORECASE,
};
static const OptionDef options[] = {
@@ -388,6 +389,11 @@ static const OptionDef options[] = {
VIS_OPTION_TYPE_STRING,
VIS_HELP("Vertical or horizontal window layout")
},
+ [OPTION_IGNORECASE] = {
+ { "ignorecase", "ic" },
+ VIS_OPTION_TYPE_BOOL,
+ VIS_HELP("Ignore case when searching")
+ },
};
bool sam_init(Vis *vis) {
diff --git a/vis-cmds.c b/vis-cmds.c
index f2551d0..181321e 100644
--- a/vis-cmds.c
+++ b/vis-cmds.c
@@ -361,6 +361,9 @@ static bool cmd_set(Vis *vis, Win *win, Command *cmd, const char *argv[], Select
windows_arrange(vis, layout);
break;
}
+ case OPTION_IGNORECASE:
+ vis->ignorecase = toggle ? !vis->ignorecase : arg.b;
+ break;
default:
if (!opt->func)
return false;
diff --git a/vis-core.h b/vis-core.h
index d409f88..383d262 100644
--- a/vis-core.h
+++ b/vis-core.h
@@ -221,6 +221,7 @@ struct Vis {
Array motions;
Array textobjects;
Array bindings;
+ bool ignorecase; /* whether to ignore case when searching */
};
enum VisEvents {
diff --git a/vis-prompt.c b/vis-prompt.c
index fd57a04..bb1db39 100644
--- a/vis-prompt.c
+++ b/vis-prompt.c
@@ -63,7 +63,8 @@ static const char *prompt_enter(Vis *vis, const char *keys, const Arg *arg) {
pattern = "^:";
else if (prompt->file == vis->search_file)
pattern = "^(/|\\?)";
- if (pattern && regex && text_regex_compile(regex, pattern, REG_EXTENDED|REG_NEWLINE) == 0) {
+ int cflags = REG_EXTENDED|REG_NEWLINE|(REG_ICASE*vis->ignorecase);
+ if (pattern && regex && text_regex_compile(regex, pattern, cflags) == 0) {
size_t end = text_line_end(txt, pos);
size_t prev = text_search_backward(txt, end, regex);
if (prev > pos)
diff --git a/vis.c b/vis.c
index c4e8fa1..d84622c 100644
--- a/vis.c
+++ b/vis.c
@@ -1685,7 +1685,8 @@ Regex *vis_regex(Vis *vis, const char *pattern) {
Regex *regex = text_regex_new();
if (!regex)
return NULL;
- if (text_regex_compile(regex, pattern, REG_EXTENDED|REG_NEWLINE) != 0) {
+ int cflags = REG_EXTENDED|REG_NEWLINE|(REG_ICASE*vis->ignorecase);
+ if (text_regex_compile(regex, pattern, cflags) != 0) {
text_regex_free(regex);
return NULL;
}