From 2f2b6825d3d3454266a4e5b4ace1afff96cd6b8a Mon Sep 17 00:00:00 2001 From: Helio Guilherme Date: Wed, 20 Sep 2023 01:09:31 +0100 Subject: [PATCH 1/2] Fix missing link indication in User Keyword when pressing Ctrl in Grid Editor --- CHANGELOG.adoc | 1 + src/robotide/application/CHANGELOG.html | 3 ++- src/robotide/application/releasenotes.py | 3 ++- src/robotide/editor/kweditor.py | 17 ++++++++--------- src/robotide/editor/texteditor.py | 4 +++- src/robotide/version.py | 2 +- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 7a5a997fa..05742aa8b 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -18,6 +18,7 @@ and this project adheres to http://semver.org/spec/v2.0.0.html[Semantic Versioni === Fixed +- Fixed missing indication of link for User Keyword, when pressing ``Ctrl`` in Grid Editor - Fixed exception when finding GREY color for excluded files and directories in Project Tree - Colorization of Grid Editor cells after the continuation marker ``...`` and correct parsing of those lines - Colorization of Grid Editor cells when contents is list or dictionary variables diff --git a/src/robotide/application/CHANGELOG.html b/src/robotide/application/CHANGELOG.html index d780e5679..bd9429807 100644 --- a/src/robotide/application/CHANGELOG.html +++ b/src/robotide/application/CHANGELOG.html @@ -10,7 +10,8 @@ Added variables creation shortcuts (``Ctrl-1,2,5``) to fields Arguments in Grid Editor
  • Added support for JSON variables, by using the installed Robot Framework import method -
  • 1.2. Fixed

    • +

    1.2. Fixed

      +
    • Fixed missing indication of link for User Keyword, when pressing ``Ctrl`` in Grid Editor
    • Fixed exception when finding GREY color for excluded files and directories in Project Tree
    • Colorization of Grid Editor cells after the continuation marker ``…`` and correct parsing of those lines diff --git a/src/robotide/application/releasenotes.py b/src/robotide/application/releasenotes.py index a9aa4ff6b..d9c660646 100644 --- a/src/robotide/application/releasenotes.py +++ b/src/robotide/application/releasenotes.py @@ -168,6 +168,7 @@ def set_content(self, html_win, content):

    New Features and Fixes Highlights

      +
    • Fixed missing indication of link for User Keyword, when pressing Ctrl in Grid Editor
    • 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
    • @@ -237,6 +238,6 @@ def set_content(self, html_win, content):
       python -m robotide.postinstall -install
       
      -

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

      +

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

    """ diff --git a/src/robotide/editor/kweditor.py b/src/robotide/editor/kweditor.py index 8818b8c68..75a0bffc2 100755 --- a/src/robotide/editor/kweditor.py +++ b/src/robotide/editor/kweditor.py @@ -113,7 +113,7 @@ def __init__(self, parent, controller, tree): self._controller.datafile_controller.register_for_namespace_updates( self._namespace_updated) self._tooltips = GridToolTips(self) - self._marked_cell = None + self._marked_cell = (-1, -1) self._make_bindings() self._write_steps(self._controller) self.autosize() @@ -256,9 +256,11 @@ def on_kill_focus(self, event): def _execute(self, command): return self._controller.execute(command) - def _toggle_underlined(self, cell): + def _toggle_underlined(self, cell, clear=False): font = self.GetCellFont(cell.Row, cell.Col) - font.SetUnderlined(not font.Underlined) + toggle = not font.GetUnderlined() if not clear else False + self._marked_cell = cell if toggle else (-1, -1) + font.SetUnderlined(toggle) self.SetCellFont(cell.Row, cell.Col, font) self.Refresh() @@ -731,7 +733,6 @@ def _cell_value(self, cell): def _show_user_keyword_link(self, cell, value): if cell != self._marked_cell and self._plugin.get_user_keyword(value): self._toggle_underlined(cell) - self._marked_cell = cell def _show_keyword_details(self, cell, value): details = self._plugin.get_keyword_details(value) @@ -872,8 +873,7 @@ def _navigate_to_matching_user_keyword(self, row, col): value = self.GetCellValue(row, col) uk = self._plugin.get_user_keyword(value) if uk: - self._toggle_underlined((grid.GridCellCoords(row, col))) - self._marked_cell = None + self._toggle_underlined((grid.GridCellCoords(row, col)), True) wx.CallAfter(self._tree.select_user_keyword_node, uk) return True return False @@ -882,10 +882,9 @@ def _is_active_window(self): return self.IsShownOnScreen() and self.FindFocus() def _hide_link_if_necessary(self): - if not self._marked_cell: + if self._marked_cell == (-1, -1): return - self._toggle_underlined(self._marked_cell) - self._marked_cell = None + self._toggle_underlined(self._marked_cell, True) def on_create_keyword(self, event): _ = event diff --git a/src/robotide/editor/texteditor.py b/src/robotide/editor/texteditor.py index 98ec29bd2..e65a7d5f6 100644 --- a/src/robotide/editor/texteditor.py +++ b/src/robotide/editor/texteditor.py @@ -1523,7 +1523,9 @@ def show_kw_doc(self): def hide_kw_doc(self): if self._information_popup: - self._information_popup.hide() + # self._information_popup.hide() + self._information_popup.Show(False) + self._information_popup.Destroy() self._information_popup = None def on_key_pressed(self, event): diff --git a/src/robotide/version.py b/src/robotide/version.py index ae412d3f3..ba16c9b85 100644 --- a/src/robotide/version.py +++ b/src/robotide/version.py @@ -14,4 +14,4 @@ # limitations under the License. # # Automatically generated by `tasks.py`. -VERSION = 'v2.0.8dev12' +VERSION = 'v2.0.8dev13' From 20240c903ff5f49289d8c5a306b0e43f47cfbe76 Mon Sep 17 00:00:00 2001 From: Helio Guilherme Date: Wed, 20 Sep 2023 22:53:28 +0100 Subject: [PATCH 2/2] Fix closing of kw doc when Ctrl is released --- src/robotide/editor/texteditor.py | 61 ++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/src/robotide/editor/texteditor.py b/src/robotide/editor/texteditor.py index e65a7d5f6..05db6e208 100644 --- a/src/robotide/editor/texteditor.py +++ b/src/robotide/editor/texteditor.py @@ -405,6 +405,7 @@ def __init__(self, plugin, parent, title, data_validator): self._controller_for_context = None self._suggestions = None self._stored_text = None + self.old_information_popup = None PUBLISHER.subscribe(self.on_settings_changed, RideSettingsChanged) PUBLISHER.subscribe(self.on_tab_change, RideNotebookTabChanging) @@ -856,15 +857,18 @@ def _create_editor_text_control(self, text=None): self.Sizer.Layout() if text is not None: self.source_editor.set_text(text) + self._kw_doc_timer = wx.Timer(self.source_editor) self.source_editor.Bind(wx.EVT_KEY_DOWN, self.on_key_down) self.source_editor.Bind(wx.EVT_CHAR, self.on_char) self.source_editor.Bind(wx.EVT_KEY_UP, self.on_editor_key) + self.source_editor.Bind(wx.EVT_MOTION, self.on_mouse_motion) self.source_editor.Bind(wx.EVT_KILL_FOCUS, self.LeaveFocus) self.source_editor.Bind(wx.EVT_SET_FOCUS, self.GetFocus) # DEBUG: Add here binding for keyword help def LeaveFocus(self, event): _ = event + self.source_editor.hide_kw_doc() self.source_editor.AcceptsFocusFromKeyboard() self.store_position() self.source_editor.SetCaretPeriod(0) @@ -942,6 +946,7 @@ def on_key_down(self, event): else: self.delete_row(event) elif event.ControlDown() and keycode == 0: + # coords = self._get_screen_coordinates() self.source_editor.show_kw_doc() else: event.Skip() @@ -953,6 +958,12 @@ def on_key_down(self, event): self.execute_sharp_uncomment() self.store_position() """ + @staticmethod + def _get_screen_coordinates(): + point = wx.GetMousePosition() + point.x += 25 + point.y += 25 + return point def on_char(self, event): if not self.is_focused(): @@ -964,6 +975,20 @@ def on_char(self, event): else: event.Skip() + def on_mouse_motion(self, event): + if event.CmdDown(): + self._kw_doc_timer.Stop() + # self.source_editor.show_kw_doc() + else: + if self.old_information_popup != self.source_editor._information_popup: + self.source_editor.hide_kw_doc() + self.old_information_popup = self.source_editor._information_popup + self._start_kw_doc_timer() + event.Skip() + + def _start_kw_doc_timer(self): + self._kw_doc_timer.Start(1000, True) + def execute_variable_creator(self, list_variable=False, dict_variable=False): from_, to_ = self.source_editor.GetSelection() text = self.source_editor.SelectedText @@ -1493,8 +1518,7 @@ def __init__(self, parent, readonly=False): self._plugin = parent.plugin self._settings = parent.source_editor_parent.app.settings self._information_popup = None - self.old_position = None - self.old_select = [] + self._old_details = None self.readonly = readonly self.SetMarginType(self.margin, stc.STC_MARGIN_NUMBER) self.SetLexer(stc.STC_LEX_CONTAINER) @@ -1513,25 +1537,24 @@ def __init__(self, parent, readonly=False): self.RegisterImage(2, wx.ArtProvider.GetBitmap(wx.ART_NEW, size=(16, 16))) self.RegisterImage(3, wx.ArtProvider.GetBitmap(wx.ART_COPY, size=(16, 16))) - def show_kw_doc(self): + def show_kw_doc(self, coords=None): if self.AutoCompActive(): selected = [self.AutoCompGetCurrentText()] else: selected = self.get_selected_or_near_text(keep_cursor_pos=True) for kw in selected: - self._show_keyword_details(kw) + self._show_keyword_details(kw, coords) def hide_kw_doc(self): - if self._information_popup: - # self._information_popup.hide() - self._information_popup.Show(False) - self._information_popup.Destroy() - self._information_popup = None + list_of_popups = self.parent.GetChildren() + for popup in list_of_popups: + if isinstance(popup, HtmlPopupWindow): + popup.hide() + self._old_details = None def on_key_pressed(self, event): if self.CallTipActive(): self.CallTipCancel() - self.hide_kw_doc() key = event.GetKeyCode() if key == 32 and event.ControlDown(): pos = self.GetCurrentPos() @@ -1719,17 +1742,21 @@ def on_update_ui(self, evt): else: self.BraceHighlight(brace_at_caret, brace_opposite) - def _show_keyword_details(self, value): + def _show_keyword_details(self, value, coords=None): details = self._plugin.get_keyword_details(value) - if details: - wpos = self.parent.source_editor_parent.GetPosition() - npos = self.parent.GetPosition() - position = self.GetCurrentPos() - position = self.PointFromPosition(position) - position = position + wpos + npos + if details and details != self._old_details: # This is because on Windows keys are sent in repeat + if not coords: + wpos = self.parent.source_editor_parent.GetPosition() + npos = self.parent.GetPosition() + position = self.GetCurrentPos() + position = self.PointFromPosition(position) + position = position + wpos + npos + else: + position = coords self._information_popup = HtmlPopupWindow(self.parent, (450, 300)) self._information_popup.set_content(details, value) self._information_popup.show_at(position) + self._old_details = details class FromStringIOPopulator(robotapi.populators.FromFilePopulator):