Page MenuHome

Text Editor UI updates
AbandonedPublic

Authored by William Reynish (billreynish) on Jun 6 2019, 10:58 AM.

Details

Summary

This patch makes a few changes to the Text Editor to make it fit in with Blender 2.8 more.

The sidebar is moved to the right, which is more consistent, and also doesn't get in the way of the line numbers, and also doesn't make the text jump when you open/close it.
Before:

After:


The sidebar uses the new layout system here.

Note: The sidebar needs a Do Version update to be complete.

The context menu is more fleshed out and useful:
Before:

After:

View toggles are in the View menu, similar to other editors such as the Dopesheet:

Before:

After:

Diff Detail

Event Timeline

I would even go further:

  • Remove icon/toggle from the top three items. The icons are really meant for the header only.
  • Use current nesting for Show Margin
  • Rename Properties to Display

TBH I think it might also just be nicer to move some of the toggles in the View menu.

Yes, there are many things which could be improved, but on the things you mention, most of the functions are still defined in C here:
https://developer.blender.org/diffusion/B/browse/master/source/blender/makesrna/intern/rna_space.c
... and I'm not able to code C. I'm sorry.

Just set toggle=False to make the icon toggles into normal checkboxes. You don't have to change RNA.

Turned the toggle-buttons into checkboxes.
Renamed Properties to Display
And Show Margin will determine visibility of Show Column:

For the nesting, I was thinking more like this:

Or this:

We try not to make things suddenly appear, which makes the UI elements jump around.

Peter Fog (tintwotin) updated this revision to Diff 15818.EditedJun 6 2019, 1:41 PM

Just removed "bpy." - not needed.

On you reply, imo:
#1 is a bit overkill.
#2 the Sidebar is too narrow for this.

I'll leave it up to you, how you prefer to design it(including adding elements to the View menu).

As for the Display panel, the Live Edit and Tabs as Spaces don't fit anymore. We probably should find a new home for those. We could add them to the Edit menu instead.

The Find panel should probably also be renamed to Find & Replace.

Peter Fog (tintwotin) edited the summary of this revision. (Show Details)Jun 13 2019, 1:01 AM
Peter Fog (tintwotin) updated this revision to Diff 15888.

The following Text Editor Redesign is the result of further discussion with @William Reynish (billreynish)

As mentioned everything has become right aligned.
Four settings has been moved into the View menu, in order to clean up the panel:

  • show_line_numbers
  • show_word_wrap
  • show_syntax_highlight
  • show_line_highlight

And one setting to the Edit menu:

  • use_live_edit

The Margin has been nested.

The Find and Replace options are now disabled if no text, like in Properties.

'Find' has been renamed to 'Find and Replace'
'Wrap' has been renamed to 'Wrap Around', which is also used in ex. Notepad, for continue F&R from the top.
'All' has been renamed to 'All Texts', because all in F&R normally means replacing all instances in the current text - but here it means continue F&R in all texts loaded in the text editor.

What still needs to be done is to change the 'Tabs as spaces' in the RNA for it can be moved into the Format menu. @William Reynish (billreynish) offered to do this. And if the default width of the Sidebar where a few pixels wider the last letter of the Margin could be read too.

Here's a gif showcasing the current design:

To be clear, you don’t need to change the RNA to put a checkbox on the menus.

We need to change RNA in order to turn it into an enum.

  • Fix wrong greying out of the Margin toggle

  • Change Tabs as Spaces to be an enum called Indentation, with Spaces or Tabs as choices

  • Remove Line Number, Word Wrap and Syntax Highlighting toggles from the header. I don't think these are necessary if they are in the View menu, and we get some space back for the things that are exclusive to the header

Changed layout of the Search & Replace panel:

  • Put settings at the top
  • Make the settings more compact
  • Use icons

Peter Fog (tintwotin) edited the summary of this revision. (Show Details)Jun 13 2019, 11:32 PM

Updates from D5125:

  • Add full context menu to Text Editor (with edits by me)
  • Move Text Editor Sidebar to the right, consistent with other editors, and doesn't clash with line numbers.
William Reynish (billreynish) retitled this revision from Convert Text Editor Sidebar to 2.80 Right-aligned style to Text Editor UI updates.Jun 23 2019, 1:02 AM

@Brecht Van Lommel (brecht) Sidebar is moved to the right here. May need help with Do Version to make it apply to already existing Text Editors.

