This is code editor written in pure Lua that can be rendered within LÖVE framework. The editor can be used to build self-contained development environments, like fantasy consoles or in-game editors.
It is a rather complete implementation of editor component that's easy to integrate into any project. Host should provide function callbacks for drawing text and rectangles, and react to keypresses by calling into text buffer functions.
The main.lua demonstrates how to use the editor, but it is not meant to be complete standalone editor application. File access and dialogs for opening/saving files are out of scope.
Features:
* pure Lua platform-independant text buffer
* restricted to ASCII character set
* basic text typing/deleting
* easy key remapping
* horizontal and vertical scrolling
* single cursor with page up/down, word skip and other movement options
* text highlighting for Lua code, with external color scheme
* text selection, cut, copy and paste
* status line for filename and row/column info
* basic macros (quick one-liners to be executed on key combination)
* simple and extendable
* public domain code unburdened by license
There is currently no undo and search features, or support for general text files (currently always using Lua highlighting).
This LÖVE version is actually a by-product of VR project, I'm sharing here as it might be useful to someone. Future updates to the editor will be available here: https://github.com/jmiskovic/indeck
A Lua code editor
A Lua code editor
- Attachments
-
- lovedit.love
- (114.1 KiB) Downloaded 750 times
Last edited by josip on Thu Jul 23, 2020 3:18 pm, edited 1 time in total.
Re: A Lua code editor
This is really good. The only minor tweak I'd add is key repeating, but that wouldn't be too hard to tack on for an end user. Awesome!
Re: A Lua code editor
Hi I'm looking into your code.
I had implemented key repeating in the love example but I'm struggling with utf8 encoding. The editor keep crashing when I insert utf chars. It is my fault or the editor doesn't support it?
Thanks
I had implemented key repeating in the love example but I'm struggling with utf8 encoding. The editor keep crashing when I insert utf chars. It is my fault or the editor doesn't support it?
Thanks
Re: A Lua code editor
Nice. But I can't use it until you add a license
Re: A Lua code editor
Thanks for interest.
@Giovifav the unicode is not supported unfortunately. It would require about x10 more work, and my needs were already covered with basic ASCII. I'll edit the description to clarify.
@monolifed I'm releasing it into public domain for anyone to do with it as they please.
@Giovifav the unicode is not supported unfortunately. It would require about x10 more work, and my needs were already covered with basic ASCII. I'll edit the description to clarify.
@monolifed I'm releasing it into public domain for anyone to do with it as they please.
Re: A Lua code editor
Hi, thanks for the answer!
No Unicode support isn't a problem if there is a way to convert Unicode into ASCII so the editor doesn't crash.
Edit:
After a rapid googling I found this:
https://stackoverflow.com/questions/418 ... n-pure-lua
Maybe worth checking it
No Unicode support isn't a problem if there is a way to convert Unicode into ASCII so the editor doesn't crash.
Edit:
After a rapid googling I found this:
https://stackoverflow.com/questions/418 ... n-pure-lua
Maybe worth checking it
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: A Lua code editor
Can i assume that your codebase was written for lua version 5.1? (or LuaJIT without the 5.2 compatibility flag?)
I'm only asking because if someone wants to use this in löve, it has its own utf-8 library (regarding the encoding only) that one can require in (with the added ability to actually print utf-8 characters without any modifications to anything), and it's similar, if not a carbon-copy, of the PuC lua 5.3 module. (that said, strings can store anything anyway, so "only" the display and editing parts are the problem)
I'm only asking because if someone wants to use this in löve, it has its own utf-8 library (regarding the encoding only) that one can require in (with the added ability to actually print utf-8 characters without any modifications to anything), and it's similar, if not a carbon-copy, of the PuC lua 5.3 module. (that said, strings can store anything anyway, so "only" the display and editing parts are the problem)
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: A Lua code editor
Well, getting rid of UTF-8 can be done with just one line.
Code: Select all
text = text:gsub('[\192-\255][\128-\191]*', '?')
Re: A Lua code editor
My idea was to replace the utf8 char with a similar one ASCII compatible, for example ü become u, ã = a.
I'm a dummie so I don't know if is feasible.
Off topic:
pgimeno I stumble across your code multiple times, I really like your work!
I'm a dummie so I don't know if is feasible.
Off topic:
pgimeno I stumble across your code multiple times, I really like your work!
Who is online
Users browsing this forum: No registered users and 4 guests