quickopen Fallback to glib.regex

+ support for new version of vte complaining about MULTILINE
(inspired by:
  a004e66b87
)

closes #1230

Signed-off-by: Gaetan Semet <gaetan@xeberon.net>
This commit is contained in:
Gaetan Semet 2018-04-08 18:22:09 +02:00
parent 8b9093d7b0
commit dbcaaadb3f
5 changed files with 35 additions and 14 deletions

View File

@ -2,7 +2,8 @@ Before opening a new issue, please read the following:
- for **feature requests**, please use [FeatHub](https://feathub.com/Guake/guake). This allow us to
spot directly which are the most requested features.
- before opening **a new bug**, please search for a similar one in the GitHub issue.
- before opening **a new bug**, please search for a similar one in the
[GitHub issue](https://github.com/Guake/guake/issues).
- to **report a bug**, please give the following information:
- **Guake Version**: see in about box.

View File

@ -10,7 +10,7 @@ Please follow these steps before submitting a new Pull Request to Guake:
- execute the code styling, checks and unit tests using:
```bash
$ make style check test
$ make style check reno-lint test
```
- add a slug in release note using:
@ -18,8 +18,9 @@ Please follow these steps before submitting a new Pull Request to Guake:
```bash
$ make reno SLUG=<short_name_of_my_feature>
```
and edit the created file in `releasenotes/notes/`.
You can see how `reno` works using `pipenv run reno --help`.
Please use a generic slug (for translation update, use `translation`)
Please use a generic slug (eg, for translation update, use `translation`)

View File

@ -5,6 +5,8 @@ python:
install:
# https://docs.openstack.org/reno/latest/user/usage.html#within-travis-ci
- git fetch --unshallow --tags
- sudo ./bootstrap-dev-debian.sh
- ./bootstrap-dev-pip.sh system

View File

@ -176,13 +176,28 @@ class GuakeTerminal(Vte.Terminal):
tag = self.match_add_regex(Vte.Regex.new_for_match(match, 0, 0), 0)
self.match_set_cursor_type(tag, Gdk.CursorType.HAND2)
except GLib.Error as e:
g_pcre2_enabled = False
log.error(
"ERROR: PCRE2 does not seems to be enabled on your system. "
"Quick Edit and other Ctrl+click features are disabled. "
"Please update your VTE package or contact your distribution to ask "
"to enable regular expression support in VTE. Exception: '%s'", str(e)
)
log.info("PCRE2 disabled on your current VTE, fallback with glib regex")
try:
compile_flag = 0
if (Vte.MAJOR_VERSION, Vte.MINOR_VERSION) >= (0, 44):
compile_flag = GLib.RegexCompileFlags.MULTILINE
for expr in TERMINAL_MATCH_EXPRS:
# TODO PORT next line throws a Vte-WARNIN but works: runtime check failed
tag = self.match_add_gregex(GLib.Regex.new(expr, compile_flag, 0), 0)
self.match_set_cursor_type(tag, Gdk.CursorType.HAND2)
for _useless, match, _otheruseless in QUICK_OPEN_MATCHERS:
# TODO PORT next line throws a Vte-WARNIN but works: runtime check failed
tag = self.match_add_gregex(GLib.Regex.new(match, compile_flag, 0), 0)
self.match_set_cursor_type(tag, Gdk.CursorType.HAND2)
except GLib.Error as e:
g_pcre2_enabled = False
log.error(
"ERROR: PCRE2 does not seems to be enabled on your system. "
"Quick Edit and other Ctrl+click features are disabled. "
"Please update your VTE package or contact your distribution to ask "
"to enable regular expression support in VTE. Exception: '%s'", str(e)
)
def get_current_directory(self):
directory = os.path.expanduser('~')
@ -284,7 +299,7 @@ class GuakeTerminal(Vte.Terminal):
g = re.compile(extractor).match(value)
if g and g.groups():
filename = g.group(1).strip()
(fp, _, _) = self.is_file_on_local_server(filename)
(filepath, _, _) = self.is_file_on_local_server(filename)
line_number = g.group(2)
if line_number is None:
line_number = "1"

View File

@ -3,9 +3,11 @@ fixes:
Fix several issues on Quick Edit:
- quick open freezes guake
- support system with PCRE2 (regular expression in terminal) disabled, like Ubuntu 17.10.
This disables quick open and open url on direct Ctrl+click. User can still select the wanted
url or text and Cltr+click or use contextual menu.
- support for systems with PCRE2 (regular expression in terminal) disabled for VTE, like
Ubuntu 17.10 and +.
This might disable quick open and open url on direct Ctrl+click.
User can still select the wanted url or text and Cltr+click or use contextual menu.
See this `discussion on Tilix <https://github.com/gnunn1/tilix/issues/916>`_, another
Terminal emulator that suffurs the same issue.