From ad2c79d0c87a1aa70af96a5efb93a3714bda0b76 Mon Sep 17 00:00:00 2001 From: HelioGuilherme66 Date: Tue, 19 Sep 2023 00:55:50 +0100 Subject: [PATCH] Change Text Editor help call to ude Ctrl. Allow to call help when autocomplete list is shown --- CHANGELOG.adoc | 2 +- src/robotide/application/CHANGELOG.html | 2 +- src/robotide/application/releasenotes.py | 4 +- src/robotide/context/__init__.py | 4 +- src/robotide/editor/texteditor.py | 47 ++++++++---------------- 5 files changed, 21 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index a147c2c80..7a5a997fa 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -10,7 +10,7 @@ and this project adheres to http://semver.org/spec/v2.0.0.html[Semantic Versioni === Added -- Added content help pop-up on Text Editor by pressing ``Ctrl-M`` for text at cursor position +- Added content help pop-up on Text Editor by pressing ``Ctrl-M`` for text at cursor position or selected autocomplete list item - Added Exclude option in context nenu for Test files, previously was only possible for Test Suites folders - Added exclusion of monitoring filesystem changes for files and directories excluded in Preferences - Added variables creation shortcuts (``Ctrl-1,2,5``) to fields Arguments in Grid Editor diff --git a/src/robotide/application/CHANGELOG.html b/src/robotide/application/CHANGELOG.html index 04352cba5..d780e5679 100644 --- a/src/robotide/application/CHANGELOG.html +++ b/src/robotide/application/CHANGELOG.html @@ -1,7 +1,7 @@ Changelog

Changelog


All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

1.1. Added

  • -Added content help pop-up on Text Editor by pressing ``Ctrl-M`` for text at cursor position +Added content help pop-up on Text Editor by pressing ``Ctrl-M`` for text at cursor position or selected autocomplete list item
  • Added Exclude option in context nenu for Test files, previously was only possible for Test Suites folders
  • diff --git a/src/robotide/application/releasenotes.py b/src/robotide/application/releasenotes.py index bffb03d82..a9aa4ff6b 100644 --- a/src/robotide/application/releasenotes.py +++ b/src/robotide/application/releasenotes.py @@ -168,7 +168,7 @@ def set_content(self, html_win, content):

New Features and Fixes Highlights

    -
  • Added content help pop-up on Text Editor by pressing Ctrl-M for text at cursor position
  • +
  • Added content help pop-up on Text Editor by pressing Ctrl-M for text at cursor position or selected autocomplete list item
  • Added Exclude option in context nenu for Test files, previously was only possible for Test Suites folders
  • Added exclusion of monitoring filesystem changes for files and directories excluded in Preferences
  • Fixed exception when finding GREY color for excluded files and directories in Project Tree
  • @@ -237,6 +237,6 @@ def set_content(self, html_win, content):
     python -m robotide.postinstall -install
     
    -

    RIDE {VERSION} was released on 18/Sep/2023.

    +

    RIDE {VERSION} was released on 19/Sep/2023.

""" diff --git a/src/robotide/context/__init__.py b/src/robotide/context/__init__.py index 97bae4ec9..9350b501f 100644 --- a/src/robotide/context/__init__.py +++ b/src/robotide/context/__init__.py @@ -325,8 +325,8 @@ def bind_keys_to_evt_menu(target, actions): Suggestions and auto completion - CtrlCmd-M - Help for content at cursor + CtrlCmd + Help for content at cursor or selected autocomplete list item CtrlCmd-T diff --git a/src/robotide/editor/texteditor.py b/src/robotide/editor/texteditor.py index 131d7d7e9..98ec29bd2 100644 --- a/src/robotide/editor/texteditor.py +++ b/src/robotide/editor/texteditor.py @@ -884,6 +884,7 @@ def revert(self): def on_editor_key(self, event): keycode = event.GetKeyCode() + keyvalue = event.GetUnicodeKey() if keycode == wx.WXK_DELETE: # DEBUG on Windows we only get here, single Text Editor selected = self.source_editor.GetSelection() if selected[0] == selected[1]: @@ -896,6 +897,8 @@ def on_editor_key(self, event): return if self.is_focused() and keycode != wx.WXK_CONTROL and self._dirty == 0: self._mark_file_dirty(self.source_editor.GetModify()) + if keyvalue == wx.WXK_NONE and keycode in [wx.WXK_CONTROL, wx.WXK_RAW_CONTROL]: + self.source_editor.hide_kw_doc() event.Skip() def on_key_down(self, event): @@ -938,7 +941,7 @@ def on_key_down(self, event): self.delete_cell(event) else: self.delete_row(event) - elif keycode == ord('M') and event.ControlDown(): + elif event.ControlDown() and keycode == 0: self.source_editor.show_kw_doc() else: event.Skip() @@ -1511,19 +1514,22 @@ def __init__(self, parent, readonly=False): self.RegisterImage(3, wx.ArtProvider.GetBitmap(wx.ART_COPY, size=(16, 16))) def show_kw_doc(self): - cursor_pos = self.GetCurrentPos() - if cursor_pos != self.old_position: - self.old_position = cursor_pos + if self.AutoCompActive(): + selected = [self.AutoCompGetCurrentText()] + else: selected = self.get_selected_or_near_text(keep_cursor_pos=True) - if self.old_select != selected: - for kw in selected: - self._show_keyword_details(kw) + for kw in selected: + self._show_keyword_details(kw) + + def hide_kw_doc(self): + if self._information_popup: + self._information_popup.hide() + self._information_popup = None def on_key_pressed(self, event): if self.CallTipActive(): self.CallTipCancel() - if self._information_popup: - self._information_popup.hide() + self.hide_kw_doc() key = event.GetKeyCode() if key == 32 and event.ControlDown(): pos = self.GetCurrentPos() @@ -1540,29 +1546,6 @@ def on_key_pressed(self, event): """ # Code completion else: - if self._information_popup: - self._information_popup.hide() - """ - kw = list(keyword.kwlist[:]) - kw.append("zzzzzz?2") - kw.append("aaaaa?2") - kw.append("__init__?3") - kw.append("zzaaaaa?2") - kw.append("zzbaaaa?2") - kw.append("this_is_a_longer_value") - # kw.append("this_is_a_much_much_much_much_much_much_much_longer_value") - - kw.sort() # Python sorts are case-sensitive - self.AutoCompSetIgnoreCase(True) # so this needs to match - - # Images are specified with an appended "?type" - for i in range(len(kw)): - if kw[i] in keyword.kwlist: - kw[i] = kw[i] + "?1" - self.AutoCompSetDropRestOfWord(True) - self.AutoCompSetSeparator(ord(';')) - self.AutoCompShow(0, ";".join(kw)) - """ selected = self.get_selected_or_near_text() sugs = [] for start in selected: