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 3 of 4 | |||||
Author | Message | ||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
Hi all, I uploaded XEdit 0.4. Here are the changes since 0.3: - Added visual position-in-buffer indicator on right window border. - Improved search speed. - Fixed out of memory error when opening help screen in certain configurations, reported by thwill. - Fixed weird 'animation' on last line when (un)indenting a selection that spans more than 1 screen. Also made indenting much faster. - Dynamically sized keyword array (KEYWORD_LIST_DATA) using end sentinel as suggested by Jiri. - Fixed bug: Search always started from the beginning of the line instead of from cursor. - Added serial compatibility mode, enabled through flag SERIAL_INPUT_COMPAT_MODE. Note that enabling this mode affects certain keybindings. In particular, selection mode is toggled using the Esc key. - Moved find-next keybinding to Ctrl-N. Added find-previous function bound to Alt-N. - Added reverse-find keybinding, Alt-F. - F6 shows console screen as it was when launching xedit in current buffer. This allows you to see your previous program output, trace list etc. from xedit. See screenshot below. - F11 exits XEdit and runs program currently in buffer. ... To Dos ------ - Add support for vegipete's FileDialog. - 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. - Faster horizontal scrolling speed. - Support copy-to-clipboard from console screen. - More sensible buffer position when toggling window split (F5). - Faster scrolling with selection. Key Bindings ------------ F1 = Help F2/F9 = Save File/Save File as F3 = Load File F4 = Toggle Buffer F5 = Toggle Window split F6 = Show Console Screen in current buffer F10 = Exit XEdit F11 = Exit XEdit and run program currently in buffer Ctrl-O = Toggle Active Window Ctrl-F = Find Prompt/Selection Alt-F = Reverse-Find Prompt/Selection. Ctrl-N = Find Next Ctrl-R = Replace Prompt/Selection Ctrl-X/Y/P = Cut/Copy/Paste Ctrl-G = Goto Line INS = Toggle Insert/Overwrite mode (Ctrl-W in SERIAL_INPUT_COMPAT_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 (Tab/Ctrl-B in SERIAL_INPUT_COMPAT_MODE) Shift-Navigation Key = Start/Extend Selection (Esc toggles selection mode in SERIAL_INPUT_COMPAT_MODE) Ctrl-Z = Undo F7 = Start Macro Recording F8 = Stop Macro Recording / Playback recorded macro Alt-C = Toggle Syntax Highlighting On/Off (Ctrl-S in SERIAL_INPUT_COMPAT_MODE) Alt-K = Show Key Code at prompt (not supported in SERIAL_INPUT_COMPAT_MODE) Alt-S = Screenshot (not supported in SERIAL_INPUT_COMPAT_MODE) Limitations ----------- - Max. 14000 lines across all buffers (including clipboard and undo buffer). - Max. 2 windows - Max. 2 buffers - Text entered on find prompt can't include double quotes or commas. Find selection can includes double quotes and commas however. - Edit and Clipboard operations are not supported on buffer in show console mode. - No undo for replace operations. - Tested on FW version 5.0505 only. xedit.zip Cheers, Ruben/Epsilon. Epsilon CMM2 projects |
||||
PeteCotton Guru Joined: 13/08/2020 Location: CanadaPosts: 316 |
You could map the XEDIT command to one of the user programmble Function keys if that helps? OPTION F11 command OPTION F12 command |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3846 |
Looking good, more reasons for me to be sorry that it doesn't fit into my setup/workflow. I'm very curious as to how you intend to implement that since AFAIK all you've got (and can have) is a bitmap you grabbed from PAGE 0 when XEDIT started. Surely you aren't proposing to do OCR on that bitmap ? Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
elk1984 Senior Member Joined: 11/07/2020 Location: United KingdomPosts: 227 |
Feel free to take any code that may be useful from here Edited 2020-11-29 05:36 by elk1984 |
||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
Hi Tom, I added the SERIAL_INPUT_COMPAT_MODE to accommodate your workflow. What is missing? Best effort Character Recognition is indeed what I'm proposing. Just for MODE 1,8 and FONT 1,1 (initially?). I would divvy up the PAGE in FONTWIDTH by FONTHEIGHT chunks and match against the FONT 1,1 character set. I'm more curious about how I can speed up horizontal scrolling. I tried copying the window contents one column to the left or right and then rendering the rightmost/leftmost column (with syntax highlighting) but that turns out to be just as slow as full page redraws. I'm going to have to do some profiling to figure out where the bottlenecks are exactly. I don't have a very good sense yet of the cost of MMBasic operations (function/sub calls, string manipulations, CSUB calls) vs. graphics operations such as BLIT. Epsilon CMM2 projects |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3846 |
As I said previously I am generally driving the CMM2 from TeraTerm or PuTTY (principally so that I can scroll the console and have a web-browser open simultaneously - I am aware I could use a screen capture device to deal with the second problem ... wonder if the Pi3 can handle that?) I don't seriously expect XEDIT to ever be my go-to editor, that would need to be terminal based, like a Vi port. That does not mean I don't think it is brilliant and an amazing advance for anyone who is going 100% retro and developing on the CMM2 using a VGA display and USB keyboard. Cool ... might need a CSUB to be fast enough. I can't really help with that, graphics have not been my thing on the CMM2 so far. I *believe* you can setup a graphics buffer that is larger than the actual string, so perhaps it is possible to render the entire width text to such a buffer and then scrolling just consists of blitting the correct window onto that buffer. Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
jirsoft Guru Joined: 18/09/2020 Location: Czech RepublicPosts: 532 |
Is it on PAGE 0 or on some hidden one? I didn't go through XEdit, because I can't use it so much (in my workflow), but I you need I can write CSUB for horizontal scroll. Jiri Napoleon Commander and SimplEd for CMM2 (GitHub), Â CMM2.fun |
||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
As I said previously I am generally driving the CMM2 from TeraTerm or PuTTY (principally so that I can scroll the console and have a web-browser open simultaneously - I am aware I could use a screen capture device to deal with the second problem ... wonder if the Pi3 can handle that?) My bad. I was thinking of elk1984's setup which does have VGA capture. I don't seriously expect XEDIT to ever be my go-to editor, that would need to be terminal based, like a Vi port. That does not mean I don't think it is brilliant and an amazing advance for anyone who is going 100% retro and developing on the CMM2 using a VGA display and USB keyboard. Understood. I don't have any plans to add a terminal mode for XEdit. I can't really help with that, graphics have not been my thing on the CMM2 so far. I *believe* you can setup a graphics buffer that is larger than the actual string, so perhaps it is possible to render the entire width text to such a buffer and then scrolling just consists of blitting the correct window onto that buffer. Yes, FRAMEBUFFER probably exists exactly to solve this type of problem. Unfortunately, I'm running out of memory and FRAMEBUFFERs are allocated on the heap. Epsilon CMM2 projects |
||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
Is it on PAGE 0 or on some hidden one? I didn't go through XEdit, because I can't use it so much (in my workflow), but I you need I can write CSUB for horizontal scroll. Hi Jiri, Thanks for the offer. I'm already using CSUBs actually, for syntax highlighting. One issue with using CSUB to improve horizontal scrolling speed is that the TEXT command is not available in ARMCFunctions.h. Epsilon CMM2 projects |
||||
jirsoft Guru Joined: 18/09/2020 Location: Czech RepublicPosts: 532 |
Thanks for the offer. I'm already using CSUBs actually, for syntax highlighting. One issue with using CSUB to improve horizontal scrolling speed is that the TEXT command is not available in ARMCFunctions.h. I thought you will need just scrolling (what row and direction), missing character could be filed in in the MMBasic or? But if you are using BLIT for scrolling, is it not fast enough? BLIT should be pretty well optimised by Peter... Jiri Napoleon Commander and SimplEd for CMM2 (GitHub), Â CMM2.fun |
||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
I have vertical scrolling implemented like that and it's working great. The difference is that with vertical scrolling I just need one additional SUB call to fill in the missing line. With horizontal scrolling, the scrolling portion is just as easy of course (one fast blit) but filling in the missing characters requires one SUB call per row to figure out the right character and the right color for that character and that's expensive. Epsilon CMM2 projects |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1082 |
Could you store the full width (255 characters) as bytes, not pixels? (Assuming mode 1,8 (800x600x1) and font 1 (8x12) for the following) Storing 255 x 50 characters as pixels needs 255 * 8 * 50 * 12 = heck-of-a-lot bytes. Storing them as characters uses considerably less, 12750 bytes. When you scroll vertically, you either shift all the rows and add a new one, or better, maintain a pointer and use the buffer in a circle. The buffer doesn't change for horizontal scrolling. You just show the appropriate horizontal window. The big trouble? Colour coding. That could easily double the memory requirements: 2 bytes per character, 1 for the ASC code, 4 bits for foreground colour, 4 bits for background colour. Visit Vegipete's *Mite Library for cool programs. |
||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
Hi Pete, That's a good idea. I might try that. The additional memory requirements are peanuts compared to a framebuffer. Thanks! Coming back to Jiri's proposal to use a CSUB, I realized I can get around not having a TEXT function in CSUBs by having a page handy with all printable characters already drawn. I can then blit characters individually from that page. Blit is available in CSUBs. So that's another option I can try. Epsilon CMM2 projects |
||||
jirsoft Guru Joined: 18/09/2020 Location: Czech RepublicPosts: 532 |
The problem with BLIT the character from another page is complicated because of foreground color. You can do it (prepare complete font in one page=once, then prepare another page full of forecolor=everytime, do PAGE_AND_PIXELS=you will have font in forecolor, BLIT it back to PAGE 0), but it's pretty complicated... So I already used CSUB for one character (drawChar screen address, charset address, ASCII code, row, column, forecolor, backcolor), it has some advantages: 1. fast and simple 2. I can use also characters with ASCII 0-31 3. I can change font on the fly! With help of screenaddress I can fine tune vertical position (for example in MODE 1 and charset 8x16 you have 37.5 rows x 100 columns, so I need to choose first row position) and I'm limited with fixed column for character. Edited 2020-12-01 20:00 by jirsoft Jiri Napoleon Commander and SimplEd for CMM2 (GitHub), Â CMM2.fun |
||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
I was thinking of pre-rendering all characters in all the colors I need for syntax higlighting, so I catch two birds with one stone. So I already used CSUB for one character (drawChar screen address, charset address, ASCII code, row, column, forecolor, backcolor), it has some advantages: 1. fast and simple 2. I can use also characters with ASCII 0-31 3. I can change font on the fly! With help of screenaddress I can fine tune vertical position (for example in MODE 1 and charset 8x16 you have 37.5 rows x 100 columns, so I need to choose first row position) and I'm limited with fixed column for character. I don't see a drawChar function in ARMCFunctions.h. Do you mean that you created such a CSUB? It sounds perfect for what I need. Do you have the source code available somewhere? Epsilon CMM2 projects |
||||
jirsoft Guru Joined: 18/09/2020 Location: Czech RepublicPosts: 532 |
Here is my code I'm using in MM64 for C64 output, but it has (because of C64) some limitations and you need to modify it a little: void drawChar(long long int *chargen, long long int *screen, long long int *what) //chargen, screen, what //what = position (0-999) << 16, frontcolor(0-255)<<8, charcode (0-255) { char frontColor = (*what >> 8) & 255; char backColor = 17; char charCode = *what & 255; int position = (*what >> 16) & 1023; int row = position / 40, col = position % 40; char *dest = *screen + row * 800 * 16 + col * 16; char *source = *chargen + charCode * 8; char chrow, hlp; for (int r = 0; r < 8; r++) { chrow = *source; hlp = 128; for (int c = 0; c < 8; c++) { if((chrow & hlp) > 0) { *dest++ = frontColor; *dest++ = frontColor; } else { *dest++ = backColor; *dest++ = backColor; } hlp = hlp / 2; } dest += (800-16); chrow = *source++; hlp = 128; for (int c = 0; c < 8; c++) { if((chrow & hlp) > 0) { *dest++ = frontColor; *dest++ = frontColor; } else { *dest++ = backColor; *dest++ = backColor; } hlp = hlp / 2; } dest += (800-16); } } First, now is prepared for MODE1, 8 and chars size 8x8, it is doubling it to 16x16. So if you need to use for (for example) 8(w)x16(h) chars, you need just (I hope ): void drawChar(long long int *chargen, long long int *screen, long long int *what) //chargen, screen, what //what = position (0-100*37) << 16, frontcolor(0-255)<<8, charcode (0-255) { char frontColor = (*what >> 8) & 255; char backColor = 17; char charCode = *what & 255; int position = (*what >> 16); int row = position / 100, col = position % 100; char *dest = *screen + row * 800 * 16 + col * 16; char *source = *chargen + charCode * 8; char chrow, hlp; chrow = *source++; hlp = 128; for (int c = 0; c < 16; c++) { if((chrow & hlp) > 0) *dest++ = frontColor; else *dest++ = backColor; hlp = hlp / 2; } dest += (800-8); } } I forgot I'm calling it just with 3 parameters, in third is position on the screen (but later is calculated row and column), character and front color, back color is set to 17, just change it. I hope you will understand it... Jiri Napoleon Commander and SimplEd for CMM2 (GitHub), Â CMM2.fun |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8584 |
By the looks of it this code only works in one video mode. The CMM2 firmware tries to work correctly fro every variant. If you build in mode specific CSUBS then you disenfranchise many potential users Edited 2020-12-02 08:44 by matherp |
||||
jirsoft Guru Joined: 18/09/2020 Location: Czech RepublicPosts: 532 |
By the looks of it this code only works in one video mode. The CMM2 firmware tries to work correctly fro every variant. If you build in mode specific CSUBS then you disenfranchise many potential users Peter is absolutely right. I did it for very specific reason, maybe you should really stay with system tools... Jiri Napoleon Commander and SimplEd for CMM2 (GitHub), Â CMM2.fun |
||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
Your sample code is very instructive nonetheless. Much appreciated Jiri! Epsilon CMM2 projects |
||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
Hi all, XEdit V0.5 is now on GitHub (also attached): https://github.com/epsilon537/xedit_cmm2 See changelog below for details. It includes improved horizontal scrolling. Jiri and vegipete's input (thanks guys!) gave me enough incentive to actually go after it. It turned out to be fairly straightforward. Initially I was trying to make the row oriented rendering faster and more flexible so it could handle single character rows, and that just didn't work (well, it did, but it was slow). All I had to do was create a column oriented rendering routine. Calling TEXT "LTV" once for the entire column of text, instead of for each row made all the difference. In hindsight everything is obvious. There's always more to do, but I'm pretty happy with where XEdit is right now, so I'm going to move it to the back-burner for a while. I'm itching to start other projects. I'm still on the hook for bug fixes of course. Cheers, Ruben/Epsilon. ChangeLog --------- 0.5: - Improved horizontal scrolling speed. - More sensible buffer position when toggling window split (F5). - Faster vertical scrolling with active selection (shift-crsrUp/Down). - Ctrl-K deletes from cursor to End Of Line. - Fixed some laggy selection highlighting cases. - Added User Configurable variable NUM_BACKUP_FILES specifying how many backup copies to maintain when saving a file. Defaults to 1. - Added editor resource utilization pop-up, bound to Alt-R. - Add Select-All key binding Ctrl-A. - Avoiding unnecessary horizontal scrolling when moving cursor up or down. - Reorganized help page. - Fixed corner case where "Paste done." message doesn't appear after completing a past action. - Fixed corner case: when undo buffer was full and needed to be cleared (emergency measure), the undo buffer lines weren't returned to the line pool, creating a memory leak. ... To Dos ------ - Add support for vegipete's FileDialog. - Add scroll current line to center/top/end key bindings. - Add case sensitive search/replace keybindings. - Smart, escapable line input, allowing entering commas and double quotes on prompt. - Support copy-to-clipboard from console screen. 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 F6 = Show Console Screen in current buffer F10 = Exit XEdit F11 = Exit XEdit and run program currently in buffer Ctrl-O = Toggle Active Window Ctrl/Alt-F = Forward/Reverse Find Prompt or Selection Ctrl/Alt-N = Find Next/Previous Ctrl-R = Replace Prompt or Selection Ctrl-X/Y/V = Cut/Copy/Paste Ctrl-K = Delete from cursor to End Of Line Ctrl-G = Goto Line INS = Toggle Insert/Overwrite mode (Ctrl-W in SERIAL_INPUT_COMPAT_MODE) Home 1/2/3x = Go To Start of Line/Page/Buffer End 1/2/3x = Go To End of Line/Page/Buffer Tab/Shift-Tab = Indent/Unindent Line/Selection (Tab/Ctrl-B in SERIAL_INPUT_COMPAT_MODE) Shift-Navigation Key = Start/Extend Selection (Esc toggles selection mode in SERIAL_INPUT_COMPAT_MODE) Ctrl-A = Select All Ctrl-Z = Undo F7 = Start Macro Recording F8 = Stop Macro Recording / Playback recorded macro Alt-C = Toggle Syntax Highlighting On/Off (Ctrl-S in SERIAL_INPUT_COMPAT_MODE) Alt-K = Show Key Code at prompt Alt-R = Show XEdit Resource Utilization Alt-S = Screenshot Navigation Keys: Cursor Up/Down/Left/Right, PgUp/Down, Home/End. 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 FG/KEYWORD/STRING/COMMENT/BG_COLOR% DISABLE_CONFIRMATION_PROMPTS%=0/1 Default=0 NUM_BACKUP_FILES%=<Num.> Default=1 SERIAL_INPUT_COMPAT_MODE%=0/1 Default=0 (Alt-based key bindings N/A in SERIAL_INPUT_COMPAT_MODE) Limitations ----------- - Max. 14000 lines across all buffers (including clipboard and undo buffer). - Max. 2 windows - Max. 2 buffers - Text entered on find prompt can't include double quotes or commas. Find selection can includes double quotes and commas however. - Edit and Clipboard operations are not supported on buffer in show console mode. - No undo for search-and-replace operations. - Tested on FW version 5.0505 only. xedit.zip Epsilon CMM2 projects |
||||
Page 3 of 4 |
Print this page |