SSTE (Super Simple Text Editor)

versatile 64-bit multi-user Linux distribution


Moderators: kirk, jamesbond, p310don, JakeSFR, step, Forum moderators

Post Reply
User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

SSTE (Super Simple Text Editor)

Post by stemsee »

I am creating SSTE - a lightweight text editor, similar to leafpad but with extra functionality. It is easy to modify as only a bash script and yad to deal with.

Attachments
sste2.png
sste2.png (473.33 KiB) Viewed 2246 times
sste1.png
sste1.png (235.87 KiB) Viewed 2246 times
User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

So after some careful tests and review of the purpose of sste, I decided to remove formatting functions from the right hand yad list and instead have fewer formatting functions in the form of buttons along the bottom of the swallowing yad paned gui, along with prefs, screenshot and print buttons.. The list is still there but now has two columns. Column one displays the path of the image displayed in column two. This allows searches and further functionality suitable for touchscreens. Currently double clicking on an image converts the image to a pdf and opens in evince which provides pinch to zoom, rotation, night mode, and other options. Meanwhile on the other side, the yad text-info editor, is able to save and open new files on the fly Doing so does not update the gui or backend with path of the newly opened file. So to use the formatting and print functions it is a necessary (inconvenience) that all(in the case of print) or some of the text must be pre-selected. Whether using mouse cursor or touch screen this is very easily accomplished. Now, to match the convenience of viewing an image in evince yad ---print preview allows a pinch to zoom gui for ease of viewing on a touchscreen. This print preview can also rotate the text simply by selecting in Page Layout of the print dialogue, Landscape, reverse landscape, portrait or reverse portrait - all four rotations, with pinch to zoom convenience. However going a little further I added a button for xscreenshot, which lets you select an area of the screen and creates an image file (of your visible text). Which then can be converted to pdf and opened in evince. This convenience is at the limitation of having a /root/sste directory with pdf, images and text sub-directories. So images can be converted to pdf if pdf doesn't already exist.

The ides for my use case is to be able to easily load images of guitar chords or scored music etc along with text or images of lyrics. Of course the text editor can be setup with text and background colours, and a range of font types and sizes. The separator can be used to hide either side, partially or completely. Everything happens very smoothly and with very little delay.

Currently I am working on the formatting options. When all are working I will add a banner image and button icons along with hover text for each button, before releasing a beta. But I have to say so far it is pleasant to use. Probably needs a history, and image scaling and categorisation.

xscreenshot-20241103T213115.png
xscreenshot-20241103T213115.png (444.5 KiB) Viewed 2162 times
User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

@step
when using yadu --text-info --file-op, i can open a new file which clears current contents and loads contents from opened file. Then how do I programmatically reference the new file, is it a new "$1" or ... ? I want to be able to add the file path and name to a history log.

User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

I have added a preferences dialogue for selecting font, colours, image scaling max size and tray menu, saving prefs as different .set files, with custom name or, fields 1, 2 and 3, for easy selection. There are 8 fields in prefs.

xscreenshot-20241104T152820.png
xscreenshot-20241104T152820.png (55.84 KiB) Viewed 2102 times

I added a couple lines of code to resize images using graphicsmagic, a fork of imagemagick but upto date and smaller. I am able to load 1000 images @1024x1280 in 4 seconds. rescaling took a bit longer.

xscreenshot-20241104T150419.png
xscreenshot-20241104T150419.png (429.22 KiB) Viewed 2102 times

The list can also load text files for pre-viewing in the editor.

I will add a tray menu for more functions and options at some point.

step
Posts: 561
Joined: Thu Aug 13, 2020 9:55 am
Has thanked: 60 times
Been thanked: 206 times
Contact:

Re: SSTE (Super Simple Text Editor)

Post by step »

stemsee wrote: Mon Nov 04, 2024 1:11 am

@step
when using yadu --text-info --file-op, i can open a new file which clears current contents and loads contents from opened file. Then how do I programmatically reference the new file, is it a new "$1" or ... ? I want to be able to add the file path and name to a history log.

There isn't a way to programmatically reference the file you open in yad'd file open dialog. Also, yad closes the file handle right after loading file contents into the text view; therefore there isn't a way to inspect the system to figure out which file was opened.

User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

thanks @step

When opening a file first navigate to the file then right click on the file and copy location is available. This will be the most automatic way to get a file reference, if it can be scripted with xdotool, or just manually - is better than nothing.

right-click.png
right-click.png (436.75 KiB) Viewed 2046 times
User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

step wrote: Mon Nov 04, 2024 2:17 pm
stemsee wrote: Mon Nov 04, 2024 1:11 am

@step
when using yadu --text-info --file-op, i can open a new file which clears current contents and loads contents from opened file. Then how do I programmatically reference the new file, is it a new "$1" or ... ? I want to be able to add the file path and name to a history log.

