This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Possseidon's profile picture

Notepad LuaEditor

Started by Possseidon, 12 March 2015 - 12:07 PM
Possseidon #1
Posted 12 March 2015 - 01:07 PM
Updated to Version 1.04
Contains auto updater now!

Hey everybody!

I finally finished my Notepad LuaEditor so far that I can publish it and it turned out pretty cool and useful in the end!

Have a short list of features it contains:
  • Menubar that can be triggered with ctrl shortcuts
  • Windows with buttons, labels, textfield, checkboxes, …
  • Text selection, copying, pasting, etc.
  • Better Highlighting, Line Numbers and a StatusBar
  • Code Suggesting/Completion
  • Searching for text
  • Integrated debugger
Here are some screenshots of the Editor in action (Version 1.0):






Doesn't it look pretty cool? :D/>/>/>/>

Everything is completly written by myself (the two APIs as well), meaning I'm open for any questions you have!

I wish you lots of fun with my ComputerCraft Version of Notepad

Changelog:
Changelog 1.04:
Spoiler- bug: table = abc.insert colored wrong
- bug: too much rendering especially with multiline comments
- bug: you can get uncolored multiline comments/strings by:
> pasting a comment that is longer than the screenheight
> goto line where comment-start was not displayed yet
- bug: everything gets rendered when scrolling not changing anything
- bug: home and end key render line if no scroll
- bug: all text gets rendered when statusbar disappears
- bug: ctrl-S draws whole screen
Version 1.03
Spoiler- try adding ä|ö|ü|ß press prevention since they bug out anyway
- bug: before debugging, ctrl-timer can be still active, causing events
- bug: "table.–XXX.sort" comment note colored as comment
- ctrl-[home/end] scrolls 10 chars right/left (useful for selection)
- bug: deleting everything from codesuggestion will not trim spaces after line
- bug: "table." with line end after you can open code suggestion with freecursor everywhere behind it
- bug: "elseif"/"else" should also count as "end" for "if"
- bug: selection not reset after opening file
- bug: save as can't open folder
Version 1.02
Spoiler- SaveAs Window
- Explorer not getting updated after disk/peripheral which changes filestructure
- Coloring/Suggesting of sth like "test"..textutils.serialize
- bug "table: <rest until="" end="" of="" line="">" rest until end of line not highlighted
- scroll "hitbox" of explorer offset down
- Pressing "open" in the OpenWindow on a folder/nothing crashes
- Opening a read-only file not changing filename
- Add Bool Const to Code Highlighting
- Add keywords (while/true/return/…) to suggestion
- add shell.getRunningProgram()-override for debug to simulate a real "shell.run"
- bug "test" bla "\\" > bla highlighted as string
Version 1.01
Spoiler- external pasting not removing selection
- strings using [[foo bar]] now work multilined as well (like –[[ comments ]])
- moved goto, find, find next to view-tab
- Selection in uncolored mode
- add options window to view-tab:
+ Toggle Code Suggestion
+ Toggle Highlighting
+ Modular LineNr Width
+ Toggle Free Cursor
+ Create missing counterpart for "while/repeat/for/…"
- opening/closing a window won't scroll if cursor is offscreen
- added "goto error" in error window
- added AutoUpdater!
- Open File Window
Todo: (give me more ideas! :D/> )
Spoiler- redo/undo
- Add some sort of Help for whole IDE
- make windows moveable with left-click-drag and reset to their original centered position with right-click
- ctrl-backspace deletes whole word/expression
- add some right-click actions:
+ Code:
> if click on global const, open window showing its value in a textbox
> if click on linenumber where do/function/loop-start shrink whole code inside and color lineNr orange
- add downloadable color-theme support
- spilt Preferences into more windows
- change Preferences from below
- add .notepad folder for config/active theme/…

Here the pastebin links for all the files:

Use this to install everything automatially:
pastebin run A8vHkwsp

OR

Get the needed files on your own:
notepad:
pastebin get tw5dBNJb notepad

APIs:
pastebin get sFgHKGnH apis/advTable
pastebin get g1RALA3Q apis/application</rest>
Edited on 05 June 2015 - 06:25 PM
ROBOTS #2
Posted 17 March 2015 - 04:08 AM
Huh- I'll give this a shot. I usually code outside of minecraft, but this would be waaaay less painful for debugging and last-minute tweaking.
minebuild02 #3
Posted 28 March 2015 - 03:20 PM
This "Notepad" is more than a code editor. It's an IDE.
But, can you publish it using Pastebin?
Edited on 28 March 2015 - 02:21 PM
rahph #4
Posted 28 March 2015 - 03:39 PM
This "Notepad" is more than a code editor. It's an IDE.
But, can you publish it using Pastebin?
i agree. Just put all files on pb, remember codes and then shell.run("pastebin get <code> <dir>") for each part of code inside installer
Edited on 28 March 2015 - 02:39 PM
LewisMC #5
Posted 28 March 2015 - 05:30 PM
Any chance I could download a simple installer script from Pastebin?
Creator #6
Posted 28 March 2015 - 09:23 PM
This is amazing, seriously. For how long have you been coding in Lua? And I see you only have 7 posts at the moment, which means you probably have not published any CC app. Is this your first app?

