Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/robotide/editor/customsourceeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
class SourceCodeEditor(PythonSTC):
def __init__(self, parent, options, style=wx.BORDER_NONE):
PythonSTC.__init__(self, parent, -1, options, style=style)
self.SetUpEditor(options)
self.SetUpEditor()

# Some methods to make it compatible with how the wxTextCtrl is used
def SetValue(self, value):
Expand Down Expand Up @@ -90,7 +90,7 @@ def SelectLine(self, line):
end = self.GetLineEndPosition(line)
self.SetSelection(start, end)

def SetUpEditor(self, eoptions: dict):
def SetUpEditor(self):
"""
This method carries out the work of setting up the Code editor.
It's seperate so as not to clutter up the init code.
Expand Down Expand Up @@ -122,13 +122,13 @@ def SetUpEditor(self, eoptions: dict):
self.SetTabWidth(4) # Proscribed tab size for wx
self.SetUseTabs(False) # Use spaces rather than tabs, or TabTimmy will complain!
# White space
self.SetViewWhiteSpace(eoptions['visible spaces']) # Don't view white space
self.SetViewWhiteSpace(False) # Don't view white space

# EOL: Since we are loading/saving ourselves, and the
# strings will always have \n's in them, set the STC to
# edit them that way.
self.SetEOLMode(wx.stc.STC_EOL_LF)
self.SetViewEOL(eoptions['visible EOL'])
self.SetViewEOL(False)

# No right-edge mode indicator
self.SetEdgeMode(stc.STC_EDGE_NONE)
Expand Down Expand Up @@ -232,8 +232,7 @@ def __init__(self, parent, main_frame, filepath=None):
self.parent = parent
wx.Panel.__init__(self, parent, size=wx.Size(1, 1))
self.mainFrame = main_frame
self.editor = SourceCodeEditor(self, options={'tab markers':True, 'fold symbols':2,
'visible spaces':True, 'visible EOL':True})
self.editor = SourceCodeEditor(self, options={'tab markers':True, 'fold symbols':2})
self.editor.RegisterModifiedEvent(self.on_code_modified)
parent.SetName(f'Code Editor: {filepath}')
"""
Expand Down Expand Up @@ -301,9 +300,11 @@ def on_save(self, event, filepath=None):
return
if filepath:
if filepath != self.path and os.path.isfile(filepath):
overwrite_msg = "You are about to overwrite an existing file\n" + \
"Do you want to continue?"
dlg = wx.MessageDialog(self, overwrite_msg, "Editor Writer",
overwrite_msg = _("You are about to overwrite an existing file.\n\n") + \
_("File: %s\n\n") % filepath + \
_("The existing file will be replaced and cannot be recovered.\n\n") + \
_("Do you want to continue?")
dlg = wx.MessageDialog(self, overwrite_msg, _("Confirm Overwrite"),
wx.YES_NO | wx.NO_DEFAULT | wx.ICON_EXCLAMATION)
dlg.SetBackgroundColour(Colour(200, 222, 40))
dlg.SetForegroundColour(Colour(7, 0, 70))
Expand Down
38 changes: 20 additions & 18 deletions src/robotide/editor/texteditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,11 +776,16 @@ def _old_handle_sanity_check_failure(self):
self._editor._mark_file_dirty()
return False
# TODO: use widgets.Dialog
id = wx.MessageDialog(self._editor,
'ERROR: Data sanity check failed!\n'
'Reset changes?',
'Can not apply changes from Txt Editor',
style=wx.YES | wx.NO).ShowModal()
msg = _('ERROR: Data sanity check failed!') + '\n\n' + \
_('The text content could not be parsed correctly.') + '\n' + \
_('This may be caused by:') + '\n' + \
_(' - Invalid Robot Framework syntax') + '\n' + \
_(' - Malformed table or section headers') + '\n' + \
_(' - Incorrect indentation or spacing') + '\n\n' + \
_('Reset changes?')
id = wx.MessageDialog(self._editor, msg,
_('Can not apply changes from Text Editor'),
style=wx.YES | wx.NO | wx.ICON_ERROR).ShowModal()
self._last_answer = id
self._last_answer_time = time()
if id == wx.ID_YES:
Expand Down Expand Up @@ -907,8 +912,12 @@ def _handle_sanity_check_failure(self, message):
# self.source_editor._mark_file_dirty(True)
return False
dlg = RIDEDialog(title=_("Can not apply changes from Text Editor"),
message=f"{_('ERROR: Data sanity check failed!')}\n{_('Error at line')}"
f" {message[1]}:\n{message[0]}\n\n{_('Reset changes?')}",
message=f"{_('ERROR: Data sanity check failed!')}\n\n"
f"{_('Error at line')} {message[1]}:\n"
f" {message[0]}\n\n"
f"{_('This may be caused by invalid syntax or formatting.')}\n"
f"{_('Check the line and fix the error, or reset changes.')}\n\n"
f"{_('Reset changes?')}",
style=wx.ICON_ERROR | wx.YES_NO)
dlg.InheritAttributes()
did = dlg.ShowModal()
Expand Down Expand Up @@ -2641,11 +2650,8 @@ def __init__(self, parent, readonly=False, language=None, style=wx.BORDER_NONE):
self._settings = parent.source_editor_parent.app.settings
self.tab_markers = self._settings[PLUGIN_NAME].get('tab markers', True)
self.fold_symbols = self._settings[PLUGIN_NAME].get('fold symbols', 2)
self.visible_spaces = self._settings[PLUGIN_NAME].get('enable visible spaces', True)
self.visible_EOL = self._settings[PLUGIN_NAME].get('enable visible newlines', False)
PythonSTC.__init__(self, parent, -1, options={'tab markers':self.tab_markers, 'fold symbols':self.fold_symbols,
'visible spaces':self.visible_spaces,
'visible EOL':self.visible_EOL}, style=style)
PythonSTC.__init__(self, parent, -1, options={'tab markers':self.tab_markers, 'fold symbols':self.fold_symbols},
style=style)
self._information_popup = None
self._old_details = None
self.readonly = readonly
Expand Down Expand Up @@ -2979,13 +2985,13 @@ def SetUpEditor(self, tab_size=4, tab_markers=True, m_bg='', m_fg='', caret_fg:
self.SetTabWidth(tab_size) # Proscribed tab size for wx
self.SetUseTabs(False) # Use spaces rather than tabs, or TabTimmy will complain!
# White space
self.SetViewWhiteSpace(self.visible_spaces) # View white space
self.SetViewWhiteSpace(False) # Don't view white space

# EOL: Since we are loading/saving ourselves, and the
# strings will always have \n's in them, set the STC to
# edit them that way.
self.SetEOLMode(wx.stc.STC_EOL_LF)
self.SetViewEOL(self.visible_EOL)
self.SetViewEOL(False)

# No right-edge mode indicator
self.SetEdgeMode(stc.STC_EDGE_NONE)
Expand Down Expand Up @@ -3091,8 +3097,6 @@ def on_settings_changed(self, message):
if section == PLUGIN_NAME:
self.set_styles(self._readonly) # DEBUG: When on read-only file changing background color ignores flag
self.editor.autocomplete = self.settings[PLUGIN_NAME].get(AUTO_SUGGESTIONS, False)
self.editor.visible_spaces = self.settings[PLUGIN_NAME].get('enable visible spaces', True)
self.editor.visible_EOL = self.settings[PLUGIN_NAME].get('enable visible newlines', False)
caret_colour = self.settings[PLUGIN_NAME].get('setting', 'black')
caret_colour = self.editor.get_visible_color(caret_colour)
self.editor.SetCaretForeground(Colour(caret_colour))
Expand Down Expand Up @@ -3181,8 +3185,6 @@ def set_styles(self, readonly=False):
fore=foreground))
self.editor.StyleSetBackground(wx.stc.STC_STYLE_DEFAULT, background)
self.editor.SetZoom(self._zoom_factor())
self.editor.SetViewWhiteSpace(self.editor.visible_spaces)
self.editor.SetViewEOL(self.editor.visible_EOL)
self.editor.Refresh()

