You are not logged in.

#1 2010-03-31 20:52:35

rafunchi
Member
Registered: 2010-03-14
Posts: 16

sandy - a simple text editor

sandy - a simple text editor

Sandy is a X11 text editor with an easy-to-read, hackable C source. It uses GTK+ and GtkSourceView for convenience and is akin to surf, only it is a text editor, not a web browser. Sandy tries to maximize screen estate, minimize the SLOC used and not get in your way too much. It can somehow be controlled via XProperties and all preferences and keybindings are to be chosen at compile time. Two example configs are provided with the source.

Features
- Basic editing, saving, etc.
- One document per instance
- Embeddable (e.g. can use http://tools.suckless.org/tabbed for tabs)
- Regex search, go to line functionalities
- Pipe selection through arbitrary command
- Pipe selection through predefined command(s)
- Syntax highlighting
- Line numbers, current line highlightnig
- Simple autoindenting
- Multi-level undo
- Configurable at compile-time

Dependencies
- GtkSourceView2
- Gtk+2
- (probably) xorg-utils to get xprop to set XProperties
- one method to grab user input: either zenity or dmenu in the pre-defined config files

Screenshot
http://sandyeditor.sf.net/sandy_editor.jpeg

Homepage
http://sandyeditor.sf.net/

Download
http://sourceforge.net/projects/sandyed … z/download

AUR
http://aur.archlinux.org/packages.php?ID=36084


Comments, bug reports and patches welcome.

Last edited by rafunchi (2010-04-13 23:24:26)

Offline

#2 2010-03-31 21:06:29

JohannesSM64
Member
From: Norway
Registered: 2009-10-11
Posts: 623
Website

Re: sandy - a simple text editor

Sorry for my disrespect, but why is GTK needed for a simple text editor?

Offline

#3 2010-03-31 21:54:10

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: sandy - a simple text editor

The cursor should stay the same after a PIPE command.

No quit binding?

Offline

#4 2010-03-31 22:01:38

rafunchi
Member
Registered: 2010-03-14
Posts: 16

Re: sandy - a simple text editor

JohannesSM64 wrote:

Sorry for my disrespect, but why is GTK needed for a simple text editor?

There is some rationale at the project homepage. Please read it and comment. Basically if you already have any GTK+ program in memory (in your dynamically linked OS such as ArchLinux) then there is no overhead. Also it feels right for the editor's text buffer to behave in a similar way to the text buffers in your other apps. Some of my other apps (mostly surf) use GTK.

Finally simplicity is the key concept here; not optimization or effectiveness (yet the binary itself weights only about 25K). The source base is really small (actually smaller than dmenu ATM) and fairly easy to understand even if you don't "speak" C. The GTK TextBuffer/View objects are simple, powerful and easily extensible once you get to know them.

Offline

#5 2010-03-31 22:21:46

rafunchi
Member
Registered: 2010-03-14
Posts: 16

Re: sandy - a simple text editor

Procyon wrote:

The cursor should stay the same after a PIPE command.

Thanks for your comment. I don't really understand what the problem may be.

After a PIPE command, the selection is set to the inserted text, which is in turn the output of the pipe. The insertion point (is that the cursor?) stays at the end of the selection and the selection mark at the beginning. At this point inserting any text replaces the selection, moving down or forward moves from the end of the selection, moving up or backwards moves from the beginning. Does sandy work in this way at your system? If it doesn't... what is the difference? If it does... did you expect it to work in any other way? If so, how?


Procyon wrote:

No quit binding?

I thought about it. The simple way to close the editor is request a delete with your window manager (to "alt-f4" it). If the buffer has not been modified, the editor will close. If it has, it will print a warning as the window title and exit (without saving!) at the second consecutive attempt. I've used it for a while and find it fairly comfortable so far.

However, there is a reason other than my personal taste for this. If you embed the editor in another application (I've tried tabbed, and only a little), it really does not make sense to have a binding to quit but rather have the parent app close the window when it no longer needs it. OTOH we might as well have a binding to close the editor that behaves the same way as requesting a delete and is silently ignored if the window is embedded. I'll go for both Ctrl-W and Ctrl-Q in the default wimp config (EDIT: done in hg tip).

Thanks again for your comments.

Last edited by rafunchi (2010-03-31 22:28:53)

Offline

#6 2010-04-01 02:11:27

renuvio
Member
Registered: 2008-10-25
Posts: 49

Re: sandy - a simple text editor

Hi rafunchi:

Piping the output of dmesg in a blank page in sandy give me this message error exactly at the end:

sandy[2478]: segfault at 0 ip 0804b403 sp bfba9090 error 4 in sandy[8048000+5000]

I don't know what this mean, but the editor is still working even after that. And a similar message appear every time i pipe dmesg output.

I hope this may be useful for you. Bye.

Offline

#7 2010-04-01 09:55:14

rafunchi
Member
Registered: 2010-03-14
Posts: 16

Re: sandy - a simple text editor

renuvio wrote:

Piping the output of dmesg in a blank page in sandy give me this message error exactly at the end:

sandy[2478]: segfault at 0 ip 0804b403 sp bfba9090 error 4 in sandy[8048000+5000]

I don't know what this mean, but the editor is still working even after that. And a similar message appear every time i pipe dmesg output.

Hi renuvio. Thanks for your feedback.

I have tried and this happens every time you pipe no text through a command, but it is obviously more visible if you get the dmesg output as the segfault messages go there and into the buffer. The writing process is affected and segfaults, but neither the main (reading) process nor the piping process are affected and thus you can continue using the editor as expected.

Anyhow, a process segfaulting like that is really ugly, so I'll try and work out a patch. (EDIT: fixed in hg tip)

Last edited by rafunchi (2010-04-01 10:30:39)

Offline

#8 2010-04-01 16:15:58

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: sandy - a simple text editor

It would be nice to be able to do something like this:
1 abc
2 dec
3 abd
4 edc
5 {CURSOR}ad

^R, sed command: 1,3s/^/%%%/

1 %%%abc
2 %%%dec
3 %%%abd
4 edc
5 {CURSOR}ad

So you can edit and continue where you left off. Maybe you can check for "/^s/" in the command to make it work on this current line, just like vim's :s///

Offline

#9 2010-04-02 10:17:13

rafunchi
Member
Registered: 2010-03-14
Posts: 16

Re: sandy - a simple text editor

Procyon wrote:

It would be nice to be able to do something like this:
1 abc
2 dec
3 abd
4 edc
5 {CURSOR}ad

^R, sed command: 1,3s/^/%%%/

1 %%%abc
2 %%%dec
3 %%%abd
4 edc
5 {CURSOR}ad

So you can edit and continue where you left off.

The problem with implementing this behavior is 'sed' is an external command here. The full text is filtered through sed and put back in the buffer, not just lines 1 to 3. You can't just preserve the insert position as the text coming from the pipe might be completely different from your original. Same for searching the current line.

You *could* remember your line+char position and move the cursor back there, but this would be highly unreliable and move the cursor to a third position in the buffer if your 's' command changes the number of lines (e.g. try s/:/\n/g in a password file)

Also, a couple of tests with vim prove that it does not behave consistently in this regard, despite :s being an internal command there.

if you really want to add '%%%' at the beginning of the line quite often, I suggest you define a binding or action for:

t_editable, t_pipelines, { .v = (char *)"sed \'s/^/%%%/\'" }

Then select the lines you want to target lousily (you don't need to select full lines) and launche the binding/action. It does move the cursor, but seems fairly quick.


Procyon wrote:

Maybe you can check for "/^s/" in the command to make it work on this current line, just like vim's :s///

I made a wee change in the hg tip code. Now sandy "listens" to three properties regarding pipes:
- _SANDY_PIPE: Pipes the selected text, or nothing by default as per f_pipe. This is used by the ^I binding in the default config.
- _SANDY_PIPEALL: Pipes the selected text, or the full file if nothing is selected as per f_pipeall. This is used by the ^P binding in the default config.
- _SANDY_PIPELINES: Pipes the selected text, extending the selection to full lines and matching the current line if there is no selection as per f_pipelines. This is used by the ^R binding in the default config. This means now sed is applied to full lines if there is a selection and to the current line if there is not.

Thanks for your feedback. I hope this helps.

Offline

#10 2010-04-13 23:27:20

rafunchi
Member
Registered: 2010-03-14
Posts: 16

Re: sandy - a simple text editor

I just finished implementing extended regex search (though it might need some work), tagged as sandy-0.2 and uploaded to AUR.

As usual, comments are welcome.

Offline

#11 2010-04-14 03:54:42

n0dix
Member
Registered: 2009-09-22
Posts: 956

Re: sandy - a simple text editor

Thanks rafunchi for the good work. I would like to try this editor. I'll give a feedback in the next days.

Last edited by n0dix (2010-04-14 03:56:09)

Offline

Board footer

Powered by FluxBB