You are not logged in.

#1 2015-02-11 18:25:54

FelipeFS
Member
Registered: 2015-02-11
Posts: 19

Love Text (text editor)

Hello, Arch users!
This is my first time posting here, though I'm a long time user of Arch. Well, I think this is the most appropriate section to post this.
lovetext.png
I'm developing a text editor in C integrated with Lua, which I call "Love Text". The objective here is to provide a lightweight text editor and still be powerful. I do not know the rules to put a project on AUR, but I hope to be able to put it there one day. So, you can download the source code at:

(Please, see the "README")

Also, there is a repository of extensions available at:

Well, thank you. Feedbacks are welcome!

Last edited by FelipeFS (2015-02-16 19:39:47)

Offline

#2 2015-02-11 18:34:33

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: Love Text (text editor)

Looks interesting.  I just tried it out and I see in addition to the gtk3 dependency which is listed on the README it also requires gtksourceview3.  This should be pretty easy to package with a PKGBUILD to upload to the AUR, but I'd recommend a couple revisions to the Makefile: 1) use standard variables for the compiler ('CC' instead of 'compiler', LDLIBS rather than CLIBS), and 2) don't override default settings of these variables, just append to them.  For example:

CC      ?= gcc
CFLAGS  += `pkg-config ...`
LDLIBS  += `pkg-config ...`

Also while this doesn't affect functionality at all, you can simply the rest of the makefile with default rules.

So far lovetext is just immediately segfaulting upon startup.  The tail of the strace shows the following:

access("/usr/share/themes/Adwaita/gtk-3.0/settings.ini", F_OK) = -1 ENOENT (No such file or directory)
futex(0x7ffb8998b568, FUTEX_WAKE, 2147483647) = 0
stat(".", {st_mode=S_IFDIR|0755, st_size=280, ...}) = 0
stat("/tmp/lovetext", {st_mode=S_IFDIR|0755, st_size=280, ...}) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffb8bd5a000
write(1, "[MESSAGE] Program activated.\n", 29[MESSAGE] Program activated.
) = 29
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0xffffffffa84e2f0e} ---
+++ killed by SIGSEGV (core dumped) +++
Segmentation fault (core dumped)

mod note: moving to Community Contributions.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2015-02-11 18:43:42

FelipeFS
Member
Registered: 2015-02-11
Posts: 19

Re: Love Text (text editor)

@Trilby

Thank you for the feedback. I believe that the segfault is because the program tries to apply a custom theme from the start (you can use custom themes, optionally), but is returning a NULL. I will fix this.

Offline

#4 2015-02-11 18:56:54

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: Love Text (text editor)

It may be because I don't use gtk3 (or any toolkits really) so I don't have any themes or normal toolkit stuff configured.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2015-02-12 18:28:04

FelipeFS
Member
Registered: 2015-02-11
Posts: 19

Re: Love Text (text editor)