This comment has been deleted.
William Reynish (billreynish) edited the summary of this revision. (Show Details)

Is this ready for review or are other changes planned?

@Campbell Barton (campbellbarton) it’s ready, except for the fact that I moved the Sidebar to the right. This requires some Do Version magic that neither @Peter Fog (tintwotin) or I can do.

I'm sorry. I'm hesitating a bit, because are we sure about the 'Download' icons? Or do we need more exact icons created for these buttons?
Are we sure, we want the Find&Replace settings above the search fields(normally these settings are below the search fields)?
Should Find&Replace be on top in the Sidebar. Having the most used functions on top?
Are we sure we do want Highlight Line unselected as default setting?

I'm sorry. I'm hesitating a bit, because are we sure about the 'Download' icons? Or do we need more exact icons created for these buttons?

We could also simply use the 'paste' icon here?

Are we sure, we want the Find&Replace settings above the search fields(normally these settings are below the search fields)?

I have no super strong opinion on that. Could do either I think.

Should Find&Replace be on top in the Sidebar. Having the most used functions on top?

Ideally, as we discussed earlier, Find & Replace should probably not even be in the sidebar, but a separate bar region similar to most text editors. But it's a lot more work to do this. We could place it as the first panel, yes.

Are we sure we do want Highlight Line unselected as default setting?

Most apps don't have this kind of thing enabled by default. I would leave that off.

On the icon, the first button seems to copy&paste&find, which I feel isn't covered with an Import icon or a Paste icon, but maybe that's just me? (Actually this function should have been build into the Find operator - so highlighting text and hit ctrl+f would do that, and there would be no need for a button). Maybe the Eyedropper icon could cover the process of extracting a string and add it to the panel? Maybe it's better, but it still doesn't cover the additional find function.

I would also prefer if we could get rid of this button altogether, and infer this depending on the selection when you launch Find & Replace. Might be outside the scope of this though, I certainly don't know how to implement that.

IMO we should just review and commit the changes in this patch, and then further changes can always happen later, if any developers feel like assisting with the Text Editor.

Oh, this is strange. I did a build with this patch, and now the Text Editor won't load a text block anymore. Can anyone confirm this?

EDIT: Hmm, not related to this patch. A current 2.81 build simply can't open a text block(2.80 luckily can).

Here are the small changes I mentioned above:


Unfortunately I can't update this patch(missing rights?), but here it is for download:

What has been done:
Find & Replace has been moved to the top of the panel, since it is used more than the properties.
Import icons has been changed to Eyedropper icons, since it makes more sense to, "extract" the selection into the panel.
The Find & Replace settings has been moved under the search boxes, since they are used less than the search boxes.
True align in each of the the Find and in the Replace columns.

A gif of the the Eyedropper buttons in action:

Here's the code to move the sidebar to the right:

1diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
2index cb2b649..545908c 100644
3--- a/source/blender/blenloader/intern/versioning_280.c
4+++ b/source/blender/blenloader/intern/versioning_280.c
5@@ -3535,5 +3535,18 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
6
7 {
8 /* Versioning code until next subversion bump goes here. */
9+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
10+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
11+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
12+ if (sl->spacetype == SPACE_TEXT) {
13+ ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
14+ ARegion *ar = do_versions_find_region(regionbase, RGN_TYPE_UI);
15+ if (ar) {
16+ ar->alignment = RGN_ALIGN_RIGHT;
17+ }
18+ }
19+ }
20+ }
21+ }
22 }
23 }
24diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
25index 24f282f..9a7debe 100644
26--- a/source/blender/editors/space_text/space_text.c
27+++ b/source/blender/editors/space_text/space_text.c
28@@ -82,7 +82,7 @@ static SpaceLink *text_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen
29
30 BLI_addtail(&stext->regionbase, ar);
31 ar->regiontype = RGN_TYPE_UI;
32- ar->alignment = RGN_ALIGN_LEFT;
33+ ar->alignment = RGN_ALIGN_RIGHT;
34 ar->flag = RGN_FLAG_HIDDEN;
35
36 /* main region */

This makes the Ctrl+T shortcut a little inconsistent, but Ctrl+N is already in use so I'm not sure there is much we can do.

Updated with the versioning code from @Brecht Van Lommel (brecht), and the latest layout tweaks from @Peter Fog (tintwotin).

IMO this is ready for review now.

release/scripts/startup/bl_ui/space_text.py
50–53

