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

Opus Editor

Started by Kepler, 20 December 2016 - 09:43 PM
Kepler #1
Posted 20 December 2016 - 10:43 PM
Opus Editor

A replacement for the in-game editor. Featuring:
  • Cut, copy, paste
  • Find, find again
  • Go to line
  • Block marking (for copy/paste operations)
  • Multiple undo
  • Enhanced movement key combinations
Manual Installation
pastebin get pEFCYXX1 edit.lua
Add the following to startup
shell.setAlias('edit', 'edit.lua')

Packman Installation
packman install OpusEdit
note: file will be installed as usr/bin/opedit

Source: http://pastebin.com/pEFCYXX1



Key bindings
Spoilerup = 'up',
down = 'down',
left = 'left',
right = 'right',
pageUp = 'pageUp',
[ 'control-b' ] = 'pageUp',
pageDown = 'pageDown',
[ 'control-f' ] = 'pageDown',
home = 'home',
[ 'end' ] = 'toend',
[ 'control-home' ] = 'top',
[ 'control-end' ] = 'bottom',
[ 'control-right' ] = 'word',
[ 'control-left' ] = 'backword',
[ 'scrollUp' ] = 'scroll_up',
[ 'control-up' ] = 'scroll_up',
[ 'scrollDown' ] = 'scroll_down',
[ 'control-down' ] = 'scroll_down',
[ 'mouse_click' ] = 'goto',
[ 'control-l' ] = 'goto_line',

– marking
[ 'shift-up' ] = 'mark_up',
[ 'shift-down' ] = 'mark_down',
[ 'shift-left' ] = 'mark_left',
[ 'shift-right' ] = 'mark_right',
[ 'mouse_drag' ] = 'mark_to',
[ 'shift-mouse_click' ] = 'mark_to',
[ 'control-a' ] = 'mark_all',
[ 'control-shift-right' ] = 'mark_word',
[ 'control-shift-left' ] = 'mark_backword',
[ 'shift-end' ] = 'mark_end',
[ 'shift-home' ] = 'mark_home',

– editing
delete = 'delete',
backspace = 'backspace',
enter = 'enter',
char = 'char',
paste = 'paste',
tab = 'tab',
[ 'control-z' ] = 'undo',

– copy/paste
[ 'control-x' ] = 'cut',
[ 'control-c' ] = 'copy',
[ 'control-v' ] = 'paste',
[ 'control-t' ] = 'toggle_clipboard',

– file
[ 'control-s' ] = 'save',
[ 'control-q' ] = 'exit',
[ 'control-enter' ] = 'run',

– search
[ 'control-slash' ] = 'find_prompt',
[ 'control-n' ] = 'find_next',

– misc
[ 'control-g' ] = 'status',
[ 'control-r' ] = 'refresh',
[ 'leftCtrl' ] = 'menu',
Edited on 07 January 2017 - 12:42 AM
Pyuu #2
Posted 21 December 2016 - 04:33 AM
Nice program. The find function is my personal favorite when editing files (especially with the way the editors scroll and limited screen size.)
Though personally the normal search hotkey would be CTRL+F (which threw me off).

My question though is why are there the grey periods at the end of every sentence?
Pyeroh #3
Posted 21 December 2016 - 09:51 AM
Yep, very nice program ! I tested it a bit, and it's very friendly to use !

However, there's no autocomplete… Maybe a next feature ?