def _get_word_and_length(self, current_position):
Expand Down
14 changes: 11 additions & 3 deletions src/robotide/ui/mainframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,23 @@ def _create_title(message):

@staticmethod
def _show_validation_error(message):
message_box = RIDEDialog(title=_('Validation Error'), message=message.message, style=wx.ICON_ERROR|wx.OK)
error_msg = message.message
help_text = "\n\n" + _("Common causes:") + "\n" + _(" - Invalid characters in name") + "\n" + _(" - Name too long or empty") + "\n" + _(" - Duplicate name already exists")
message_box = RIDEDialog(title=_('Validation Error'),
message=error_msg + help_text,
style=wx.ICON_ERROR|wx.OK)
message_box.ShowModal()

@staticmethod
def _show_modification_prevented_error(message):
filename = message.controller.datafile_controller.filename
message_box = RIDEDialog(title=_("Modification prevented"),
message=_("\"%s\" is read only") % message.controller.datafile_controller.filename,
message=_("\"%s\" is read only.\n\n") % filename +
_("To make changes:\n") +
_(" 1. Close the file in RIDE\n") +
_(" 2. Change file permissions in your file manager\n") +
_(" 3. Reopen the file in RIDE"),
style=wx.ICON_ERROR|wx.OK)
# message_box.CenterOnParent()
message_box.ShowModal()

def _init_ui(self):
Expand Down
Loading