Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yedit: EOL treatment + Mouse click bug #61

Closed
Gavin-Holt opened this issue Oct 17, 2020 · 3 comments
Closed

Yedit: EOL treatment + Mouse click bug #61

Gavin-Holt opened this issue Oct 17, 2020 · 3 comments

Comments

@Gavin-Holt
Copy link

Gavin-Holt commented Oct 17, 2020

Hi,

Many thanks for making the effort, especially as you appear to be a vim user!
As a non-compiling amateur the self contained windows binary is very welcome
(I note it's not in the nightly CAB build).

Feels great, very clean interface and only 78ms to startup!!
Not having to think about how to use the editor,
really concentrates the mind regarding adding features.

It was a long time ago that edit.com was my workhorse and
I can't run the original so it's difficult to remember specific behaviors.

As a 100% DOS/Windows user I do have deeply ingrained muscle memory
for cursor movements, cut copy paste undo, find replace goto, new open save(as) reload quit.

Perhaps yedit could mimicking edit.com as described on the web:

What is the "most valued feature" missing?

  • Delete at (or beyond) EOL joins lines. I Can't remove line one if cursor is on line one!
  • Left at col 1 moves to end of line above
  • Right at EOL moves to col 1 line below
  • Cursor not to stray beyond EOL
  • Cut/del line to include EOL
  • Cursor back to home after cut/del line
  • Ctrl/Ctrl+Shift with left/right arrows (move/select word),
  • Select drive in open dialog

What is in the "first tier of desires"

  • Infinite Undo
  • Auto-indenting and smart home
  • Ctrl+Shift home/end (select to BOF/EOF)
  • Ctrl+A Select all
  • Shift+F3 find previous
  • Wrap find at BOF/EOF to start again
  • Ctrl+F6 launch new editor - hopefully with a useful current directory
  • Ctrl+F5 Reload file
  • Ctrl+Shift+F5 Execute file using default association with directory set to the file location
  • Wrapping lines

Bugs?

  • After mouse click to change location - then del or bksp fails. Even if I insert text I can't use del/bksp. I have to left, right, home, or end to restore del/bksp actions (I use Win 10 legacy console)

Enhancements (Autohotkey)

#IfWinActive Administrator: yedit.exe
{
^':: Send ''{Left}
^2:: Send ""{Left}
^9:: Send (){Left}
^0:: Send (){Left}
^[:: Send []{Left}
^]:: Send []{Left}
^b:: Send {Home}
^+b:: SendInput +{Home}
^e:: Send {End}
^+e:: SendInput +{End}
^k:: SendInput +{End}{Del}
+^k:: SendInput +{Home}{BS}
^y:: Send {End}+{Home}{Del}{BS}{Down}{Home}
^+s:: Send !fa
^w:: Send !fx
^h:: Send !sc
^Up:: Send {F3}
^Down:: Send {F3}
WheelUp:: Send {Home}{Up}{Up}
WheelDown:: Send {Home}{Down}{Down}
^RButton:: SendInput {RAW}%ClipBoard% ; Paste
}

@malxau
Copy link
Owner

malxau commented Oct 17, 2020

Thanks for all the great suggestions. There's a lot here and it might take a while to work through it all.

As a non-compiling amateur the self contained windows binary is very welcome
(I note it's not in the nightly CAB build).

Are you referring to yedit.exe? It should be part of yori-typical.cab, both in stable and daily. Are you seeing something different?

* Delete at (or beyond) EOL joins lines. I Can't remove line one if cursor is on line one!

Hmm, odd that I missed that. I have a fix for it ready, will push it soon.

* Left at col 1 moves to end of line above

* Right at EOL moves to col 1 line below

* Cursor not to stray beyond EOL

This behavior is following MS-DOS Edit. I've been following version 1 (which is included with NT 4.) I don't know if version 2 did something different. But I agree this behavior is a little strange, and I'm open to changing it; I just wanted to start with the original and see what people want before deviating too much.

* Cursor back to home after cut/del line

Can I ask what this one refers to? When I select a line with shift+down and hit del, the cursor seems to end in the right location. What are you using to delete the line, and where does the cursor go?

This is one area where I changed behavior from Edit. In Edit, it's not possible to have a selection that spans lines without including the entire line - you can select lines, or select characters within a line, but not both. When deleting a selection that spans lines, it returns the cursor to the beginning of the line because that's the beginning of the selection.

* Ctrl/Ctrl+Shift with left/right arrows (move/select word),

Hmm, I never knew Edit did that...

* Select drive in open dialog

Yedit followed edit by putting drives as part of the directory list. I know that's not what modern UIs do, but it was common for DOS programs.

* Infinite Undo

I've been wanting to implement this too. It's a larger change and may take a while though.

* Auto-indenting and smart home

Realistically, I doubt this will ever happen. Auto indent implies knowledge of the language that the text is written in. That just seems "a bridge too far" - there are lots of good editors that do this kind of thing, but they are necessarily larger and need ongoing maintenance to keep up with the languages they are parsing.

* Ctrl+A Select all

You probably already knew this, but it looks like MS-DOS Edit treats Ctrl+A as move one word left, Ctrl+S as move one char left, Ctrl+D as move one char right, and Ctrl+F as move one word right. I didn't know that before. I wonder what environment they were using it in where arrow keys were not available or supported.

* Ctrl+F6 launch new editor  - hopefully with a useful current directory

Since I've been following Edit 1, there's no multi-document support. I'm not sure if this is worth doing or not - in a modern environment it's easy to launch multiple instances, and the clipboard is shared since it's using the Windows clipboard. The main reason I can see for this is when using SSH and launching multiple instances of things is hard.

* Wrapping lines

You're not the first person to ask for this, although it's a ton of work, and Edit 1 didn't support it. (I had to build support for this in ymore.exe and am horrified about how it turned out but don't know how to do better.)

* After mouse click to change location - then del or bksp fails. Even if I insert text I can't use del/bksp.  I have to left, right, home, or end to restore del/bksp actions (I use Win 10 legacy console)

That's very funny. I have a fix and will push it soon. This was broken by trying to support mouse selection - it has created a selection with zero characters in it. Delete refuses to delete an empty selection, but leaves the selection there anyway, so the only way out is to use keys that clear selections.

@Gavin-Holt
Copy link
Author

Gavin-Holt commented Oct 19, 2020

Hi,

+Alternate installation
Although I couldn't find a list online, I have now found yedit inside:

I appreciate yedit was built as part of yori, but am delighted that it only imports KERNEL32.DLL and
will run as a single file application :-)