There isn't a way to programmatically reference the file you open in yad'd file open dialog. Also, yad closes the file handle right after loading file contents into the text view; therefore there isn't a way to inspect the system to figure out which file was opened.

After thinking about it, I realised that I can still Save the edits to the correct file, which suggests the file handle is still 'held' somewhere. If it wasn't then i would need to Save As and re-select the file!

User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

Search and Replace is regex enabled. This means less format buttons are needed. For example adding bullets in front of a line, can be searched and replaced with anything. So I added a "Bullets end of line" also. Using search and replace can quote and bracket as required.

I was having a huge headache with xsel and xdotool ctrl+v ... nothing worked as I wanted, but now modified text gets piped to editor. So formatting sequence is
EDIT: 1) click on Format button on gui.
2) Select text.
3) Click on a format option button on the formatting buttons column.

Ctrl+z to undo (line by line), or Ctrl+Shift+z to re-do (i have a japanese keyboard).

Prefs now has 10 fields, added help and 'ADD Image Directory' checkbox.

xscreenshot-20241105T121629.png
xscreenshot-20241105T121629.png (81.23 KiB) Viewed 2015 times

Last things to do are:

1) tray menu! with columns, indented formatting, portrait, landscape, other text formatting
2) hashtext (gettext)
3) translation function
4) grammar check function

That would be enough to get started with.

Last edited by stemsee on Fri Nov 08, 2024 3:48 am, edited 1 time in total.
User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

An interesting 'discovery' ...
There are no navigation options for cycling through documents or a history for the editor .... but ! if you open a document in the editor, then open another , and another and another... and so on for however many documents you want to iterate through .... then you can use "undo" or "ctrl+y" or in my case "Ctrl+Shift+z" and there you have a bunch of documents/history/edits to cycle through. Clearly xdotool must be used to take advantage of this caching to "LOAD" a directory of texts into the undo cache....just be careful not to save anything ... in case of overwriting a file with the wrong contents.

Needs further investigation

User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

There are four ways to load text:

1) set sste.sh as run action for .txt files in rox right-click menu, open with sste.sh by clicking on file.
2) loading text files from /root/sste/text dir (default behaviour on start up) all files will be appended in a single long document.
3) loading text files from image directory, files added to list for select to preview in editor
4) loading text files from additional text directory, files are cached in undo/redo history, use ctrl+z or ctrl+y to navigate through them.

NaviPad is up and running in sste. Using xdotool to send key combos to focused window: this works well because the navipad uses yad option --no-focus.

xscreenshot-20241106T105028.png
xscreenshot-20241106T105028.png (7.17 KiB) Viewed 1961 times

These are the default settings, and the function can read a config in /root/sste/navi-pad.conf which overrides defaults

Code: Select all

cmndone='bash -c "xdotool key ctrl+a"'
cmndtwo='bash -c "xdotool key ctrl+shift+z"'
cmndthree='bash -c "xdotool key ctrl+x"'
cmndfour='bash -c "xdotool key ctrl+o"'
cmndfive='bash -c "xdotool key ctrl+f"'
cmndsix='bash -c "xdotool key ctrl+s"'
cmndseven='bash -c "xdotool key ctrl+c"'
cmndeight='bash -c "xdotool key ctrl+z"'
cmndnine='bash -c "xdotool key ctrl+v"'
Last edited by stemsee on Thu Dec 12, 2024 2:00 am, edited 1 time in total.
User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

Here it is SSTE.sh Version 0.1 - use at own risk - not exhaustively tested!
fake .gz extension. rename to SSTE.sh or sste.sh and give exec permissions 'chmod 755 /root/sste.sh'.

xscreenshot-20241108T105919.png
xscreenshot-20241108T105919.png (460.66 KiB) Viewed 1871 times

Note Bene: NaviPad and Formatting Button Column will work with focused apps or desktop. Formatting will pipe text to SSTE editor!

SSTE.sh.gz
(16.41 KiB) Downloaded 40 times
User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

An update that tidys up after itself removing files in tmp. And in the case of Search'n'Replace it gets the exit code and continues only if exit = 0.
Navipad is now setup for the majority of users. ctrl+z and ctrl+y

SSTE.sh.gz
(17.31 KiB) Downloaded 54 times
User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

Improved formatting sed terms and moved searchfn to byblockfn, thus reducing script size. Search'n'Replace now functions on pattern i.e. selected text, not all.

SSTE.sh.gz
(17.29 KiB) Downloaded 55 times
User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

Because undo and redo work line by line, probably because of cat command. So I have added multiple undo and redo, using xdotool. Still works line by line just automatic according to line count of text.

SSTE.sh.gz
(17.52 KiB) Downloaded 56 times
User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

I loaded a .py script and this triggered text highlighting ... I wish I knew the specifics

xscreenshot-20241111T184209.png
xscreenshot-20241111T184209.png (368.4 KiB) Viewed 1738 times
User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

