How would you show some love for the Blender Text Editor?

Simply added 4 spaces:

Looks better for sure, but could you define a variable(ex. margin = " "*4) and insert that instead, so if we find a way to change it dynamically, it’ll be easy?

1 Like

Yes done :slight_smile:
Would be useful to expose this variable in the Addon UI to have a quick margin feature.

Blender_Screenwriter.zip (3.4 KB)

Thank you. I’m sorry something is wrong:
image

Btw. no need for () around margin and no space around + inside ().

Corrected the () and spaces, thank you.

For what i understand the original parser “require scene headings to be surrounded by blank lines” ( maybe the python version too) :

Fountain Syntax about Line Breaks:

https://fountain.io/syntax#section-br

Adding blank lines ( like two carriage returns ) after “Syntax block elements”, the formatting is ok.

I also loaded the “Big-Fish.fountain” by John August and beside the missing syntax elements, the formatting seems ok.

Formatting indications by John August :

https://screenwriting.io/what-is-standard-screenplay-format/

Could we use the Courier Prime font? ( SIL Open Font License OFL )

Other links about screenplay formatting:

https://en.wikibooks.org/wiki/Movie_Making_Manual/Writing/Screenplay_Format

https://www.oscars.org/nicholl/screenwriting-resources

Last changes:

Blender_Screenwriter.zip (3.4 KB)

Thanks. Let’s use this thread: Blender Screenwriter

The font can be manually set in the Preferences, but setting it with Python is very difficult because finding the right path for the Fonts folder cross platform is not easy.

1 Like

watching a programming tuto I saw an interesting feature in sublime text the multi cursor. to write at several places at once.

I’ve spend some more hours on updating the essential Auto Complete add-on which also comes with multi-file add-on templates, handling and execution from the Text Editor. I think all of the word and syntax changes has been fixed, but I’m no good with multi-file add-ons. I know registering has changed in 2.80 and therefore I’ve collected all registering of classes in the init, but I need someone to help me out with doing that part right. Anyone? https://github.com/tin2tin/code_autocomplete

3 Likes

A number of UI fixes ex. more space between line-numbers and code and theming for linenumbers:

https://developer.blender.org/D6268

1 Like

Hotstrings:
Here there is a little script that allows the use of hotstrings (text replacement as we type) inside the Blender’s text editor. Updated to support all python 3 builtins. list, repr, abs, dict, … will add parenthesis automatically.


Download: Text replacement for Blender's text editor (hotstrings)

1 Like

I don’t know if you guys noticed, but in an attempt to raise awareness about the fine Text Editor add-ons here in this thread, I set up at poll. But since the number of votes doesn’t reflect the sparse number of clicks to download the add-ons here, I guess the votes only reflect an interest in seeing an add-on with that name in the Text Editor.

Here are the current results: Vote for the essential Text Editor add-ons

1 Like

Command Recorder:

Download: https://github.com/Muthird/CommandRecorder2.8

2 Likes

Hi I tried some things and that’s really useful. I wanted to do an addon but it already existed. for incremental autosave. really useful when coding and having some crashes…I explain how to configure things there and the addon is in the description or on github in sambler chanel https://www.youtube.com/watch?v=0Oyalp8dXl8

2 Likes

Thank you. That’s great to have. No more losing work because of crashes. :slight_smile:

1 Like

Lots of great stuff here!!

I have a self made pie menu I use for the Text Editor (Shift + RMB), very similar to Pistiwique’s.
Can somebody help me implement my “DeleteLine” class?
For the moment, it deletes the line I’m on and makes a backspace. But it works only on one line.
I’m struggling to make it delete all the selected lines at once.

class DeleteLine(bpy.types.Operator):
    bl_idname = "text.delete_line"
    bl_label = "Delete Line"
    bl_options = {'REGISTER', 'UNDO'}

    @classmethod
    def poll(self, context):
        return context.edit_text is not None
    
    def execute(self, context):
        bpy.ops.text.select_line()
        bpy.ops.text.delete()
        bpy.ops.text.delete(type='PREVIOUS_CHARACTER')
        
        return {'FINISHED'}

Here is my full addon:
PieMenu_Toolbox_SCRIPTING_Text_Editor.py (3.6 KB)
Pie menu TE

Thanks!

1 Like

It’s possible to set text selection using text.select_set. When the char index argument is -1, it selects at the end of a line.

class TEXT_OT_delete_line(bpy.types.Operator):
    bl_idname = "text.delete_line"
    bl_label = "Delete Line"
    bl_options = {'REGISTER', 'UNDO'}

    @classmethod
    def poll(self, context):
        return getattr(context, "edit_text", False)
    
    def execute(self, context):
        text = context.space_data.text

        start_l, end_l = sorted((text.current_line_index, text.select_end_line_index))
        start_c = end_c = -1
        selc = text.select_end_character

        if start_l == 0:
            end_l += 1
            start_c = end_c = 0

            if len(text.lines) == 1:
                end_c = -1

        text.select_set(max(start_l, 1) - 1, start_c, end_l, end_c)
        bpy.ops.text.delete(type='PREVIOUS_CHARACTER')
        text.cursor_set(start_l, character=selc)
        return {'FINISHED'}
2 Likes

Thanks a lot, worked like a charm!

In your API additions, is there an optimized way to “get selection”?

There isn’t, but sounds like a nice weekend project.

So far I’ve been using this abomination:

def select_get(txt):
    curl = txt.current_line_index
    sell = txt.select_end_line_index
    curc = txt.current_character
    selc = txt.select_end_character

    a, b = sorted((curl, sell))
    selection = [line.body for line in txt.lines[a:b + 1]]

    if curl == sell:
        curc, selc = sorted((curc, selc))
        return "".join(selection)[curc:selc]

    if (a, b) != (curl, sell):
        curc, selc = selc, curc

    selection[0] = selection[0][curc:]
    selection[-1] = selection[-1][:selc]
    return "\n".join(selection)

edit: wrong one!

1 Like

A basic ‘get selected text’ function is missing from the API and blocking for development of built-in operators for the Text Editor in Python. Iceythe/Kaio has submitted at patch to deal with this, so show some love here, if you would find that useful: https://developer.blender.org/D6377