Team Spartan Cookies & Milk Forums

Full Version: New Editor
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Something I've been working on the past few days. It's now on the server.

Light theme:
[attachment=126]

Dark theme:
[attachment=125]

This new editor is using the Ace code editor loading directly from the server. I find Ace is a much better editor than the E2 editor from wiremod (which is what SF is using currently). It also has plenty of themes so you can have it syntax highlight with the colours you want. Another advantage is I have added Starfall specific highlighting for object methods/library functions.

You can also share files to a server hosted folder for collaboration/releases.

Hopefully this will make developing SF a much better experience and allow people to share code much quicker.

Known bugs:
  • None! Please report any you find.

Console commands
  • sf_editor_fontsize - Sets the font size to use, default is 16.
  • sf_editor_autosaveinterval - Sets how often, in seconds, to auto save files. Default is 120 (every 2 minutes).
  • sf_editor_reset - Resets all settings back to default.

Keyboard shortcuts
The editor is heavily reliant on keyboard shortcuts. There's no right click menu like the old E2 editor.
  • Ctrl + Z - Undo
  • Ctrl + Y - Redo
  • Ctrl + F - Find
  • Ctrl + H - Find and replace
  • Ctrl + S - Save
  • Ctrl + N - New file
  • Tab - When selecting multiple rows, will indent all of them.
  • Shift + Tab - When selecting multiple rows, will remove an indent from all of them.
  • Ctrl + / - Toggle commenting of all selected rows.
  • Ctrl + L - Opens the command bar.
    • Type :<num> to go to line <num>, e.g :100 goes to line 100.
    • Type @<functionname> to search the current tab's code for the given function (like Sublime Text's command palette).
    • Type !<command> to run commands such as !save, !new etc.
    • Type #<searchstring> for a quick find in the current file. Hit enter to go to the next result.
    • If you start typing without a symbol at the start, it will search your local directory for matching files.

For a full list of the editor's shortcuts, see here: https://github.com/ajaxorg/ace/wiki/Defa...-Shortcuts
I like the new code editor. It looks much cleaner than the e2 editor, especially the white theme. But the "Click to check for syntax error" button could be a bit smaller so there is more space for code (or you could make the size customizable).

Edit:
An undo/redo button would be very nice, because the right-click function of the e2 editor is horrible.
(14-03-2014, 04:55 PM)_BL4CKH4WK Wrote: [ -> ]I like the new code editor. It looks much cleaner than the e2 editor, especially the white theme. But the "Click to check for syntax error" button could be a bit smaller so there is more space for code (or you could make the size customizable).

Edit:
An undo/redo button would be very nice, because the right-click function of the e2 editor is horrible.
Undo/redo is Ctrl + Z for undo and Ctrl + Y for redo, as with basically every text editor. This text editor is very keyboard heavy, there's little in the way of mouse menus/buttons.

As for the syntax check button, that was inspired by the old editor. I kind of like how it's a nice big easy to press button to check the code. However, I can make it a bit less tall, or if you have a good suggestion of how else to implement it instead of how it is at the moment, feel free to suggest.

Also, file sharing is essentially done. I just need to finish skinning a few parts of the UI (the buttons and list), deal with a few missing keyboard shortcuts and then I can upload it to the server and see how it fares "in the real world".

[attachment=55]

Oh, also, the editor highlights every single (currently implemented) SF library function. I'm going to work on adding the object methods too at some point.
You are right, a big button is much easier to press and you don't have to change it, i won't cry because of a few millimetre Wink
Ctrl+Z/Y is as good as buttons, I'm just glad that I don't have to use this weird right-click menu. Big Grin

But what about an "update files" button that the e2 editor has, or does it have an update interval?

Anyway good job! I'm looking forward to seeing it on the server. Smile
(14-03-2014, 10:35 PM)_BL4CKH4WK Wrote: [ -> ]You are right, a big button is much easier to press and you don't have to change it, i won't cry because of a few millimetre Wink
Ctrl+Z/Y is as good as buttons, I'm just glad that I don't have to use this weird right-click menu. Big Grin

But what about an "update files" button that the e2 editor has, or does it have an update interval?

Anyway good job! I'm looking forward to seeing it on the server. Smile
You can right click folders and click "Refresh". Otherwise it will auto-refresh when you save/delete/rename a file.
Is it just me or is the yellow line a bit hard to see in the github theme?

Oh, and could you add something like the E2Helper, so we don't have to check the wiki for the functions?
(15-03-2014, 11:02 AM)Veegi Wrote: [ -> ]Is it just me or is the yellow line a bit hard to see in the github theme?

Oh, and could you add something like the E2Helper, so we don't have to check the wiki for the functions?
The yellow line is probably just the JPG compression ruining the image. In game it's very easy to see.

As for an E2Helper, that's a very, very difficult thing to do for a dynamically typed language.

E2 helper works because E2 is just a bunch of fixed typed functions that output a fixed type back. SF functions can take multiple input types and potentially return multiple outputs. The docs are the only feasible way to store what all the available functions are and do I'm afraid. I think I will add a "docs" button somewhere in the editor so you can get to it while you code.

Sort of related to that, I think I have every single library function and entity method now highlighting in the editor, which ought to help too.
Well, the editor is now uploaded onto the server. The next time it starts it'll be there to test.

I hope there's no major bugs. In singleplayer at least, it's working flawlessly.

I'd call it "beta" for now.
Looks nice! Gives me a new reason to pick up starfall again Big Grin

But it still misses some really important shortcuts for a programming editor in my opinion:
- Ctrl + Left Arrow: Moves the caret one word to the left
- Ctrl + Right Arrow: Moves the caret one word to the right
- Ctrl + Backspace: Deletes the word that is behind the carret position
- Ctrl + Delete: Deletes the word that follows the carret

These features all work in this forum text editor I am writing this post in. You can try them here (tested in chrome).

Other nice to have shortcuts would be:
- Ctrl + E + C (not necessarily this exact shortcut): Comments the current line
- Ctrl + E + U (not necessarily this exact shortcut): Uncomments the current line
(19-03-2014, 09:00 AM)Cobra Wrote: [ -> ]Looks nice! Gives me a new reason to pick up starfall again Big Grin

But it still misses some really important shortcuts for a programming editor in my opinion:
- Ctrl + Left Arrow: Moves the caret one word to the left
- Ctrl + Right Arrow: Moves the caret one word to the right
- Ctrl + Backspace: Deletes the word that is behind the carret position
- Ctrl + Delete: Deletes the word that follows the carret

These features all work in this forum text editor I am writing this post in. You can try them here (tested in chrome).

Other nice to have shortcuts would be:
- Ctrl + E + C (not necessarily this exact shortcut): Comments the current line
- Ctrl + E + U (not necessarily this exact shortcut): Uncomments the current line
If you look at the link at the very bottom of the original post, you'll find those shortcuts already exist (and many more not listed in the post).

Also, commenting I listed too, it's Ctrl + / to toggle commenting of a line or multiple lines.
Pages: 1 2 3