Makefile changed (bonus to myself, I didn't know you could append values to makefile variables).

Just pushed a new commit to check for NULL returns and give more detailed reports. Also, started the implementation which will allow to draw above the text editor (by consequence allowing to create a minimap).
Still, I don't know how if it is stably running at others computers. I'll be able to test at others computers only next week.

Screen (using theme Zukitre + personal highlighting scheme):
screenshot_01_lovetext.png

Edit: I hope to be able to fix these problems soon. I'm using the program myself for a while, and my motivation was exactly the fact that some editors are bulky and crash a lot in the middle of you coding (like gedit), some are very stable and lightweight but lack features (mousepad)... and the really good one is closed-source (sublime).

Last edited by FelipeFS (2015-02-12 18:32:06)

Offline

#6 2015-02-12 19:09:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: Love Text (text editor)

I just tried it out again.  I'm still getting the segfault, but I traced it down.  It's from accessing the home_env variable on line 49 of module.c.  This *should* work as written, and I've inserted all sorts of tests there to learn more, and everything I'm learning is odd.  First, getenv returns a pointer.  I can print that address successfully (e.g. printf("%X\n", home_env) ) but anything else I do with that pointer segfaults.  I can't print it as a string (which is why the g_printf command segfaults).  I can't even access the first byte of it without segfaulting (i.e. char c = home_env[0] ).

I can use getenv("HOME") just fine in other programs.  The only thing I can think of is if this is multithreaded/multiprocess and the process that this code runs from should not have access to the environment of the main process.  I've never done any gtk programming, so I have no idea how it starts up and if there are such multiple processes.

EDIT: I just moved the getenv and print commands to be the very first things run in main, and this also segfaults.  So this rules out threading issues.  The only other thing I could think of is that getenv is redefined somewhere.

EDIT 2: it's actually much simpler than that: getenv wasn't even defined because stlib.h wasn't included.  Adding the sdlib.h include fixed the segfault.

EDIT 3: I couldn't figure out why this ever even compiled with that missing header, but you have hardcoded the "-w" flag to the compiler to explicitly ignore/supress all warnings.  This is a very bad idea.  Without this flag the compiler would have specified exactly what the problem was.

Last edited by Trilby (2015-02-12 19:11:41)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2015-02-12 20:57:56

FelipeFS
Member
Registered: 2015-02-11
Posts: 19

Re: Love Text (text editor)

Oh maaan!

I was trying to fix it all day! Thank you very much!
(I will answer you properly...)

Offline

#8 2015-02-12 20:58:09

stevenhoneyman
Member
From: England
Registered: 2014-05-25
Posts: 241

Re: Love Text (text editor)

Interesting little editor! I'll keep an eye on it ready for 'beta' status smile
(I presume you're aware of the various bugs with the parts that are still "in progress")

Honestly, the only thing I dislike so far is the name. That's just personal preference though!

Offline

#9 2015-02-12 21:07:57

FelipeFS
Member
Registered: 2015-02-11
Posts: 19

Re: Love Text (text editor)

Trilby wrote:

I just tried it out again.  I'm still getting the segfault, but I traced it down.  It's from accessing the home_env variable on line 49 of module.c.  This *should* work as written, and I've inserted all sorts of tests there to learn more, and everything I'm learning is odd.  First, getenv returns a pointer.  I can print that address successfully (e.g. printf("%X\n", home_env) ) but anything else I do with that pointer segfaults.  I can't print it as a string (which is why the g_printf command segfaults).  I can't even access the first byte of it without segfaulting (i.e. char c = home_env[0] ).

I can use getenv("HOME") just fine in other programs.  The only thing I can think of is if this is multithreaded/multiprocess and the process that this code runs from should not have access to the environment of the main process.  I've never done any gtk programming, so I have no idea how it starts up and if there are such multiple processes.

EDIT: I just moved the getenv and print commands to be the very first things run in main, and this also segfaults.  So this rules out threading issues.  The only other thing I could think of is that getenv is redefined somewhere.

I was trying to figure out what was the problem with the getenv, too. I have even replaced it with "g_get_home_dir()" from the GLib. Probably it will work without the stdlib, but I will put the header anyway.

Trilby wrote:

EDIT 2: it's actually much simpler than that: getenv wasn't even defined because stlib.h wasn't included.  Adding the sdlib.h include fixed the segfault.

EDIT 3: I couldn't figure out why this ever even compiled with that missing header, but you have hardcoded the "-w" flag to the compiler to explicitly ignore/supress all warnings.  This is a very bad idea.  Without this flag the compiler would have specified exactly what the problem was.

I wonder why the program was running normally on my computer when it should not, I was not even able to reproduce the error. I will remove the "-w", too.

Thank you, again!

Offline

#10 2015-02-12 21:17:03

FelipeFS
Member
Registered: 2015-02-11
Posts: 19

Re: Love Text (text editor)

stevenhoneyman wrote:

Interesting little editor! I'll keep an eye on it ready for 'beta' status smile
(I presume you're aware of the various bugs with the parts that are still "in progress")

Honestly, the only thing I dislike so far is the name. That's just personal preference though!

1. I'm bad at versioning. To me, it is "stable" or "unstable".

2. The name?! But it is cute! Ahahah

3. The preferences window still need work, but as far as I know, does not cause any crash. Once all these little bugs are fixed, the only thing to work on are the extensions, and nothing more (but of course, the extensions can add graphical parts to the editor). I want to keep it to be really fast and lightweight.

Offline

#11 2015-02-12 22:29:08

flannelhead
Member
From: Finland
Registered: 2014-03-30
Posts: 55
Website

Re: Love Text (text editor)

This really looks interesting. I've been liking Gedit for its good usability and feature set, and that's why I'm interested to try a similar but simplified editor. GtkSourceView looks like a good choice for an editor component – you won't have to reinvent the wheel. Keep up the good work!

Offline

#12 2015-02-13 01:58:27

FelipeFS
Member
Registered: 2015-02-11
Posts: 19

Re: Love Text (text editor)

The first step to minimap plugin. That dark panel on the right is drawn on Lua side. Now, it is just a matter of reading the words and draw the lines.

https://googledrive.com/host/0B_MHIzIpQ … INIMAP.png

Update - lines on the minimap:
https://googledrive.com/host/0B_MHIzIpQ … INIMAP.png


moderator edit: replaced img tags with url tags

Last edited by fsckd (2015-02-14 22:23:33)

Offline

#13 2015-02-14 21:15:48

FelipeFS
Member
Registered: 2015-02-11
Posts: 19

Re: Love Text (text editor)

So, I think it is useful to put a list of extensions I'm thinking about:

  • Minimap: half-done. I can print the little lines to represent the words on the document.

  • Set Language: The editor tries to figure out what language you are working by the extension of the file. Be able to set the language highlighting manually is useful when the file is not yet saved.

  • Multiple Select: I'm wondering how I will be able to acomplish this. I think that create tags (gtk_text_buffer_create_tag) on the text buffer is the way to go.

  • Snnipets: I will use buffer tags, for sure.

  • Git: I'm crazy to incorporate git into the editor. Not just be able to commit/push/init/etc, but show the diff on the editor would be really cool! But the git output for diff is really confusing to interpret which lines were insert/deleted/changed.

Any other extension suggestions?

Offline

#14 2015-02-14 22:18:55

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Love Text (text editor)

Hi FelipeFS, welcome to the forums. When you post pictures, don't post the full image. Instead, post a thumbnail which links to the full image. Forum Etiquette: Pasting pictures and code.

Edit: I replaced the images with URLs in one of your posts above. While the file sizes are reasonable, the dimensions are above threshold. Thanks for understanding.

Love Text looks pretty cool. The minimap is something I could use. smile

Last edited by fsckd (2015-02-14 22:27:30)


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#15 2015-02-15 09:17:25

FelipeFS
Member
Registered: 2015-02-11
Posts: 19

Re: Love Text (text editor)

fsckd wrote:

Hi FelipeFS, welcome to the forums. When you post pictures, don't post the full image. Instead, post a thumbnail which links to the full image. Forum Etiquette: Pasting pictures and code.

Edit: I replaced the images with URLs in one of your posts above. While the file sizes are reasonable, the dimensions are above threshold. Thanks for understanding.

Love Text looks pretty cool. The minimap is something I could use. smile

My bad! and thanks!

Just discovered that it is possible to put widgets on the side of the tabs on a notebook. Always wanted that. MAYBE I will remove the menubar and put a button on the left side of the tabs, it would save a small amount of space, and still would look beautiful on fullscreen mode. Might look like what gedit does (http://blogs.gnome.org/nacho/files/2014/01/gedit2.png), but it is not the same thing. Gedit puts a header above the notebook, and put the buttons there (no space saved).

Edit: but the downside would the fact that menu bars are easier to navigate.

Last edited by FelipeFS (2015-02-15 09:30:10)

Offline

#16 2015-02-16 10:47:34

chickenPie4tea
Member
Registered: 2012-08-21
Posts: 309

Re: Love Text (text editor)

I think the posts title should be
Love Text (text editor)
as I ignored this post at first as I didn't know it was a text editor.


You can like linux without becoming a fanatic!

Offline

#17 2015-02-20 01:15:02

FelipeFS
Member
Registered: 2015-02-11
Posts: 19

Re: Love Text (text editor)

Writing the git plugin:
https://googledrive.com/host/0B_MHIzIpQ … vetext.png

Plus, I finished a diff plugin, to show the modifications on the gutter (I will push the commit and post a screen later)!

Offline

#18 2015-02-22 03:37:31

FelipeFS
Member
Registered: 2015-02-11
Posts: 19

Re: Love Text (text editor)

Diff plugin screenshot:
https://googledrive.com/host/0B_MHIzIpQ … vetext.png

  • Added lines receive a green mark;

  • Modified lines receive a yellow mark;

  • Removed lines receive a red mark;

I'm using git to check the diff. Currently it checks the difference between the current buffer and the file using the command

git diff <the original file x> <temporary file representing the buffer>

What I want is to check the difference between the buffer and the file at the HEAD, something like

git diff <file x at HEAD> <temporary file representing the buffer>

Offline

#19 2015-02-22 04:18:29

progandy
Member
Registered: 2012-05-17
Posts: 5,279

Re: Love Text (text editor)

FelipeFS wrote:

What I want is to check the difference between the buffer and the file at the HEAD, something like

git diff <file x at HEAD> <temporary file representing the buffer>

You can build a command with "git show" and (git-)diff.
http://stackoverflow.com/questions/1527 … dard-input


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#20 2015-02-22 08:29:55

FelipeFS
Member
Registered: 2015-02-11
Posts: 19

Re: Love Text (text editor)

progandy wrote:
FelipeFS wrote:

What I want is to check the difference between the buffer and the file at the HEAD, something like

git diff <file x at HEAD> <temporary file representing the buffer>

You can build a command with "git show" and (git-)diff.
http://stackoverflow.com/questions/1527 … dard-input

Thanks, worked nicely!

Offline

#21 2015-02-22 08:45:56

progandy
Member
Registered: 2012-05-17
Posts: 5,279

Re: Love Text (text editor)

By the way, why don't you write everything with lua(jit)/lgi? It seems the compiled part of your editor is pretty simple, so you should be able to migrate to pure lua(jit)/lgi


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#22 2015-02-22 11:46:47

Shinryuu
Member
From: /dev/urandom
Registered: 2010-02-27
Posts: 339

Re: Love Text (text editor)

I'm interested in this as well, also I need a graphical editor for little tweks when I'm not willing to use vim for the task smile I compiled lovetext and put it in my bin folder, seems to run okay but when I open a while I just get a segmentation fault. I also put extension stuff inside ~/.lovetext folder but I get messages like this:

[MESSAGE] Program activated.
[MESSAGE] Allocating preferences.
[MESSAGE] Structure allocated.
[MESSAGE] Receiving "HOME".
[MESSAGE] "HOME" received.
[MESSAGE] Your home path is "/home/shn".
[MESSAGE] Setting configuration path.
[MESSAGE] Configuration path found at "/home/shn/.lovetext".
[MESSAGE] Setting extension path.
[MESSAGE] Extensions path found at "/home/shn/.lovetext/plugins".
[MESSAGE] Setting configuration file path.
[MESSAGE] Trying to load configuration file from "/home/shn/.lovetext/lovetextrc".
[MESSAGE] Configuration file loaded.
[MESSAGE] Setting no custom theme.
[MESSAGE] Creating main window.
[MESSAGE] Main window created.
[MESSAGE] Initializing Lua.
[MESSAGE] Lua version is Lua 5.2.
[MESSAGE] Lua state created.
[MESSAGE] Loading base extension.
[LUA] Lua Lua 5.2 loaded.
[ERROR] Fail to load lua script "/home/shn/.lovetext/base.lua".
[MESSAGE] Loading extensions.
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/backup.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/command_palette.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/file_manager.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/git.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/git_diff.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/make.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/minimap.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/set_language.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/terminal.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/toggle_scrollbar.lua".
[MESSAGE] Lua initialized.
[MESSAGE] Performing action "window.open".
[1]    8358 segmentation fault (core dumped)  lovetext

Offline

#23 2015-02-22 13:34:31

FelipeFS
Member
Registered: 2015-02-11
Posts: 19

Re: Love Text (text editor)

progandy wrote:

By the way, why don't you write everything with lua(jit)/lgi? It seems the compiled part of your editor is pretty simple, so you should be able to migrate to pure lua(jit)/lgi

I never used LuaJIT, but since it uses pre-compiled code, I think it would be a bit harder for other people to modify plugins (or even read for learning how to make them).

Shinryuu wrote:

I'm interested in this as well, also I need a graphical editor for little tweks when I'm not willing to use vim for the task smile I compiled lovetext and put it in my bin folder, seems to run okay but when I open a while I just get a segmentation fault. I also put extension stuff inside ~/.lovetext folder but I get messages like this:

[MESSAGE] Program activated.
[MESSAGE] Allocating preferences.
[MESSAGE] Structure allocated.
[MESSAGE] Receiving "HOME".
[MESSAGE] "HOME" received.
[MESSAGE] Your home path is "/home/shn".
[MESSAGE] Setting configuration path.
[MESSAGE] Configuration path found at "/home/shn/.lovetext".
[MESSAGE] Setting extension path.
[MESSAGE] Extensions path found at "/home/shn/.lovetext/plugins".
[MESSAGE] Setting configuration file path.
[MESSAGE] Trying to load configuration file from "/home/shn/.lovetext/lovetextrc".
[MESSAGE] Configuration file loaded.
[MESSAGE] Setting no custom theme.
[MESSAGE] Creating main window.
[MESSAGE] Main window created.
[MESSAGE] Initializing Lua.
[MESSAGE] Lua version is Lua 5.2.
[MESSAGE] Lua state created.
[MESSAGE] Loading base extension.
[LUA] Lua Lua 5.2 loaded.
[ERROR] Fail to load lua script "/home/shn/.lovetext/base.lua".
[MESSAGE] Loading extensions.
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/backup.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/command_palette.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/file_manager.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/git.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/git_diff.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/make.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/minimap.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/set_language.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/terminal.lua".
[ERROR] Fail to load lua script "/home/shn/.lovetext/plugins/toggle_scrollbar.lua".
[MESSAGE] Lua initialized.
[MESSAGE] Performing action "window.open".
[1]    8358 segmentation fault (core dumped)  lovetext

Do you have LGI installed? I think you don't, because the message "[LUA] Lua Lua 5.2 loaded." is printed by the "base.lua", but after that, the program fails to load the script. This is because the LGI module is required right after that print message:

print("[LUA] Lua " .. _VERSION .. " loaded.")
local lgi = require 'lgi'
local GtkSource = lgi.GtkSource
local Gio = lgi.Gio
...

But, as precaution measure, I will add more print's after the "[MESSAGE] Performing action "window.open"", just to be sure where the segfault occurs.

Offline

#24 2015-02-22 16:56:36

Shinryuu
Member
From: /dev/urandom
Registered: 2010-02-27
Posts: 339

Re: Love Text (text editor)

For some odd reason I totally missed this 'lgi' package, and it loads things just fine. I've tried to use different and default GTK themes to check if they have any impact for the segfault. Well let's hope it's just a little thing somewhere smile

Offline

#25 2015-04-08 12:32:57

FelipeFS
Member
Registered: 2015-02-11
Posts: 19

Re: Love Text (text editor)

Just updating:
There is only one bug I'm trying to solve, I think there is a problem with the save as function. When I solve the problem, I will launch a stable or beta version.

Offline

Board footer

Powered by FluxBB