Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 00:12 20 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: XEdit Text Editor

     Page 1 of 4    
Author Message
epsilon

Senior Member

Joined: 30/07/2020
Location: Belgium
Posts: 255
Posted: 05:41pm 29 Oct 2020
Copy link to clipboard 
Print this post

Hi all,

We all know and love the built-in editor, but it's good to have options.
XEdit is a text editor for CMM2. The editor is written in MMBasic so is by construction open source and extensible.
XEdit supports up to two windows, two buffers (files), undo and the usual complement of editor operations.
Many features are still in the pipeline. See the README below for details.

When taking XEdit for a spin please keep in mind that this is an early alpha release. There will be bugs.
Please let me know what you think, report bugs and feel free to request features.

Cheers,
Ruben/Epsilon.

GitHub:
https://github.com/epsilon537/xedit_cmm2








xedit.zip
   
XEdit Text Editor for Color Maximite 2 by Epsilon
-------------------------------------------------
Current Version: 0.1

ChangeLog
---------
0.1:
- Initial version.

Description
-----------
XEdit is a text editor written in MMBasic. The editor supports up to two windows (Hsplit/Vsplit
or no split) and up to two buffers (files). The two buffers can be freely assigned to
windows and two windows can present separate views into a single buffer.
XEdit supports undo as well as the usual complement of operations: cut/copy/paste, find/replace,
indent/unident selections, insert/overwrite mode, goto line.

To Do's
-------
- Add support for vegipete's FileDialog
- Add option to display row numbers next to the rows
- Add Select-All key binding
- Add Macro recording and playback
- Maintain backup files when saving
- Syntax Highlighting
- Add scroll current line to center/top/end key bindings
- Restore previous context when starting editor
- Add Find Next keybinding
- Add resource utilization pop-up
- Add optional config file with user configurable keybindings and other options

Limitations
-----------
- Max. 14000 lines across all buffers (including clipboard and undo buffer).
- Max. 2 windows
- Max. 2 buffers

KeyBindings
-----------
F1 = Help
F2/F9 = Save File/Save File as
F3 = Load File
F4 = Toggle Buffer
F5 = Toggle Window split
F10 = Quit
Ctrl-O = Toggle Active Window
Ctrl-F = Find Prompt/Selection
Ctrl-R = Replace Prompt/Selection
Ctrl-X/Ctrl-Y/Ctrl-P = Cut/Copy/Paste
Ctrl-G = Goto Line
INS = Toggle Insert/Overwrite mode
Home 1x/2x/3x = Go To Start of Line/Page/Buffer
End 1x/2x/3x = Go To End of Line/Page/Buffer
Tab/Shift-Tab = Indent/Unindent Line/Selection
Shift-Navigation Key = Start/Extend Selection
Ctrl-Z = Undo
Alt-K = Show Key Code at prompt
Alt-S = Screenshot
Epsilon CMM2 projects
 
NPHighview

Senior Member

Joined: 02/09/2020
Location: United States
Posts: 192
Posted: 05:49pm 29 Oct 2020
Copy link to clipboard 
Print this post

Geachte heer epsilon:

* Love the keybindings!
* Is it possible to cut/copy from one buffer and paste into the other? That would be wonderful.
* I do appreciate the syntax highlighting in the "regular" editor, and in syntax-sensitive external editors like Notepad++.  Do you anticipate adding that feature?

Looking forward to using your editor!

- Steve (why yes, I did live in a Flemish-speaking area of Europe for a while) Johnson
Live in the Future. It's Just Starting Now!
 
epsilon

Senior Member

Joined: 30/07/2020
Location: Belgium
Posts: 255
Posted: 05:59pm 29 Oct 2020
Copy link to clipboard 
Print this post

  NPHighview said  
* Is it possible to cut/copy from one buffer and paste into the other? That would be wonderful.


Yes, that is supported.

  NPHighview said  
* I do appreciate the syntax highlighting in the "regular" editor, and in syntax-sensitive external editors like Notepad++.  Do you anticipate adding that feature?


Yes, that's a must-have, right after the File Dialogs.

  NPHighview said  
- Steve (why yes, I did live in a Flemish-speaking area of Europe for a while) Johnson


