[vte] app: Add MULTILINE flag for regex
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] app: Add MULTILINE flag for regex
- Date: Sat, 17 Sep 2016 18:34:04 +0000 (UTC)
commit 2b93575d98ccc5dbc932cf0c49be36fa33e61622
Author: Christian Persch <chpe src gnome org>
Date: Sat Sep 17 20:33:47 2016 +0200
app: Add MULTILINE flag for regex
src/app.vala | 14 +++-----------
src/vteapp.c | 4 ++--
2 files changed, 5 insertions(+), 13 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index 4fef749..b43a275 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -36,7 +36,6 @@ class SearchPopover : Gtk.Popover
[GtkChild] private Gtk.Revealer revealer;
private bool regex_caseless = false;
- private bool regex_multiline = false;
private string? regex_pattern = null;
private GLib.Regex? regex_gregex = null;
private Vte.Regex? regex_regex = null;
@@ -88,7 +87,6 @@ class SearchPopover : Gtk.Popover
string search_text;
string pattern = null;
bool caseless = false;
- bool multiline = false;
GLib.Regex? gregex = null;
Vte.Regex? regex = null;
@@ -97,7 +95,6 @@ class SearchPopover : Gtk.Popover
if (regex_checkbutton.active) {
pattern = search_text;
- multiline = true;
} else {
pattern = GLib.Regex.escape_string(search_text);
}
@@ -106,24 +103,20 @@ class SearchPopover : Gtk.Popover
pattern = "\\b" + pattern + "\\b";
if (caseless == regex_caseless &&
- multiline == regex_multiline &&
pattern == regex_pattern)
return;
regex_pattern = null;
regex_caseless = caseless;
- regex_multiline = multiline;
if (search_text.length != 0) {
try {
if (!App.Options.no_pcre) {
uint32 flags;
- flags = 0x40080000u /* PCRE2_UTF | PCRE2_NO_UTF_CHECK */;
+ flags = 0x40080400u /* PCRE2_UTF | PCRE2_NO_UTF_CHECK | PCRE2_MULTILINE */;
if (caseless)
flags |= 0x00000008u; /* PCRE2_CASELESS */
- if (multiline)
- flags |= 0x00000400u; /* PCRE2_MULTILINE */
regex = new Vte.Regex.for_search(pattern, pattern.length, flags);
try {
@@ -136,11 +129,10 @@ class SearchPopover : Gtk.Popover
} else {
GLib.RegexCompileFlags flags;
- flags = GLib.RegexCompileFlags.OPTIMIZE;
+ flags = GLib.RegexCompileFlags.OPTIMIZE |
+ GLib.RegexCompileFlags.MULTILINE;
if (caseless)
flags |= GLib.RegexCompileFlags.CASELESS;
- if (multiline)
- flags |= GLib.RegexCompileFlags.MULTILINE;
gregex = new GLib.Regex(pattern, flags, 0);
}
diff --git a/src/vteapp.c b/src/vteapp.c
index 96a3732..e80325b 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -166,7 +166,7 @@ button_pressed(GtkWidget *widget, GdkEventButton *event, gpointer data)
}
}
if (!use_gregex) {
- VteRegex *regex = vte_regex_new_for_match("\\d+", -1, PCRE2_UTF, NULL);
+ VteRegex *regex = vte_regex_new_for_match("\\d+", -1, PCRE2_UTF | PCRE2_NO_UTF_CHECK
| PCRE2_MULTILINE, NULL);
has_extra_match = vte_terminal_event_check_regex_simple(terminal,
(GdkEvent*)event,
®ex, 1,
@@ -562,7 +562,7 @@ add_dingus (VteTerminal *terminal,
if (!use_gregex)
regex = vte_regex_new_for_match(dingus[i], -1,
- PCRE2_UTF | PCRE2_NO_UTF_CHECK,
+ PCRE2_UTF | PCRE2_NO_UTF_CHECK | PCRE2_MULTILINE,
&error);
else
gregex = g_regex_new(dingus[i], G_REGEX_OPTIMIZE | G_REGEX_MULTILINE, 0, &error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]