I'm not entirely sure about removing these, they don't take up that much space.

I feel like we should have better defaults for syntax highlighting and line numbers before we remove these from here.

Campbell Barton (campbellbarton) requested changes to this revision.Thu, Aug 1, 11:47 PM
Campbell Barton (campbellbarton) added inline comments.
release/scripts/startup/bl_ui/space_text.py
398–399

Think this isn't all that helpful, we had the same discussion before for the 3D view context menu.

Better not show options in the menu which you can't access later on because content exists.

"New" and "Open" are already displayed prominently in the header, if you already have a text data-block, it's no use to remember you can add new on RMB but only in rare cases.

Adding this makes it seem strange we don't have this everywhere else (3D View, image editor... etc).

Prefer not to show the menu at all in this case.

This revision now requires changes to proceed.Thu, Aug 1, 11:47 PM

Both suggestions are fine by me. What do @William Reynish (billreynish) say?

Yes I can update the context menu thing.

The line numbers etc we could enable by default too, although we already do that in the Scripting workspace.

release/scripts/startup/bl_ui/space_text.py
50–53

I would be fine with setting those options to be on by default, although we already do that in the Scripting workspace.

release/scripts/startup/bl_ui/space_text.py
50–53

I guess it would require some deeper changes to make it work well for different types of text automatically. Probably it's fine to just commit the patch as is and look at this later.

Some parts where rejected when I tried to apply this patch, but has the sidebar been moved to the right in the Workspace too?

Two thoughts on the UI, maybe for som other patches, but with the sidebar in the right hand side, maybe the panel background could have alpha so, all the space at the bottom of the panel could be used for text editing instead of just nothing. Like the panel in the 3D View:


But the scrollbar properly would have to stay on the right hand side of the sidebar to keep things tidy.
The other thought is that the 'Jump' function maybe also could be added to the sidebar, instead of a popup(which isn't in line with the current Blender way of doing things, I guess?)

  • Fixed the versioning code no longer applying to master
  • Removed the contextual part of the context menu for opening texts etc when none are selected.

Committed already.

  • Remove Line Number, Word Wrap and Syntax Highlighting toggles from the header. I don't think these are necessary if they are in the View menu, and we get some space back for the things that are exclusive to the header

I'm quite unhappy with this change. Previously those three toggles were easily enabled with one mouse drag across the header. This would turn a plain text editor into a Python editor in one drag, making it much easier to use read code. I use this all the time when using right-click, Edit Source, and inspecing how the UI is built. What was one quick drag is now six clicks.

I agree that hiding everything behind dropdown menus is super annoying and doesn't improve the UI at all.
Register Script is still an item in the header, taking up way more space than those 3 toggles we previously had, even though I believe that one is used far less.
Luckily it seems that the default is that syntax highlighting and numbers are enabled by default. So it doesnt hurt so much in this case.
In general I'd wish that items in the header were not regarded as visual clutter so much.

Luckily it seems that the default is that syntax highlighting and numbers are enabled by default. So it doesnt hurt so much in this case.

This is only the case for the open-by-default text editor in the Scripting workspace. They are not enabled by default for text editors in general, as can be seen when switching any editor to the text editor (f.e. pressing Shift+F11 in the 3D view). Since the "Edit Source" context menu item only auto-opens the file and auto-scrolls to the correct line when the text editor is in the current workspace, this default in the Scripting workspace doesn't help much.

Since the "Edit Source" context menu item only auto-opens the file and auto-scrolls to the correct line when the text editor is in the current workspace, this default in the Scripting workspace doesn't help much.

Oh damn. In that case I would like this change to be reverted. Or always enable those options. Or make it possible to enable multiple options in a dropdown menu without it closing. The last one is probably a much bigger Ui change though...
But yeah, clicking 6 times instead of 1 swipe is unacceptable.

Added back the icon toggles rB58f38ff5c1a392b40129cad100e8c1e5371d7169

release/scripts/startup/bl_ui/space_text.py
287

The _ prefix is to quiet unused warnings, since this becomes used the _ can be removed (same below).

release/scripts/startup/bl_ui/space_text.py
287

Interesting. Is this something we have as an unwritten style rule? I wouldn't mind having this formalised at https://wiki.blender.org/wiki/Style_Guide/Python.

Let's move Register to the Text menu and add the view toggles to the header. That's what @Peter Fog (tintwotin)'s patch did anyway, but it was filtered out.