Hello all!
I've been playing around with the idea to create a very minimalistic, very simple code editor for the system I've been making in Love2D. Of course nothing is wrong with using VS Code, this is what I prefer, but I feel like if I would have an integrated code editor, it would offer a nice and easy way to create quick prototypes and jump in without any setup needed.
Would anyone have any recommendations where to start making a code editor what libraries are out there that could help me get started?
This is the primary things I need:
1. UI in general the text editing field, buttons, scroll bar..etc
2. File management, the ability to manage multiple files and read and write files inside selected directory.
3. Window management, I may would like to be able to have multiple windows open, one for the code editor and one for a preview maybe.
4. Performance in general, I did have a look at some code and text editors made in Love2D and was shared many years ago I also managed to make one using ChatGPT but most of them are really slow. Not sure if there is anything that could be done about that to make sure after X lines of code, the app does not slow down. In most cases the app slow down to the point I can enter only 1 letter every 2 seconds.
What I don't really need is autocomplete, syntax highlight and error checking, tips..etc I obviously don't want to compete with VS Code, I am only trying to create a fun and integrated experience for rapid prototyping.
Thank you.
Code editor made in Love2D?
Re: Code editor made in Love2D?
Hi, I already have several projects that you may be interested on even if not all the features match your needs:
viewtopic.php?t=95818
https://codeberg.org/glitchapp/love2d-code-editor
https://codeberg.org/glitchapp/love-QWERTY-mobile
https://codeberg.org/glitchapp/Lovepad
All the projects are aimed at mobile devices and contains touch keyboards and other features aimed at touch screens, but you can easily disable those features and make a desktop version, indeed the projects were originally for desktop.
Feel free to fork them, I hope you find them useful.
viewtopic.php?t=95818
https://codeberg.org/glitchapp/love2d-code-editor
https://codeberg.org/glitchapp/love-QWERTY-mobile
https://codeberg.org/glitchapp/Lovepad
All the projects are aimed at mobile devices and contains touch keyboards and other features aimed at touch screens, but you can easily disable those features and make a desktop version, indeed the projects were originally for desktop.
Feel free to fork them, I hope you find them useful.
Re: Code editor made in Love2D?
Thanks a lot! Really appreciate it. I’m going to have a look at them
Re: Code editor made in Love2D?
Okay, so I was making really good progress with integrating this code editor in to my system.
The way I have done it, is simply when I press "f5" I load the code file and my library and then run the code
It is allow me to edit the code and run it and then return to the code editor. However, if I want to run the code once again, I get black screen. No errors, nothing just black screen.
In order to solve this, I delete all the loaded libraries from memory when I return to the code editor and reload the entire code editor.
It is solved the problem. So now I can switch back and forth between the code editor and the preview. Seemingly works perfectly.
Everything was fine until I wanted to add a UI library so I can add buttons to the code editor and what not. I decided to go with the Slab library and this is what I do.
And it does not work, because I remove all the loaded libraries before, for some reason the Slab library fail to load with the error message
Would anyone have any idea how to solve this? Either a different way to remove libs or different way to run the code from the editor?
Here is a project I prepped that demonstrate the error message with Slab: Thank you in advance.
The way I have done it, is simply when I press "f5" I load the code file and my library and then run the code
Code: Select all
local file = love.filesystem.load("mycode.lua")
if file then
love.graphics.clear()
require "MyLib"
file()
end
In order to solve this, I delete all the loaded libraries from memory when I return to the code editor and reload the entire code editor.
Code: Select all
for k in pairs(package.loaded) do
package.loaded[k] = nil
end
loadEditor()
Everything was fine until I wanted to add a UI library so I can add buttons to the code editor and what not. I decided to go with the Slab library and this is what I do.
Code: Select all
for k in pairs(package.loaded) do
package.loaded[k] = nil
end
local Slab = require "Slab"
loadEditor()
Code: Select all
module 'bit' not found
Here is a project I prepped that demonstrate the error message with Slab: Thank you in advance.
Re: Code editor made in Love2D?
Only remove the package if it's not the bit library?
I'm not entirely sure why you need to remove the packages in the first place.
I'm not entirely sure why you need to remove the packages in the first place.
LÖVE-Nuklear - a lightweight immediate mode GUI for LÖVE games
Re: Code editor made in Love2D?
Thanks. I have tried to remove the package only if its not the bit library but it did not worked.
I also uncertain why I need to remove the packages. I am sort of aimlessly messing around with integrating a code editor in to my system so I can sort of code in-game.
So basically what is happening when I run the code the first time and load my lib, everything works. But then if I return to the code editor and try to run the code again, it is no longer works. Removing the packages when I return to the code editor solve this problem.
But then I have this problem with the UI library fail to load.
I also uncertain why I need to remove the packages. I am sort of aimlessly messing around with integrating a code editor in to my system so I can sort of code in-game.
So basically what is happening when I run the code the first time and load my lib, everything works. But then if I return to the code editor and try to run the code again, it is no longer works. Removing the packages when I return to the code editor solve this problem.
But then I have this problem with the UI library fail to load.
Re: Code editor made in Love2D?
Oh, I managed to get it sorted it seems. The solution was that indeed to remove packages only if it's not the "bit" library but I have done it wrong. This is how I had to do it:
I think that the reason I need to remove the packages is that when I load my library then I initialise it with some default values but then the code I execute change these default values. So the second time I attempt to run the code, my library no longer loaded because already loaded and no longer initialised and stop working because of this. Removing the package and reload it solve this it seems because then my lib initialised with the proper values.
Guess I could improve it by only remove my package instead of all the packages with the exception of "bit".
I didn't touched Lua and my system for months, practically I have no idea what am I doing.
But for now, it seems I have this particular problem solved and I have the UI library loaded in to the code editor.
Code: Select all
for k in pairs(package.loaded) do
if k ~= "bit" then
package.loaded[k] = nil
end
end
Guess I could improve it by only remove my package instead of all the packages with the exception of "bit".
I didn't touched Lua and my system for months, practically I have no idea what am I doing.
But for now, it seems I have this particular problem solved and I have the UI library loaded in to the code editor.
Who is online
Users browsing this forum: Google [Bot] and 6 guests