Met vriendelijke groeten,
Ruben/Epsilon  
Epsilon CMM2 projects
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3831
Posted: 06:15pm 29 Oct 2020
Copy link to clipboard 
Print this post

Looking good "Epsilon",

You've probably got your own ideas, but you'll find BASIC for an MMBasic parser and code for (VT100 so no good for VGA output) syntax highlighting (amongst other things) here: https://github.com/thwill1000/sptools/tree/master/src/sptrans

I don't think it's fast enough to use within an editor, but it hasn't been seriously optimised and perhaps its a starting point if you've got nothing better.

Best wishes,

Tom
Edited 2020-10-30 04:16 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1133
Posted: 08:00pm 29 Oct 2020
Copy link to clipboard 
Print this post

Hi Ruben,

this is absolutely fantastic! Far more than expected.
The scrolling is fast and smooth, and you've even made an undo available!
I expected a few but couldn't find a bug!
I'm looking forward to version 0.2!  

Regards
Michael

PS:
I suggest changing the search function so that it is case-insensitive.
 
mkopack73
Senior Member

Joined: 03/07/2020
Location: United States
Posts: 261
Posted: 08:10pm 29 Oct 2020
Copy link to clipboard 
Print this post

Very cool!!!!
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1133
Posted: 08:36pm 29 Oct 2020
Copy link to clipboard 
Print this post

I finally found a bug:
Paste is CTRL-V, not CTRL-P, as indicated in the  help screen. .
Edited 2020-10-30 06:36 by twofingers
 
epsilon

Senior Member

Joined: 30/07/2020
Location: Belgium
Posts: 255
Posted: 11:18am 30 Oct 2020
Copy link to clipboard 
Print this post

  twofingers said  I finally found a bug:
Paste is CTRL-V, not CTRL-P, as indicated in the  help screen. .


Thanks Michael. I'll fix that of course. I'll also make the search function case insensitive.
Btw, I think the most frustrating issue I have right now is that I still occasionally press Ctrl-C to copy instead of Ctrl-Y...

I've been using the editor to write the editor to some extent. That helped to flush out the most obvious bugs, but I'm sure there's still a long tail of more subtle and some not so subtle bugs.

Cheers,
Ruben/Epsilon.
Epsilon CMM2 projects
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1133
Posted: 12:28pm 30 Oct 2020
Copy link to clipboard 
Print this post

Hi Ruben,

  Quote  Btw, I think the most frustrating issue I have right now is that I still occasionally press Ctrl-C to copy instead of Ctrl-Y...


You know that you can use Ctrl-C for copy? But I don't know if it's a good idea ...

  Quote  OPTION BREAK nn Set the value of the break key to the ASCII value 'nn'.
This key is used to interrupt a running program. The value of the break key is set to CTRL-C key at power up but it can be changed to any keyboard key using this command (for example, OPTION BREAK 4 will set the break key to the CTRL-D key). Setting this option to zero will disable the break function entirely.


BTW: I use this key assignments for Cut, Copy and Paste:
CONST KEY_CTRL_INS% = 388
CONST KEY_SHFT_INS% = 1156

CONST KEY_SHFT_DEL% = 1151


CONST CUT_KEY% = KEY_CTRL_X%
CONST CUT_KEY1% = KEY_SHFT_DEL%
CONST COPY_KEY% = KEY_CTRL_Y%
CONST COPY_KEY1% = KEY_CTRL_INS%
CONST PASTE_KEY% = KEY_CTRL_V%
CONST PASTE_KEY1% = KEY_SHFT_INS%


   CASE CUT_KEY%,CUT_KEY1%
     cutKeyHandler
   CASE COPY_KEY%,COPY_KEY1%
     copyKeyHandler
   CASE PASTE_KEY%,PASTE_KEY1%
     pasteKeyHandler


... and this
option F12 "*\xedit"+chr$(13)
to start xedit.

Thank you for this masterpiece!

Michael
Edited 2020-10-30 22:30 by twofingers
 
epsilon

Senior Member

Joined: 30/07/2020
Location: Belgium
Posts: 255
Posted: 02:01pm 30 Oct 2020
Copy link to clipboard 
Print this post

  Quote  OPTION BREAK nn Set the value of the break key to the ASCII value 'nn'.