You get a +1

After further inspection, make it load the apis, it is simpler.
Edited on 28 March 2015 - 08:45 PM
Exerro #7
Posted 28 March 2015 - 10:36 PM
This is very, very good; on the same level as the other good editors on the forums at least, if not better.

Some slight issues:

That happened when I tried to go to line 10 (which didn't exist, although after further testing it happens whenever I try the goto feature).
  • It appears that you can start typing anywhere on a line. Clicking on the right side of the screen on the cursor line will put the cursor there, even with a blank file, and lets you type there too.
  • Find doesn't work?
  • Selection misses one character out (the rightmost character of the selection).
  • Also, people will be much more likely to try this out if it's easy to install. Making a simple installer would really help, and making it load the APIs automatically would too.
Some things that would be nice:
  • Undo/redo.
  • Make it show the line that an error occurred on when it errors.
minebuild02 #8
Posted 29 March 2015 - 10:05 AM
This "Notepad" is more than a code editor. It's an IDE.
But, can you publish it using Pastebin?
i agree. Just put all files on pb, remember codes and then shell.run("pastebin get <code> <dir>") for each part of code inside installer
You just put all files in a folder, package it using oeed's Package Maker and publish the package on Pastebin.
Possseidon #9
Posted 29 March 2015 - 08:22 PM
Wow! Already thought nobody would give me any feedback at all!

And now I take a look and see "7 replies" xD

Well, thanks for all the positive feedback, I'll upload it to pastebin and add it to the main post ^^
Possseidon #10
Posted 29 March 2015 - 08:36 PM
This is very, very good; on the same level as the other good editors on the forums at least, if not better.

Some slight issues:

That happened when I tried to go to line 10 (which didn't exist, although after further testing it happens whenever I try the goto feature).
  • It appears that you can start typing anywhere on a line. Clicking on the right side of the screen on the cursor line will put the cursor there, even with a blank file, and lets you type there too.
  • Find doesn't work?
  • Selection misses one character out (the rightmost character of the selection).
  • Also, people will be much more likely to try this out if it's easy to install. Making a simple installer would really help, and making it load the APIs automatically would too.
Some things that would be nice:
  • Undo/redo.
  • Make it show the line that an error occurred on when it errors.

Thanks for the bug-report!

I rewrote the application-api a little while ago, and it seems there are still some small issues with it ^^

The fact that you can start writing in a line wherever you want is NOT a bug, but a feature xD I prefer that in editors (if you don't I'm sorry, mb i will add an option for it ;)/> )
Find does work! After you close the find window you have to use CTRL-L (or press Find Next) to find the first and keep pressing CTRL-L again and again to find all other matches
That's not a "bug" either. Imagine the cursor as a | that is on the left side of the _ and everything works correctly :P/>
Yes, I uploaded it to pastebin, edited the main post :)/>

undo/redo crossed my mind as well, but i honestly was just too lazy to do it… after you told me I probably will add it though ^^
Even though, showing the error line doesn't work always (which is btw not my fault) it does work! Sadly, it doesn't give you an error line if you for example give term.write() wrong parameter var-types
Also, if you tested it with "error()", that only gives you an error line if you gave the "error()" an error-msg (like: error("Error occured!") )

Or did you mean sth like coloring the error line in red? I thought, going to that line automatically would be enough and it would be a bit hard to make that work with selection and some other things ^^
Maybe I could color the line number on the left though… that would be a not to hard option

Wish you lots of happy programming ^^
Edited on 29 March 2015 - 07:52 PM
Square789 #11
Posted 31 March 2015 - 12:16 PM
This is an awesome program, it has text selection, copying, syntax highlighting, auto-completing and more…!

But if you are on the end of any line and hit the arrow-right-key,
the program inserts spaces - maybe you could fix that.

Also, maybe you could add:
  • An opening-function, so you don't have to type ,,notepad MyFile" into the shell.
  • A ,,Save as…"-fuction to change the filename easily

But you did a really great job!
Possseidon #12
Posted 31 March 2015 - 04:54 PM
This is an awesome program, it has text selection, copying, syntax highlighting, auto-completing and more…!

But if you are on the end of any line and hit the arrow-right-key,
the program inserts spaces - maybe you could fix that.

Also, maybe you could add:
  • An opening-function, so you don't have to type ,,notepad MyFile" into the shell.
  • A ,,Save as…"-fuction to change the filename easily
But you did a really great job!

Thanks for the good feedback!
I already told another user, it is NOT a bug, that you can move your cursor around freely and let it insert spaces automatically. It's a feature! (actually it would be way easier to program it without it)

And if you think there are tons of spaces after every line because of that, no! every unneeded space character gets deleted. Also it only creates them when you really type something. Just moving the cursor doesn't even change something at the actual text (which even if it did, would get deleted worst case after saving)