EDIT : stuff I noted so far :
  • No autocomplete in editor
  • No autocomplete for entering editor (when I type my file's name)
  • I'm not able to type chars for which AltGr is needed (eg '#' or '[')
Edited on 21 December 2016 - 09:43 AM
Wilma456 #4
Posted 22 December 2016 - 01:16 PM
This programm is awsome! I had make me a Resource Pack to put this programm to all my Computers! But i also found a few problem: The clipboard is not global. I can't copy text fom one file to another. I also have found no possibility to use the clipboard of opus and the clipboard of my system together. If nothing in the clipboard of opus, it paste from my system clipboard. Is something in the clipboard of opus, it paste from the opus clipboard. And theres no autocomletion.
Kepler #5
Posted 24 December 2016 - 12:11 AM
Seems my last post was lost in the forum update.

I updated the source in pastebin. A few modifications based on the feedback provided (thanks all).

Search is now invoked by Control-f (as well as Control-/)
Autocomplete is partially implemented. Use control-space to complete what you are currently typing. I'll continue to improve this functionality.

To answer a few questions:
The trailing dots just show the line endings. I personally like to know if there are trailing spaces. If this is too distracting, let me know.
The clipboard is only for the current editor session. I can make this global for all editor sessions (but not for anything other than the editor). Note that control-t toggles between the system and internal clipboards.
For autocompleting file names from the shell prompt, you would have to add an autocomplete function during startup (look at the default startup in rom).

As for AltGr chars, I don't filter any of the char events. Are you able to type these in the standard editor ?
Wilma456 #6
Posted 29 December 2016 - 04:40 PM
Is autocomplete like edit not possible?

And I have e found a Bug:
Jumping to the last line is not possible with the mouse

btw
Can you put your awsome editor to Packman for esay install and easy update?

Please keep on working!
Pyeroh #7
Posted 04 January 2017 - 06:43 AM
Aw yiss, I found again what I was searching : http://www.computercraft.info/wiki/Textutils.complete
I think that, combined with the way the standard startup.lua is written, it can be very useful to perform auto-completion
Kepler #8
Posted 07 January 2017 - 01:50 AM
Is autocomplete like edit not possible?
I'm not a fan of the way autocomplete is implemented in the standard editor. I'll try to improve my implementation.

And I have e found a Bug:
Jumping to the last line is not possible with the mouse
The last line is there just to show more of the text for smaller screens.

Can you put your awsome editor to Packman for esay install and easy update?
Done - the OP has been updated with instructions.

Thanks for your feedback
Wilma456 #9
Posted 18 January 2017 - 04:28 PM
Thank you for moving it to Packman.

I have a suggestion for autocomplete: Write the first possibility. If the User pressing the autocomplection key again, replace it with the next possibility. If he pressing another key then exit the loop. I can give you the code for that, if the possibilities are in a table.

Why you are not making the clipboard global? Then the content of the clipboard is still aviable after closing Opus to use it in the next session. And you can share the clipboard with other programs.

While coding my programs I had to replace much and had to exit Minecraft to do this with a external editor. I think a replace all function in Opus would be nice.
H4X0RZ #10
Posted 18 January 2017 - 08:45 PM
Thank you for moving it to Packman.

I have a suggestion for autocomplete: Write the first possibility. If the User pressing the autocomplection key again, replace it with the next possibility. If he pressing another key then exit the loop. I can give you the code for that, if the possibilities are in a table.

Why you are not making the clipboard global? Then the content of the clipboard is still aviable after closing Opus to use it in the next session. And you can share the clipboard with other programs.

While coding my programs I had to replace much and had to exit Minecraft to do this with a external editor. I think a replace all function in Opus would be nice.

You can't make the clipboard "global". It's only possible to store it in some file so Opus could load it once it starts, and maybe other programs might pick that trend up too and use Opus' file, but you can't modify the clipboard itself.
Wilma456 #11
Posted 19 January 2017 - 07:07 PM
Thank you for moving it to Packman.

I have a suggestion for autocomplete: Write the first possibility. If the User pressing the autocomplection key again, replace it with the next possibility. If he pressing another key then exit the loop. I can give you the code for that, if the possibilities are in a table.

Why you are not making the clipboard global? Then the content of the clipboard is still aviable after closing Opus to use it in the next session. And you can share the clipboard with other programs.

While coding my programs I had to replace much and had to exit Minecraft to do this with a external editor. I think a replace all function in Opus would be nice.

You can't make the clipboard "global". It's only possible to store it in some file so Opus could load it once it starts, and maybe other programs might pick that trend up too and use Opus' file, but you can't modify the clipboard itself.

Global Vars can be used by other Programs. They are not deletet after closing the Programm who has they created. They can can only deletet by making them nil or shutdown the Computer.
H4X0RZ #12
Posted 19 January 2017 - 09:13 PM
Sure, but there's a difference between "the variable is available" and "a program cares about the variable".

You would have to standardize a software-side clipboard and somehow get everyone to use it in favor of their implementation, or completely add the feature, to actually make use of it.
Wilma456 #13
Posted 05 September 2017 - 01:40 PM
The Link in the Packman package is not working.
Kepler #14
Posted 05 September 2017 - 02:38 PM
The Link in the Packman package is not working.

Fixed…
Dave-ee Jones #15
Posted 06 September 2017 - 06:56 AM
The Link in the Packman package is not working.

Fixed…

Cool, nice program! Definitely better than the default editor, though still not better than Notepad++ :P/>

Sure, but there's a difference between "the variable is available" and "a program cares about the variable".

You would have to standardize a software-side clipboard and somehow get everyone to use it in favor of their implementation, or completely add the feature, to actually make use of it.

Actually I did something like that with Bass, except it does passwords instead of a clipboard - but it wouldn't be hard to make a clipboard. Only annoying thing is it has to be run first before any other program (startup program that calls the 'real' startup program - if you have one), or just the shell. But it would catch Ctrl+C and Ctrl+V and copy/paste accordingly into the overlaying program's read() areas.
Kepler #16
Posted 06 September 2017 - 08:14 AM
Cool, nice program! Definitely better than the default editor, though still not better than Notepad++ :P/>
Ha !

Actually I did something like that with Bass, except it does passwords instead of a clipboard - but it wouldn't be hard to make a clipboard. Only annoying thing is it has to be run first before any other program (startup program that calls the 'real' startup program - if you have one), or just the shell. But it would catch Ctrl+C and Ctrl+V and copy/paste accordingly into the overlaying program's read() areas.
I actually added a global clipboard awhile ago - just forgot to update this thread. The global clipboard is installed the first time you run the editor.
Wilma456 #17
Posted 06 September 2017 - 01:11 PM
btw: Can you add this code to Opus to add autocompletion in shell:

local function completeFile( shell, nIndex, sText, tPreviousText )
  if nIndex == 1 then
	return fs.complete( sText, shell.dir(), true, false )
   end
end
shell.setCompletionFunction( shell.getRunningProgram() , completeFile )
Kepler #18
Posted 06 September 2017 - 02:04 PM
btw: Can you add this code to Opus to add autocompletion in shell:

Added.