+Behaviors
I have revived my old Thinkpad with Windows 98 and found edit.com (version 2.0.026. 11/May/1998 69kb). This is old enough to support full screen DOS and it comes with a HLP file, which is plain text and could be used as a blueprint - EDIT.HLP.txt

You are entirely correct about the default cursor behaviors and I never knew about some of these original keyboard shortcuts:

  • Ctrl+A Move one word left
  • Ctrl+B ? inserts smiley face
  • Ctrl+C Copy selection
  • Ctrl+D as move one char right
  • Ctrl+E move one line up
  • Ctrl+F as move one word right
  • Ctrl+G delete
  • Ctrl+H backspace
  • Ctrl+I insert spaces, indent if multiple lines selected
  • Ctrl+J ? inserts something
  • Ctrl+K ? inserts something
  • Ctrl+L Find
  • Ctrl+M Enter
  • Ctrl+N ? inserts something
  • Ctrl+O ? inserts something
  • Ctrl+P ? inserts something
  • Ctrl+Q Shows some of the possible keys on status line
    A - replace
    C - copy
    D - Goto end of line
    F - find
    R - Goto start of file
    S - Goto start of line
    Y - delete to end
  • Ctrl+R Goto start of file - but at current col!
  • Ctrl+S as move one char left
  • Ctrl+T ? inserts something
  • Ctrl+U ? inserts something
  • Ctrl+V Paste
  • Ctrl+W ? nothing ?
  • Ctrl+X Cut
  • Ctrl+Y Delete the current line - not the current selected lines
  • Ctrl+Z ? nothing ?
  • CTRL+LeftArrow and CTRL+RightArrow keys will select words, and then whole lines,
  • CTRL+Up and CTRL+Down do nothing.

I guess as I am running Autohotkey I could remap some of these, to use the arrow keys - or even "hjkl".

This is your project and the difficult decisions about replicating/modernizing the handling of EOL boundaries is in your hands.
IMHO to make a really useful Windows editor I would suggest copying the cursor behavior of Notepad.exe, with a few additional keyboard shortcuts:

  • CTRL+N/O/S/Q/F - as you have already changed
  • CTRL+Shift+Home: Extend selection to row 1 col 1
  • CTRL+Shift+End: Extend selection to EOF
  • CTRL+Left: Move word left
  • CTRL+Right: Move word right
  • CTRL+Shift+Right: Extend selection one word right
  • CTRL+Shift+Left: Extend selection one word left
  • CTRL+A Select all: BOF to EOF
  • CTRL+H Replace: Dialog
  • CTRL+Y Delete line, (all lines in multiline the selection?)
  • CTRL+Z Undo: Infinite for the whole session this file has been open.
  • CTRL+B Block: Select the whole of any line within the selection - such that cut/paste leaves things unchanged.
    I am a lazy mouse selector, often from the bottom up, and a key to accurately select the whole of the lines is useful.
    This allows for easy Autohotkeys to indent, move block up/down, sort block, prefix/postfix block.
  • F5 Reload: Revert to disc image of the file - or load results after running a script.
  • Shift+F5 Execute: Use the ShellExec call to run the file with its default association, from its location. Saves context switching to run the file.
  • Shift+F3 Find Previous: Search towards BOF.
  • Wrap the find/replace past EOF/BOF.

I was using "{Home}, Shift-{End}, {Del}" to remove a line and the cursor was staying at the old last col on an empty line which looked very odd. If you choose to hold the cursor to the left of the EOL this will then bring the cursor back to col 1.

I have still not found how yedit allows one to change drive; when displaying my root directory there are no other drives listed. This could be a feature of my system.

+Extensions
Auto-indenting and smart home: I am only suggesting that {Enter} will match the indentation of the line above and {Home} will go to the first non-space character - although {Home}{Home} will go to Col 1. I am a spaces for indentation person.

I can imagine wrapping lines is difficult, but it does allow comfortable use of the editor for prose/letters/emails.

Infinite Undo combined with Run is just so good for scripting: "edit, save(CTRL+S), execute(Shift+F5), undo(CTRL+Z)" is a very common cycle.

I can live without multiple documents/splits etc. However, spawning a new instance in the current directory would be useful.

Once again many thanks for bringing back edit to the command line.

Kind Regards Gavin Holt

Edited after reading you commit descriptions

@Gavin-Holt
Copy link
Author

Hi,
I have been reading your commit comments and am getting excited. Greatly looking forward to the new binary release of yedit. Guess we can close this item.

Kind regards Gavin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants