Text editor

All aspects of programming on the Commander X16.
BruceMcF
Posts: 1336
Joined: Fri Jul 03, 2020 4:27 am

Text editor

Post by BruceMcF »



On 9/10/2020 at 3:01 AM, Stefan said:




Sounds like a good idea.



If I understand, you mean automatic word wrap that inserts an actual line feed marker in the buffer. That might actually be possible to do.



In my first attempt I had word wrap that was calculated from the top of the paragraph without inserting any line feed markers. That became complicated.



An alternative is to use some other control char to mark automatic word wrap. If I remember correctly, WordStar used such an internal marker. The advantage is that you can strip the word wrap marker when saving to file.



Yes, inserting an actual return character.

The VDE approach (the MS-DOS shareware text editor, which originated as a CP/M editor ... back in the early 90's my AWK IDE was VDE and LIST) was that word wrap returns did not REPLACE the space, they were inserted AFTER the space, so the sequence "<space><return>" could be treated as a soft return, and return after any NON space character was a hard return (on the CX16, this would include SHIFT-SPACE, which is the non-break space $A0).

So you could set a new line length, select a set of lines, and the "rewrap" function would adjust the word wrap to suit for lines ending in soft returns, and leave lines ending in hard returns alone.

So, for instance, if you have a block comment and you decide you want to change it from 80 characters wide to 60 characters wide to make it easier to read, you can, without messing up any hard returned line oriented source code that you are commenting.

However you do insert mode, you can postpone rewrapping until the insert is over, to avoid rewrapping bogging down responsive of the insertion ... and then you only have to rewrap through to the first hard return.

Stefan
Posts: 454
Joined: Thu Aug 20, 2020 8:59 am

Text editor

Post by Stefan »


Hi all.

I have just published version 0.0.4 of my text editor.

New in this version:


  • More bug fixes. Most of memory handler redesigned. The program is now more stable.


  • The program tracks if a document has been changed and asks you to save before any operation that would discard those changes (closing the program, opening a new document, creating a new document).


  • Other general user interface improvements.


  • Function to display memory usage implemented (press ESC and then m). Displayed as number of blocks free, inspired by the 1541. One block is 251 bytes of actual text data.


I also made a short video demonstrating some of the features. Look carefully, and you may spot a mistake in my C programming.

Have a nice weekend!

 


Stefan
Posts: 454
Joined: Thu Aug 20, 2020 8:59 am

Text editor

Post by Stefan »


@BruceMcFI experimented a little with automatic word wrap.

As you said earlier, it's quite easy to monitor the length of a line as each char is typed in, and wrap at the previous word boundary by inserting a line feed marker.

That will be very close to GNU Nano's long line wrapping feature, which you enable by pressing ESC and then L.

It's at bit more complicated if you delete text in the middle of a line. Word processors recalculate the word wrap if this happens, and move words from the beginning of the line below to the end of the currently edited line as soon as each word will fit.

GNU Nano's long line wrapping feature works in a more simple way, and it will not recalculate the word wrap when you delete text.

If I do this, I'm thinking about going the GNU Nano way with word wrap. Would that be alright?

BruceMcF
Posts: 1336
Joined: Fri Jul 03, 2020 4:27 am

Text editor

Post by BruceMcF »



16 hours ago, Stefan said:




@BruceMcFI experimented a little with automatic word wrap.



As you said earlier, it's quite easy to monitor the length of a line as each char is typed in, and wrap at the previous word boundary by inserting a line feed marker.



That will be very close to GNU Nano's long line wrapping feature, which you enable by pressing ESC and then L.



It's at bit more complicated if you delete text in the middle of a line. Word processors recalculate the word wrap if this happens, and move words from the beginning of the line below to the end of the currently edited line as soon as each word will fit.



GNU Nano's long line wrapping feature works in a more simple way, and it will not recalculate the word wrap when you delete text.



If I do this, I'm thinking about going the GNU Nano way with word wrap. Would that be alright?



That is very much how VDE worked ... there was wrapping as you type, and then after deletes/inserts made things ragged, a block select "rewrap" operation. Just waiting until the person doing the editing wants to see how it looks wrapped works fine. The key is inserting the wrap return after the space so rewrap knows which returns are soft returns.

Stefan
Posts: 454
Joined: Thu Aug 20, 2020 8:59 am

Text editor

Post by Stefan »


X16 Edit v 0.1.0 is released, and available in the downloads section.

New features:

- Copy, cut and paste

- Search and replace

- Go to line number

- Auto indent

- Tab key behavior improved

- Memory usage function shows correct value, as returned by Kernal function MEMTOP

- And of coarse, some minor bug fixes

This version suppports almost all features I originally planned for.

Roadmap to version 1.0:

I will try to include a simplified automatic word wrap and support for PETSCII mode.

Apart from that I will focus on cleaning up and making the code more efficient and beatiful, fixing bugs, and making the user interface nicer.

If you try the program, please let me know if you encounter bugs. Please, also let me know if the user interface language could be made clearer or better. English is after all a foreign language to me.

Have a great weekend!

User avatar
desertfish
Posts: 1092
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Text editor

Post by desertfish »


Wow, that looks good! I really should try it out someday, it's shaping up to be a very cool editor.  However I do all my text editing outside of the X16 itself for now... I'll try to remember that this editor exists though for when I want to edit something on the machine itself!

BruceMcF
Posts: 1336
Joined: Fri Jul 03, 2020 4:27 am

Text editor

Post by BruceMcF »



8 hours ago, Stefan said:




X16 Edit v 0.1.0 is released, and available in the downloads section.



New features:



- Copy, cut and paste

- Search and replace

- Go to line number

- Auto indent

- Tab key behavior improved

- Memory usage function shows correct value, as returned by Kernal function MEMTOP

- And of coarse, some minor bug fixes



This version suppports almost all features I originally planned for.



Roadmap to version 1.0:



I will try to include a simplified automatic word wrap and support for PETSCII mode.



Most excellent. I will have a try of the new version sometime this weekend, as it is a holiday weekend (National Week Holiday) in Beijing, but this sounds like most everything I need from a general system text editor for Forth scripts.

Stefan
Posts: 454
Joined: Thu Aug 20, 2020 8:59 am

Text editor

Post by Stefan »


Released version 0.1.1 with support for both PETSCII charset and the ISO charset.

On startup, the program now also detects the current charset and uses that.

Thanks to @SlithyMatt for his tip above in this thread on how to do that.

Stefan
Posts: 454
Joined: Thu Aug 20, 2020 8:59 am

Text editor

Post by Stefan »


I've started working on a simple word wrap function.

It's very rudimentary: If you type a letter at the set right margin, it will wrap at the previous blank space.

It will not wrap or rewrap text in any of these cases:


  • If you insert text at the beginning of the line, even if the length of the line goes beyond the set margin


  • If you delete a line feed marker


Is it good enough?

Enclosed also a short video demonstrating what I'm talking about.


User avatar
Cyber
Posts: 482
Joined: Mon Apr 27, 2020 7:36 am

Text editor

Post by Cyber »


How the wrapped text is saved to file? Does it just insert a "new line" where the wrap happened?

Post Reply