Thanks! I did not know that. I think I can (should?) read the user guide every week and still find new things in it.

I won't change the option in the program but I will change it on my setup, just to stop myself from accidentally aborting the editor all the time.
Epsilon CMM2 projects
 
epsilon

Senior Member

Joined: 30/07/2020
Location: Belgium
Posts: 255
Posted: 02:58pm 02 Nov 2020
Copy link to clipboard 
Print this post

Hi all,

I uploaded XEdit v0.2 to GitHub.

https://github.com/epsilon537/xedit_cmm2

V0.2 includes macro recording, context restore when starting xedit, a find-next function, and a bunch of bug fixes of course.

See Changelog below for details.

Cheers,
Ruben/Epsilon.

ChangeLog
---------
0.2:
- Cleaned up and fixed typo in help screen.
- Fixed AltGr keycombos (such as @) on Azerty keyboards
- Fixed buffer position not being remembered after full screen toggle buffer followed by toggle
 window split.
- Fixed incorrect indentation of newline when cursor was in the leading spaces section.
- Fixed undo enter not working correctly.
- Fixed crash(!) that could happen when going from single window to split screen mode and
 then toggling active window.
- Fixed match on last window row not being shown after search wraparound.
- Grouped user config settings at beginning of xedit.bas.
- Added user config. setting: SEARCH_IS_CASE_SENSITIVE%. Default=0.
- Added configurable option to restore previous context when starting editor. Default enabled.
- Added Alt-F find next function.
- Included string to find/replace in search prompt.
- Added macro recording capability, bound to F7/F8 (start/stop&playback).
- Added Close File action (F12).

KeyBindings
-----------
Key Bindings (Ref. Key Bindings section in XEdit.bas to modify):
F1         = Help
F2/F9      = Save File/Save File as
F3         = Load File
F12        = Close File
F4         = Toggle Buffer
F5         = Toggle Window split
F10        = Quit
Ctrl-O     = Toggle Active Window
Ctrl-F     = Find Prompt/Selection
Alt-F      = Find Next
Ctrl-R     = Replace Prompt/Selection
Ctrl-X/Y/V = Cut/Copy/Paste
Ctrl-G     = Goto Line
INS        = Toggle Insert/Overwrite mode
Home 1x/2x/3x = Go To Start of Line/Page/Buffer
End 1x/2x/3x = Go To End of Line/Page/Buffer
Tab/Shift-Tab = Indent/Unindent Line/Selection
Shift-Navigation Key = Start/Extend Selection
Ctrl-Z     = Undo
F7         = Start Macro Recording
F8         = Stop Macro Recording / Playback recorded macro
Alt-K      = Show Key Code at prompt
Alt-S      = Screenshot
 
User Configurable Settings (Set at start of XEdit.bas):
SEARCH_IS_CASE_SENSITIVE%=0/1. Default=0.
TAB_WIDTH%=<Num.>. Default=2.
RESTORE_PREV_SESSION_CTXT%=0/1. Default=1.
Epsilon CMM2 projects
 
elk1984

Senior Member

Joined: 11/07/2020
Location: United Kingdom
Posts: 227
Posted: 07:41pm 02 Nov 2020
Copy link to clipboard 
Print this post

  epsilon said  Hi all,

I uploaded XEdit v0.2 to GitHub.

https://github.com/epsilon537/xedit_cmm2


This is absolutely excellent.  Just one question - are you using KEYDOWN because of SHIFT+Arrow Key combinations?  I ask because I'd love to use this over TeraTerm but KEYDOWN rules that out.
Edited 2020-11-03 05:41 by elk1984
 
epsilon

Senior Member

Joined: 30/07/2020
Location: Belgium
Posts: 255
Posted: 09:06pm 02 Nov 2020
Copy link to clipboard 
Print this post

  Quote  This is absolutely excellent.  Just one question - are you using KEYDOWN because of SHIFT+Arrow Key combinations?  I ask because I'd love to use this over TeraTerm but KEYDOWN rules that out.


Thank you. I am using KEYDOWN. I started out using INKEY, but INKEY just returns one byte and that wasn't good enough. I was starting to hit key combos that I couldn't capture correctly because they would overlap with other keys/combos already in use.

There were a few other reasons for giving up on serial:

