Essential Text Editor add-ons for coders

I all

@tin2tin:

About TextMarkes add-on, there is a specific reason for not implementing an automatic update for “Update Markers according to Text changes” function?

because it is a pain to have to update each time you modify something (yes I am a bit lazy).

I have implemented an auto update for this function and I have no problem so …
P16-11-2019
if i am wrong (or not) tell me

@Hokuss For me it’s great to see you contribution, but I only updated the add-on to 2.80. It is by @tonton. Maybe you could make a pull request at his repository, and discuss this feature with him: https://github.com/samytichadou/TextMarker_blender_addon

(Only thing from my side is that it might be confusing with two auto buttons doing different things?)

well for me it is more a proposal than a request.

I have already made the modification for my personal use and It seems to be relevant in the subtance. The form…

So I decided to share it to find out if it is relevant for others and in the first place for the author.

ok I didn’t pay attention at that

the form… yes it is.

I didn’t want to be too abrupt to start the discussion, so I showed my first modification on this subject, which is less radical and gives the choice.

But, for me, options to switch between manual and auto (jump and update) are all superfluous.The manual mode is superfluous. So the addon i use daily is like this:

Screenshot_20191216_234954

All is automatic (jump and update) that’s all!

Like i said in my first post perhaps i’m wrong and the manual mode is relevant…

New patch: Text Editor: make “Text” tab active when you start searching text
https://developer.blender.org/D6524

2 Likes

@iceythe Is this much needed patch at a dead end https://developer.blender.org/D6377 ? And what about the horizontal scrollbar for the Text Editor, and progress with that one? :slight_smile:

Campbell has a different view of how getting text selection should be implemented (essentially make it into functions that can retrieve or overwrite selection). That was not the idea of the initial implementation (text.write() already does this), so this one will likely be abandoned.

As for the horizontal scrollbar. It was more or less finished last year. But then there were two major commits to the text editor that unified (and broke) offsets, moving runtime variables, so a simple merge isn’t going to happen. Gonna step back a little from spontaneous code contribution and pitch my ideas first so I don’t keep wasting time :stuck_out_tongue:

I’ve worked on consolidating some of the addons which include most of what I’ve posted here, and added a couple of new operators. I’ll see if I can’t release this in a suite pretty soon.

Goto line with smooth scrolling

Find next / previous occurrence

Cursor history (mouse forward / backward)

Word-snapping selection (double-click drag)

Some cursor position and selection stats aka. make footer great again

9 Likes

wow… fantastic!

The best way is properly to pm Campbell on Blender Chat.

Thank you for all the great stuff you’re doing for the Text Editor. Looking forward to try all the new stuff. :slight_smile:

Maybe it’s only me, but the Find and Replace is the element which annoys me the most about the text editor. Maybe we could come up with a more industry standard suggestion for how it should be in the UI and it’s functions?

Some ideas:

https://twitter.com/TylerGlaiel/status/1216079810486657024
just a reminder for those who dont know, you can hold alt to do a vertical selection in most code editors


https://twitter.com/early_melon/status/1216294614824517633
@TylerGlaiel @jwaaaap You can do some fancy stuff like here in VS Code control shift P - evaluate math expression


https://twitter.com/mesetatron/status/1216110466906324993
@TylerGlaiel @robotzurg dont forget, some editors let you copypaste columnmulti-select

1 Like

Hi @tin2tin

I tend to think that it would be pretty convenient for users to find your addons in the “Text Editor” category, instead of “Development”.
This way, by just selecting the “Text Editor” category, it becomes possible to filter addons that belong to this category.

1 Like

Sometimes very useful… Icon Button to open the API

col.operator('wm.url_open', text = '', icon='BLENDER').url="https://docs.blender.org/api/blender_python_api_current/bpy.props.html?highlight=boolproperty#bpy.props.BoolProperty"

Thank you. There is also this one:

Search-For-Online-Reference

Blender Text Editor: Search online for current or selected word.

Search in:

  • API Reference
  • Python Reference
  • Blender Stack Exchange
  • Blender Source Code
  • Github

Location: Text Editor > Edit > Search API Reference or Context menu.

1 Like

This is great! Thank you! …

-the link for “text insert” is wrong.
good link [https://github.com/K-410/blender-scripts/blob/master/2.8/text_insert2.py]
(it seems not to work)
it seems that the same guy did a save incremental too [https://github.com/K-410/blender-scripts/blob/master/2.8/wm_save_incremental.py]
-“extend to bracket”. could it be possible to add extend to multispace(or tab) and bracket only one side.
e.g: bpy.ops.mesh.normals_make_consistent(inside=False) to select from bpy to first bracket
-since the UI has been modified on the left (numbers) “highlight occurrences” is not well aligned
-debug dev tools the first button debug print variable I had exactly this idea. very useful
-change case (was so obviously missing) but I would prefer it in right clic menu so I will show how to add a quick favorite to text editor in a small video with e.g a shortcut to this function.
https://youtu.be/tZsIq9LjEF0

Thank you for feedback and tutorial. Some of the points are for @iceythe.

If we at some point can get operators in Python accepted in the text editor, maybe we could move some of the essential functions into Blender(if they’re accepted). This patch was the canary in the coalmine: https://developer.blender.org/D5097 but maybe the same thing could be tried with operators which do not need an optimized “get selection” operator, like some of those you mention?

I forgot to post some of my Text Editor themes, so here they are:

A theme which is in consistency with the colors of the unselected colored buttons in the 2.80 dark theme:
https://gist.github.com/tin2tin/378707cc4062cf862289e4cd49d24daa

And a VScode Theme:
https://gist.github.com/tin2tin/18f86237a54dd307296cfa7692b81a26

Sorry for the late reply. Some of the stuff in the current repo is turning absolete and no longer worked on separately. I’ll be going through the repo and removing them soon. They will be replaced by a bigger addon suite which eliminates the need to track several addons.

That’s an interesting idea, but it doesn’t align with the purpose of the operator. I can add a new operator that selects by whole words. I’ve been wanting to add something like this for fast selection, but now that I’ve got double-click word-snapping selection working it’s not been a priority.

Another addition:

This requires minimum 2.82 since it accesses runtime to get the recently added offsets. Also added middle-click for continuous scrolling. Grab scrolling just wasn’t my thing for long texts.

3 Likes

Sounds brilliant. Looking forward to it.

Hello guys, do you think you could implement foldable regions like in C# ?
So we can fold/unfold parts of the code…

An implementation of folding would mean logical partitioning of scopes and control flow, which would require a robust lexical analyzer (that works for python and osl) to break code into an AST. Then, it’s possible to draw a flattened text based on the visibility of the nodes. Maybe there are some parser libs out there. But in the end I think this would just add a headache to Campbell :stuck_out_tongue:

If we had something like a foreach method for byte strings, all text drawing could’ve been done in python without any significant penalties.

There are ways to mitigate the need for code folding:

  • Ctrl click to jump to definition
  • Robust sidebar code navigation with collapsible entries
  • Bookmark lines
  • Live search (search as you type)

Indeed it seems complicated… ^^
I’m already using Code Navigation in the sidebar, but it would have been handy to reduce the code with folds… Thanks anyway!