Skip to content

Commit c7a3062

Browse files
Make visible spaces and newlines in Text Editor. (#3026)
* Add options to make visible spaces and newlines in Text Editor. * Fix 'General' settings not available after upgrade (blocks startup) (#3013) - Add migration from settings version 8 to 9 that ensures General section exists with all required keys - Add safe access to General settings in application.py, mainframe.py, treeplugin.py, and dialog.py - Use .get() with fallback values instead of direct dictionary access - This prevents KeyError when user settings file is missing or corrupted Closes #3000 * Enable visible spaces and newlines in External/Code Editor. --------- Co-authored-by: ChelSlava <chelslava@gmail.com>
1 parent 9abf0c5 commit c7a3062

File tree

16 files changed

+78
-269
lines changed

16 files changed

+78
-269
lines changed

AUTHORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Petr Hudeček
3232
Timothy Alexander
3333
@2Eagle2
3434
@bale836
35+
@chelslava
3536
@fzuellich
3637
@ghost
3738
@goodwillcoding

CHANGELOG.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ and this project adheres to http://semver.org/spec/v2.0.0.html[Semantic Versioni
88

99
== https://github.com/robotframework/RIDE[Unreleased]
1010

11+
=== Added
12+
- Added on Text Editor, (Preferences->Text Editor) option to *Enable visible spaces* configurable with ``enable visible spaces`` in settings.cfg, with default ``True``.
13+
- Added on Text Editor, (Preferences->Text Editor) option to *Enable visible newlines* configurable with ``enable visible newlines`` in settings.cfg, with default ``False``.
14+
- Added on External/Code Editor, both enabled, ``visible spaces`` and ``visible newlines``.
15+
16+
=== Fixed
17+
- Fixed exception seen in console when selecting Tools->Library Finder... on a clean install.
18+
1119
=== Changed
1220
- Changed isbinary to be internal library, instead of being dependency.
1321

README.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ See the https://github.com/robotframework/RIDE/blob/master/doc/releasenotes/ride
4040

4141
Currently, the unit tests are tested on Python 3.10, 3.11 and 3.14.
4242
We now have an experimental workflow on Fedora Linux 42, with wxPython 4.2.4 and Python 3.14.
43-
Likewise, the current version of wxPython, is 4.2.4, but RIDE is known to work with 4.0.7, 4.1.1, 4.2.2, 4.2.3 and 4.2.4 versions.
43+
Likewise, the current version of wxPython, is 4.2.5, but RIDE is known to work with 4.0.7, 4.1.1, 4.2.2, 4.2.3, 4.2.4 and 4.2.5 versions.
4444

4545
(3.9 &lt;= python &lt;= 3.14) Install current released version (*2.2.2*) with:
4646

4747
`pip install -U robotframework-ride`
4848

49-
(3.9 &lt;= python &lt;= 3.14) Install current development version (**2.2.3dev3**) with:
49+
(3.9 &lt;= python &lt;= 3.14) Install current development version (**2.2.3dev4**) with:
5050

5151
`pip install -U https://github.com/robotframework/RIDE/archive/develop.zip`
5252

src/robotide/application/releasenotes.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def set_content(self, html_win, content):
150150
151151
<p><a class="reference external" href="https://github.com/robotframework/RIDE/">RIDE (Robot Framework IDE)</a>
152152
{VERSION} is a new release with some enhancements and bug fixes. The reference for valid arguments is
153-
<a class="reference external" href="https://robotframework.org/">Robot Framework</a> current version, 7.4.1. However,
153+
<a class="reference external" href="https://robotframework.org/">Robot Framework</a> current version, 7.4.2. However,
154154
internal library code is originally based on version 3.1.2, but adapted for new versions.</p>
155155
<ul class="simple">
156156
<li>This version supports Python 3.9 up to 3.14.</li>
@@ -179,6 +179,10 @@ def set_content(self, html_win, content):
179179
</ul>
180180
<p><strong>New Features and Fixes Highlights</strong></p>
181181
<ul class="simple">
182+
<li>Added on Text Editor, (Preferences->Text Editor) options to <b>Enable visible spaces</b> and
183+
<b>Enable visible newlines</b>.</li>
184+
<li>Added on External/Code Editor, both enabled, <b>visible spaces<b> and <b>visible newlines<b>.</li>
185+
<li>Fixed exception seen in console when selecting Tools->Library Finder... on a clean install.</li>
182186
<li>The Test Suites Explorer can be visible or hidden with F12 (View->View Test Suites Explorer). Pane can be made
183187
floating or docked, by dragging or by double-clicking its top bar.</li>
184188
<li>In File Explorer opening non-text files is done by the operating system registered app.</li>
@@ -192,7 +196,7 @@ def set_content(self, html_win, content):
192196
</ul>
193197
<!-- <p>We hope to implement or complete features and make fixes on next major version 2.1 (in mid Autumm of 2024).</p>
194198
-->
195-
<p><strong>The minimal wxPython version is, 4.0.7, and RIDE supports the current version, 4.2.4, which we recommend.
199+
<p><strong>The minimal wxPython version is, 4.0.7, and RIDE supports the current version, 4.2.5, which we recommend.
196200
</strong></p>
197201
<p><em>Linux users are advised to install first wxPython from .whl package at</em> <a class="reference external"
198202
href="https://extras.wxpython.org/wxPython4/extras/linux/gtk3/">wxPython.org</a>, or by using the system package
@@ -243,7 +247,7 @@ def set_content(self, html_win, content):
243247
<pre class="literal-block">python -m robotide.postinstall -install</pre>
244248
<p>or</p>
245249
<pre class="literal-block">ride_postinstall.py -install</pre>
246-
<p>RIDE {VERSION} was released on 11/January/2026.</p>
250+
<p>RIDE {VERSION} was released on 29/March/2026.</p>
247251
<br/>
248252
<!--
249253
<h3>Celebrate the bank holiday, 1st December, Restoration of the Independence of Portugal (from Spain in 1640)!!</h3>

src/robotide/editor/customsourceeditor.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
class SourceCodeEditor(PythonSTC):
4141
def __init__(self, parent, options, style=wx.BORDER_NONE):
4242
PythonSTC.__init__(self, parent, -1, options, style=style)
43-
self.SetUpEditor()
43+
self.SetUpEditor(options)
4444

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

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

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

133133
# No right-edge mode indicator
134134
self.SetEdgeMode(stc.STC_EDGE_NONE)
@@ -232,7 +232,8 @@ def __init__(self, parent, main_frame, filepath=None):
232232
self.parent = parent
233233
wx.Panel.__init__(self, parent, size=wx.Size(1, 1))
234234
self.mainFrame = main_frame
235-
self.editor = SourceCodeEditor(self, options={'tab markers':True, 'fold symbols':2})
235+
self.editor = SourceCodeEditor(self, options={'tab markers':True, 'fold symbols':2,
236+
'visible spaces':True, 'visible EOL':True})
236237
self.editor.RegisterModifiedEvent(self.on_code_modified)
237238
parent.SetName(f'Code Editor: {filepath}')
238239
"""

src/robotide/editor/pythoneditor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ def __init__(self, parent, idd, options: dict, pos=wx.DefaultPosition, size=wx.D
5959
self.SetProperty("tab.timmy.whinge.level", "1")
6060
self.SetMargins(2, 2)
6161

62-
self.SetViewWhiteSpace(False)
62+
self.visible_spaces = options['visible spaces']
63+
self.visible_EOL = options['visible EOL']
64+
self.SetViewWhiteSpace(self.visible_spaces)
65+
self.SetViewEOL(self.visible_EOL)
6366
self.SetEdgeMode(stc.STC_EDGE_BACKGROUND)
6467
self.SetEdgeColumn(78)
6568

src/robotide/editor/texteditor.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2641,8 +2641,11 @@ def __init__(self, parent, readonly=False, language=None, style=wx.BORDER_NONE):
26412641
self._settings = parent.source_editor_parent.app.settings
26422642
self.tab_markers = self._settings[PLUGIN_NAME].get('tab markers', True)
26432643
self.fold_symbols = self._settings[PLUGIN_NAME].get('fold symbols', 2)
2644-
PythonSTC.__init__(self, parent, -1, options={'tab markers':self.tab_markers, 'fold symbols':self.fold_symbols},
2645-
style=style)
2644+
self.visible_spaces = self._settings[PLUGIN_NAME].get('enable visible spaces', True)
2645+
self.visible_EOL = self._settings[PLUGIN_NAME].get('enable visible newlines', False)
2646+
PythonSTC.__init__(self, parent, -1, options={'tab markers':self.tab_markers, 'fold symbols':self.fold_symbols,
2647+
'visible spaces':self.visible_spaces,
2648+
'visible EOL':self.visible_EOL}, style=style)
26462649
self._information_popup = None
26472650
self._old_details = None
26482651
self.readonly = readonly
@@ -2976,13 +2979,13 @@ def SetUpEditor(self, tab_size=4, tab_markers=True, m_bg='', m_fg='', caret_fg:
29762979
self.SetTabWidth(tab_size) # Proscribed tab size for wx
29772980
self.SetUseTabs(False) # Use spaces rather than tabs, or TabTimmy will complain!
29782981
# White space
2979-
self.SetViewWhiteSpace(False) # Don't view white space
2982+
self.SetViewWhiteSpace(self.visible_spaces) # View white space
29802983

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

29872990
# No right-edge mode indicator
29882991
self.SetEdgeMode(stc.STC_EDGE_NONE)
@@ -3088,6 +3091,8 @@ def on_settings_changed(self, message):
30883091
if section == PLUGIN_NAME:
30893092
self.set_styles(self._readonly) # DEBUG: When on read-only file changing background color ignores flag
30903093
self.editor.autocomplete = self.settings[PLUGIN_NAME].get(AUTO_SUGGESTIONS, False)
3094+
self.editor.visible_spaces = self.settings[PLUGIN_NAME].get('enable visible spaces', True)
3095+
self.editor.visible_EOL = self.settings[PLUGIN_NAME].get('enable visible newlines', False)
30913096
caret_colour = self.settings[PLUGIN_NAME].get('setting', 'black')
30923097
caret_colour = self.editor.get_visible_color(caret_colour)
30933098
self.editor.SetCaretForeground(Colour(caret_colour))
@@ -3176,6 +3181,8 @@ def set_styles(self, readonly=False):
31763181
fore=foreground))
31773182
self.editor.StyleSetBackground(wx.stc.STC_STYLE_DEFAULT, background)
31783183
self.editor.SetZoom(self._zoom_factor())
3184+
self.editor.SetViewWhiteSpace(self.editor.visible_spaces)
3185+
self.editor.SetViewEOL(self.editor.visible_EOL)
31793186
self.editor.Refresh()
31803187

31813188
def _get_word_and_length(self, current_position):

src/robotide/preferences/editors.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,19 @@ def on_reset(self, event):
226226

227227
def _create_text_config_editor(self):
228228
settings = self._settings
229-
sizer = wx.FlexGridSizer(rows=2, cols=2, vgap=10, hgap=10)
229+
sizer = wx.FlexGridSizer(rows=4, cols=2, vgap=10, hgap=10)
230230
l_auto_suggest, editor = pdiag.boolean_editor(self, settings, 'enable auto suggestions',
231231
_('Enable auto suggestions'))
232232
set_colors(l_auto_suggest, self.background_color, self.foreground_color)
233233
sizer.AddMany([l_auto_suggest, editor])
234+
l_visible_spaces, editor = pdiag.boolean_editor(self, settings, 'enable visible spaces',
235+
_('Enable visible spaces'))
236+
set_colors(l_visible_spaces, self.background_color, self.foreground_color)
237+
sizer.AddMany([l_visible_spaces, editor])
238+
l_visible_newlines, editor = pdiag.boolean_editor(self, settings, 'enable visible newlines',
239+
_('Enable visible newlines'))
240+
set_colors(l_visible_newlines, self.background_color, self.foreground_color)
241+
sizer.AddMany([l_visible_newlines, editor])
234242
return sizer
235243

236244

src/robotide/preferences/settings.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ tc_kw_name = '#1A5FB4'
7171
variable = '#008080'
7272
background = '#F6F5F4'
7373
enable auto suggestions = True
74+
enable visible spaces = True
75+
enable visible newlines = True
7476

7577
[Grid]
7678
font size = 10

0 commit comments

Comments
 (0)