- The cursor is a sprite, mainly because I wanted a different cursor for insert and overwrite mode. If it wasn't for overwrite mode I could have used alternating print/inverse print as a cursor. That's what Hexedit is doing btw.
- The window headers are continuously updated, i.e. reprinted, to reflect current status such as row and column position. That probably won't work well over serial.
- OPTION CONSOLE SCREEN is just much faster because not restricted by a baudrate, which really helps when doing full page scrolling for instances.
Epsilon CMM2 projects
 
elk1984

Senior Member

Joined: 11/07/2020
Location: United Kingdom
Posts: 227
Posted: 09:24pm 02 Nov 2020
Copy link to clipboard 
Print this post

  epsilon said  Thank you. I am using KEYDOWN...

That probably won't work well over serial.
- OPTION CONSOLE SCREEN is just much faster because not restricted by a baudrate, which really helps when doing full page scrolling for instances.


Thanks for the time to explain the rationale.  I'm actually using TeraTerm + a VGA capture card + OBS, so seeing the sprites etc. doesn't apply in my case.  I do keep a Logitech keyboard handy for emergencies but try not to keep it on my desk all the time (my brain can't track two keyboards and I invariably end up typing commands into the wrong machine  )
 
epsilon

Senior Member

Joined: 30/07/2020
Location: Belgium
Posts: 255
Posted: 11:17am 04 Nov 2020
Copy link to clipboard 
Print this post

  elk1984 said  I'm actually using TeraTerm + a VGA capture card + OBS, so seeing the sprites etc. doesn't apply in my case.  I do keep a Logitech keyboard handy for emergencies but try not to keep it on my desk all the time (my brain can't track two keyboards and I invariably end up typing commands into the wrong machine  )


That's quite a setup you have, but I get it. The number of times I sat staring at my laptop screen wondering where all the text is going that I'm typing, only to find out that my e-mail response is now embedded in the XEdit.bas source code...

I switched over to TEXT recently for the window contents. TEXT isn't affected by the serial baud rate I think, so I might be able to drop the OPTION CONSOLE SCREEN.
I might also be able to reinstate INKEY instead of KEYDOWN as an option. Certain keybindings would have to change in that mode however. Maybe I can use ctrl+space to mark the start of a selection instead using shift+navigation keys.

But ultimately the goal should be that the CMM2 becomes self contained enough that the PC dependency can be dropped altogether. But we'll need a lot more tools on the CMM2 before that can happen (including a BBS front-end for The Back Shed maybe?).
Epsilon CMM2 projects
 
epsilon

Senior Member

Joined: 30/07/2020
Location: Belgium
Posts: 255
Posted: 02:53pm 21 Nov 2020
Copy link to clipboard 
Print this post

Hi all,

It was a struggle but I finally uploaded a new version of XEdit with limited syntax highlighting support.

https://github.com/epsilon537/xedit_cmm2

This version also includes some optimizations which should make the editor overall feel more responsive.
There are some critical bug fixes as well. If you already happen to be using XEdit, you really should update.

Version 0.2 contained quite a few regressions, actually making it worse than 0.1. My apologies for that. I hope 0.3 will do better. I certainly gave it a lot more run-time.

For further info, see Changelog below.

Cheers,
Ruben/Epsilon.




xedit.zip

XEdit Text Editor for Color Maximite 2 by Epsilon
-------------------------------------------------
Current Version: 0.3

ChangeLog
---------
0.3:
- Limited MMBasic Syntax Highlighting support.
- Improved vertical scrolling, line insertion and line deletion speed.
- Switched to a dark solarized color scheme. If you prefer the higher contrast blue&white theme,
 you can still select that in the user config variables section. Or you can just roll your own
 of course.
- Critical bug fix: potential program abort triggered by toggling window split. This bug was
 introduced in 0.2.
- Critical bug fix: wrap-around search without hit can leave editor in inconsistent state,
 resulting in unpredictable behavior.
- Fixed bug in replace function turning parts of replaced lines into upper case. This bug was
 introduced in 0.2.
- Macro recording fix: new macro should overwrite existing macro, not append to it. This bug was
 introduced in 0.2.
- Added DISABLE_CONFIRMATION prompt option. Default: 0.
- Fixed a bug where last lines of a buffer would show up duplicate after deleting a selection.
- Made sure that search matches are always shown fully on screen.
- Increased undo depth from 16 to 32 entries.
- Split view into a single buffer will now as much as possible maintain view in one window
 (instead of scrolling) when lines are added or removed in other window.
- Now allowing replace-with-nothing.

...

Description
-----------
XEdit is a text editor written in MMBasic. The editor supports up to two windows (Hsplit/Vsplit
or no split) and up to two buffers (files). The two buffers can be freely assigned to
windows and two windows can present separate views into a single buffer.
XEdit supports undo, macro recording, MMBasic syntax highlighting as well as the usual
complement of editor operations: cut/copy/paste, find/replace, indent/unident selections,
insert/overwrite mode, goto line.

To Do's
-------
- Add support for vegipete's FileDialog.
- Add option to display row numbers next to the rows.
- Add visual indicators of position within buffer.
- Add Select-All key binding.
- Maintain backup files when saving.
- Add scroll current line to center/top/end key bindings.
- Add resource utilization pop-up.
- Add kill-to-end-of-line (Ctrl-K) keybinding.
- Add case senstive search/replace keybindings.
- Improve horizontal scrolling speed.
- Improve search speed.

Key Bindings
------------
F1         = Help
F2/F9      = Save File/Save File as
F3         = Load File
F4         = Toggle Buffer
F5         = Toggle Window split
F10        = Quit
Ctrl-O     = Toggle Active Window
Ctrl-F     = Find Prompt/Selection
Alt-F      = Find Next
Ctrl-R     = Replace Prompt/Selection
Ctrl-X/Y/P = Cut/Copy/Paste
Ctrl-G     = Goto Line
INS        = Toggle Insert/Overwrite mode
Home 1x/2x/3x = Go To Start of Line/Page/Buffer
End 1x/2x/3x = Go To End of Line/Page/Buffer
Tab/Shift-Tab = Indent/Unindent Line/Selection
Shift-Navigation Key = Start/Extend Selection
Ctrl-Z     = Undo
F7         = Start Macro Recording
F8         = Stop Macro Recording / Playback recorded macro
Alt-C      = Toggle Syntax Highlighting On/Off
Alt-K      = Show Key Code at prompt
Alt-S      = Screenshot

Limitations
-----------
- Max. 14000 lines across all buffers (including clipboard and undo buffer).
- Max. 2 windows
- Max. 2 buffers
- Console Only
- Text entered on find prompt can't include double quotes or commas. Find selection can
includes double quotes and commas however.
- Tested on FW version 5.0505 only.
Epsilon CMM2 projects
 
elk1984

Senior Member

Joined: 11/07/2020
Location: United Kingdom
Posts: 227
Posted: 04:09pm 21 Nov 2020
Copy link to clipboard 
Print this post

  epsilon said  It was a struggle but I finally uploaded a new version of XEdit with limited syntax highlighting support.


Really nice.  Interestingly I can't open the code on my CMM2 in edit, I get a "Not enough internal memory" error.  The code does open in xedit though
 
epsilon

Senior Member

Joined: 30/07/2020
Location: Belgium
Posts: 255
Posted: 05:55pm 21 Nov 2020
Copy link to clipboard 
Print this post

Yes, you need xedit to edit xedit. Isn't that cool  
At more than 4000 lines xedit.bas probably got too big for edit. Maybe I should split the file and use #include but that would mean multiple files to transfer and keep track of.

xedit can in theory accept files of up to 14000 lines but that number includes clipboard and undo buffer lines as well. They all allocate out of the same pool of lines. So in practice you probably should go much higher than 7000 lines.
Epsilon CMM2 projects
 
markboston36
Regular Member

Joined: 27/10/2020
Location: United States
Posts: 76
Posted: 06:12pm 21 Nov 2020
Copy link to clipboard 
Print this post

awesome text editor. i couldn't get the built in editor to read inc files.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8567
Posted: 06:25pm 21 Nov 2020
Copy link to clipboard 
Print this post

  Quote   i couldn't get the built in editor to read inc files.


edit "filename.inc" or F4 from the filemanager
Edited 2020-11-22 04:32 by matherp
 
     Page 1 of 4    
Print this page
© JAQ Software 2024