(Maybe) I will add another window (which is pretty easy the way I programmed it) for save-as and open file… but i don't know how advanced I'll do those. They might just end up like beeing an empty window with one inputfield or sth xD
If I'm reeeeally bored though I could try making a good old lil explorer to search through your files (especially for the opening)

Wish you lots of fun with the editor ;)/>
GopherAtl #13
Posted 31 March 2015 - 05:10 PM
You really ought to make at least a simple installer - just a few lines using shell.run and mkdir to to make apis dir if it doesn't exist in another pastebin that can be "pastebin run" would work nicely, and be a lot easier

Anyway, decided to test it out, I ran "notepad notepad" and it loaded the first 4 lines and no more. Seemed to be working otherwise, but obv this is not the intended behavior.
Possseidon #14
Posted 31 March 2015 - 05:32 PM
You really ought to make at least a simple installer - just a few lines using shell.run and mkdir to to make apis dir if it doesn't exist in another pastebin that can be "pastebin run" would work nicely, and be a lot easier

Anyway, decided to test it out, I ran "notepad notepad" and it loaded the first 4 lines and no more. Seemed to be working otherwise, but obv this is not the intended behavior.

It is the intended behaviour! Notepad can save one file into more units (see menubar File>Units). What you saw is only the first unit that notepad itself is structured in. You can switch via shortcut with CTRL-left/right or press on the arrows in the line diectly under the menubar.

The way it saves units is by adding commented lines into your programm that get decoded once notepad loads them up.

Probably will have added a "pastebin run XXXXXXXX" installer by the time you read this comment ^^

Hope I could help and I'm still open for any ideas to make notepad better ;)/>
GopherAtl #15
Posted 31 March 2015 - 06:19 PM
ah, ok, I see now. I'd noticed and wondered at the whole units thing, but at that point was in a file that had only the one, and didn't notice notepad had 11. I'm… kindof not sure what to make of that feature. It's an interesting concept, is it something some other editor you're used to does, or just something you came up with?
Possseidon #16
Posted 31 March 2015 - 06:43 PM
ah, ok, I see now. I'd noticed and wondered at the whole units thing, but at that point was in a file that had only the one, and didn't notice notepad had 11. I'm… kindof not sure what to make of that feature. It's an interesting concept, is it something some other editor you're used to does, or just something you came up with?

I just thought it would be nice to have your file more structured… Gives you better overview over your project and if you haven't seen it, you can use the search function just for the current unit

Btw, you don't have to use units. If the first unit is called "Default", which is standard, your file gets saved without any hints of different Units and works basically the same as the normal "edit" does.

If you wonder how you should structure your programm and notepad isn't that good of an example itself in your opinion:
  • Information about the program itself like name/description/creator/…
  • Constants used in your program
  • Predefined global Variables
  • Functions
  • The actual start of the program
That's kinda the main structure I'm using most of the time, and swap/add new ones how I need them.

Hope I could give you a better image of why I added that.
And how I said you can, if you don't like it for some reason, just ignore it ^^
Edited on 31 March 2015 - 06:12 PM
Creeper9207 #17
Posted 01 April 2015 - 03:38 AM
May i use this in my OS?
Possseidon #18
Posted 01 April 2015 - 10:46 AM
May i use this in my OS?
This is your 42 post? Congratulations, posting your 42th post in my thread!
(It's my favourite number, next to 256 and it is the answer to life, the universe and everything!)

As a present I will allow you, to use this in your OS :D/>
rahph #19
Posted 01 April 2015 - 09:26 PM
how to use units?
Possseidon #20
Posted 02 April 2015 - 09:45 AM
how to use units?
Actually, you are right… I never really explained the principle behind units xD

When you add a unit (see File>Units or ctrl-U) this will allow you to edit those units as seperate texts and by the way also save their current cursor position for easy swapping between units and you can even enable a checkbox to search only in the current unit.

Units work way simpler than you think. With them you can just structure your one loooong file into multiple parts. If the program gets started, all Units get run in the same order, they are listed in the Units-Window.
In fact, since all units are saved into one file, you can take a look at it yourself with that standard edit. In front of every Unit, notepad adds a little comment (–Unit=NAME), but in the end, if you start that program, it's the same as if it was that one loooong file.

A few posts above I gave some ideas, how you can structure your program.

Hope I could help ;)/>
Creator #21
Posted 02 April 2015 - 07:04 PM
how to use units?
Actually, you are right… I never really explained the principle behind units xD

When you add a unit (see File>Units or ctrl-U) this will allow you to edit those units as seperate texts and by the way also save their current cursor position for easy swapping between units and you can even enable a checkbox to search only in the current unit.

Units work way simpler than you think. With them you can just structure your one loooong file into multiple parts. If the program gets started, all Units get run in the same order, they are listed in the Units-Window.
In fact, since all units are saved into one file, you can take a look at it yourself with that standard edit. In front of every Unit, notepad adds a little comment (–Unit=NAME), but in the end, if you start that program, it's the same as if it was that one loooong file.

A few posts above I gave some ideas, how you can structure your program.

Hope I could help ;)/>

This is agreat idea!