Update - added roman numerals as prefix e.g. VI. This sentence

Also fixed an issue with space detection.

SSTE.sh.gz
(18.5 KiB) Downloaded 45 times
geo_c
Posts: 2942
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2265 times
Been thanked: 911 times

Re: SSTE (Super Simple Text Editor)

Post by geo_c »

stemsee wrote: Mon Nov 25, 2024 11:43 am

Update - added roman numerals as prefix e.g. VI. This sentence

Also fixed an issue with space detection.SSTE.sh.gz

I just noticed this, and this looks amazing for my uses. I'll download it and work with it!

geo_c
Old School Hipster, and Such

User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

added days months and alphabet prefixes.
Tidied up typos

SSTE.sh.gz
(19.5 KiB) Downloaded 40 times
User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

If you need to number Chapter headings, actually lines which are not indented, followed by indented lines, then Number Unindented format option is for you.

xscreenshot-20241202T123247.png
xscreenshot-20241202T123247.png (81.48 KiB) Viewed 1164 times
SSTE.sh.gz
(19.79 KiB) Downloaded 38 times
User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

Added scale field to set splitter position in percentage terms of 1600 pixel width.

xscreenshot-20241204T204639.png
xscreenshot-20241204T204639.png (56.94 KiB) Viewed 1082 times
Last edited by stemsee on Thu Dec 12, 2024 12:56 am, edited 1 time in total.
User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

With set Splitter in preferences
SSTE.sh.gz

SSTE.sh.gz
(19.98 KiB) Downloaded 33 times
Last edited by stemsee on Thu Dec 12, 2024 2:11 am, edited 1 time in total.
Luluc
Posts: 155
Joined: Mon Feb 26, 2024 3:13 am
Has thanked: 89 times
Been thanked: 7 times

Re: SSTE (Super Simple Text Editor)

Post by Luluc »

Code: Select all

# ./SSTE.sh
./SSTE.sh: line 91: /tmp/STE-24364/yadsste: No such file or directory
./SSTE.sh: line 391: RANDOM: command not found
./SSTE.sh: line 392: /tmp/STE-24364/yadsste: No such file or directory
./SSTE.sh: line 489: /tmp/STE-24364/yadsste: No such file or directory
./SSTE.sh: line 494: /tmp/STE-24364/yadsste: No such file or directory
./SSTE.sh: line 492: /tmp/STE-24364/yadsste: No such file or directory
User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

Thanks for testing and reporting @Luluc

RANDOM was used incorrectly! fixed

In the SSTE.sh script lines 26 & 27 are

Code: Select all

[[ -f $(type -p yad) ]] && cp $(type -p yad) "$track"/yadsste
[[ -f $(type -p yadu) ]] && cp $(type -p yadu) "$track"/yadsste

These use 'type' command instead of 'which' to find the 'yad' binary and copies it to /tmp/STE-$RANDOM. The idea being that yadu is preferred if available, if only yad is available it will be copied first and used with limited functionality. Is type and/or yad installed? Are you using Fatdog64-902 or higher? If not change type to which $(which yad 2>/dev/null). I can add type to deps.

SSTE is being developed on Fatdog64-902.

SSTE.sh.gz
(20.08 KiB) Downloaded 21 times
User avatar
MochiMoppel
Posts: 1290
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 22 times
Been thanked: 476 times

Re: SSTE (Super Simple Text Editor)

Post by MochiMoppel »

stemsee wrote: Thu Dec 12, 2024 2:20 am

Is type and/or yad installed? Are you using Fatdog64-902 or higher? If not change type to which $(which yad 2>/dev/null).

type doesn't need to be installed, it's a bash builtin. I don't understand what this has to do with Fatdog or its version as your script uses bash (shebang #!/bin/bash) and not sh symlinked to dash, where type is also a builtin but would not understand the -p option.

User avatar
stemsee
Posts: 788
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 188 times
Been thanked: 133 times

Re: SSTE (Super Simple Text Editor)

Post by stemsee »

MochiMoppel wrote: Thu Dec 12, 2024 3:47 am
stemsee wrote: Thu Dec 12, 2024 2:20 am

Is type and/or yad installed? Are you using Fatdog64-902 or higher? If not change type to which $(which yad 2>/dev/null).

type doesn't need to be installed, it's a bash builtin. I don't understand what this has to do with Fatdog or its version as your script uses bash (shebang #!/bin/bash) and not sh symlinked to dash, where type is also a builtin but would not understand the -p option.

You are right of course! I just wanted to highlight the fact of how yad binary is found and copied to /tmp/* as the errors Luluc showed were missing renamed yad > /tmp/STE-$RANDOM/yadsste. By not stating that type is a universal builtin, I gave scope to the user to 'check' that yad 'be' installed. Kind yet not pedantic.

Post Reply

Return to “FatDog64”