Jump to content

Recommended Posts

If you're disciplined, no project is too large or complex for command line + Nano.

I must look into Forth. Have never tried it.

  • Like 1

Share this post


Link to post
Share on other sites

Are you going to have word wrap?

I always liked the VDE word wrap: soft returns were "<space><return>", hard returns were any other character follows by a return. And in word wrap mode, it wrapped as you went, but it didn't bother with any other lines unless you highlighted a set of lines and then it word wrapped that set.

I later found out that according to some the hard and soft returns were the other way around, but if you enter a return you most often enter it right after the character at the end of the line, so the VDE approach always worked more naturally for me.

Share this post


Link to post
Share on other sites

I do not plan to have word wrap, at least not now.

When I use text editors, I never have word wrap enabled. If you're editing source code or config files, word wrap is of limited value. 

This is actually my second attempt at creating a text editor for X16. My first try in 2019 had word wrap. The code became ugly and had a lot of hard to find bugs. I dropped word wrap to make things easier, but I might revisit it in the future.

V. 0.0.3 is quite stable, and I have no known bugs (they are probably there anyway). I think I have a solid base to continue from.

These are the things I'm working on now and in the near future:

  • Memory defragmentation routine
  • Search and replace
  • Cut and paste

Share this post


Link to post
Share on other sites
On 9/7/2020 at 10:49 PM, Stefan said:

I do not plan to have word wrap, at least not now.

When I use text editors, I never have word wrap enabled. If you're editing source code or config files, word wrap is of limited value. 

This is actually my second attempt at creating a text editor for X16. My first try in 2019 had word wrap. The code became ugly and had a lot of hard to find bugs. I dropped word wrap to make things easier, but I might revisit it in the future.

V. 0.0.3 is quite stable, and I have no known bugs (they are probably there anyway). I think I have a solid base to continue from.

These are the things I'm working on now and in the near future:

  • Memory defragmentation routine
  • Search and replace
  • Cut and paste

When (if?) I get xForth fully working, I have a very simple literate programming word set which encourages explanatory block comments that can be pulled out with tags embedded in the comments for automatically generated glossary/help files.

When I was doing my "only visible characters" Forth text editor in the early 2000's, I found that a simplifying design spec for word wrap was to wrap when a character is typed into the last column, so there is no "hidden" white space between the last column and the first column of the next line. And update a "last space" column position with every space, so there's no scanning back, just insert return after the last space in the line, space out the tail, go to the head of the next line and print to screen whatever is after the return.

Then in non-line wrap mode it can just stall at the set right margin.and it's up to the user whether to hit return there are go back an insert a return further back.

Share this post


Link to post
Share on other sites
14 hours ago, BruceMcF said:

When (if?) I get xForth fully working, I have a very simple literate programming word set which encourages explanatory block comments that can be pulled out with tags embedded in the comments for automatically generated glossary/help files.

When I was doing my "only visible characters" Forth text editor in the early 2000's, I found that a simplifying design spec for word wrap was to wrap when a character is typed into the last column, so there is no "hidden" white space between the last column and the first column of the next line. And update a "last space" column position with every space, so there's no scanning back, just insert return after the last space in the line, space out the tail, go to the head of the next line and print to screen whatever is after the return.

Then in non-line wrap mode it can just stall at the set right margin.and it's up to the user whether to hit return there are go back an insert a return further back.

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.

Another thing. In my last post I said I had no know bugs. Naturally I found a couple right after saying that. On my bug severity scale, irritating - serious - deadly, I was closing up on deadly. When you inserted text above text that was already typed in, a few letters every now and then would be duplicated, effectively a memory corruption problem. Usually, you see right away what's causing such a problem. But in this case the corruption seemed random. I used a good 5 hours to isolate when the problem occurred. Finally I found an off by one error in the routine deleting a char from memory. It's a good feeling fixing such a bug ...

 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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!

 

  • Like 1

Share this post


Link to post
Share on other sites

@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?

Edited by Stefan

Share this post


Link to post
Share on other sites
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.

Edited by BruceMcF

Share this post


Link to post
Share on other sites

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!

  • Thanks 1

Share this post


Link to post
Share on other sites

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!

  • Like 1

Share this post


Link to post
Share on other sites
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.

  • Like 1

Share this post


Link to post
Share on other sites

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.

  • Like 1

Share this post


Link to post
Share on other sites

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.

  • Like 2

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

An actual line feed char is inserted when wrapping a long line.

GNU Nano's long line wrapping function (ESC+L) does this too.

I had a discussion with @BruceMcF above in this thread on the design of a word wrap function.

Apparently, his favorite editor from the past, VDE, also did this.

This is my second attempt to create a text editor for X16. My first program had word wrap calculated on the fly without inserting line feed chars. However, this became very complex and error prone, and I finally had to discard that work.

Based on my first experience, I had decided not to do word wrap, but Bruce talked me into it. I think the word wrap function is a nice addition and that it will be sufficiently usable. I'm not making a word processor.

The next version of X16 Edit will have word wrap, and then I will consider the program to be feature complete. Thereafter I will focus on bug fixes and minor improvements to the user interface.

I think version 0.1.1 already works pretty well. If you try it, please let me know what you think.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you for clearing things up. Would be nice to make an option to turn wrap functiom on and off. Idealy by a hotkey during typing.

Share this post


Link to post
Share on other sites

You will be able to turn it on and off (Ctrl+Z).

When turning on, you are prompted to set at what column to wrap.

  • Like 2

Share this post


Link to post
Share on other sites

Version 0.2.0 of X16 Edit now released.

It supports word wrap. Word wrap is turned off by default. Enable by pressing Ctrl+Z.

X16 Edit is now feature complete as I've planned version 1.0.

I will continue cleaning the code, fixing bugs, and improving the user interface.

  • Like 3

Share this post


Link to post
Share on other sites

Hi.

Version 0.2.1 uploaded. Some bug fixes, especially the automatic word wrap function that wasn't working.

I've written a short user manual that is also available on the download page.

And I finally got the "Try it now" button to work. However, there are some differences. For instance not all Ctrl+key commands are recognized when you run the program in the online emulator. I think it's still best to download the program and run it in your emulator locally.

And one more thing I forgot to mention. I've implemented a defragmentation routine that runs in the "background". Actually it's invoked to defrag one memory page each interrupt if there is no user input to handle. The memory model discussed at the beginning of this thread makes it possible to edit large files. The downside is that there is a lot of unused space, especially if you back and forth in the file editing it. The defrag routine takes care of that problem.

Edited by Stefan

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Please review our Terms of Use