Skip to content

Commit

Permalink
Merge pull request #2640 from HelioGuilherme66/fix_text_edit_help
Browse files Browse the repository at this point in the history
Fix text edit help
  • Loading branch information
HelioGuilherme66 authored Sep 20, 2023
2 parents 07209f8 + 20240c9 commit b536850
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/robotide/application/CHANGELOG.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
Added variables creation shortcuts (``Ctrl-1,2,5``) to fields Arguments in Grid Editor
</li><li class="listitem">
Added support for JSON variables, by using the installed Robot Framework import method
</li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_fixed"></a>1.2. Fixed</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
</li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_fixed"></a>1.2. Fixed</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">Fixed missing indication of link for User Keyword, when pressing ``Ctrl`` in Grid Editor</li><li class="listitem">
Fixed exception when finding GREY color for excluded files and directories in Project Tree
</li><li class="listitem">
Colorization of Grid Editor cells after the continuation marker ``…`` and correct parsing of those lines
Expand Down
3 changes: 2 additions & 1 deletion src/robotide/application/releasenotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def set_content(self, html_win, content):
</ul>
<p><strong>New Features and Fixes Highlights</strong></p>
<ul class="simple">
<li>Fixed missing indication of link for User Keyword, when pressing <b>Ctrl</b> in Grid Editor</li>
<li>Added content help pop-up on Text Editor by pressing <b>Ctrl-M</b> for text at cursor position or selected autocomplete list item</li>
<li>Added Exclude option in context nenu for Test files, previously was only possible for Test Suites folders</li>
<li>Added exclusion of monitoring filesystem changes for files and directories excluded in Preferences</li>
Expand Down Expand Up @@ -237,6 +238,6 @@ def set_content(self, html_win, content):
<pre class="literal-block">
python -m robotide.postinstall -install
</pre>
<p>RIDE {VERSION} was released on 19/Sep/2023.</p>
<p>RIDE {VERSION} was released on 20/Sep/2023.</p>
</div>
"""
17 changes: 8 additions & 9 deletions src/robotide/editor/kweditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
59 changes: 44 additions & 15 deletions src/robotide/editor/texteditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -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():
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -1513,23 +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 = 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()
Expand Down Expand Up @@ -1717,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):
Expand Down
2 changes: 1 addition & 1 deletion src/robotide/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# limitations under the License.
#
# Automatically generated by `tasks.py`.
VERSION = 'v2.0.8dev12'
VERSION = 'v2.0.8dev13'

0 comments on commit b536850

Please sign in to comment.