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

Line selection #186

Closed
umnyaga opened this issue Apr 28, 2020 · 41 comments
Closed

Line selection #186

umnyaga opened this issue Apr 28, 2020 · 41 comments
Labels
✅enhancement upstream scintilla Changes depends on upstream Scintilla 🛠workaround Workaround available
Milestone

Comments

@umnyaga
Copy link

umnyaga commented Apr 28, 2020

Is it possible to implement line selection in Notepad2?
Some details. Currently, the editor supports two types on selection, one is regular (sometimes it's called stream or block) selection and column selection. In old days, most of text editors supported 3 modes, line selection mode being third mode. Line selection selects whole lines, and when you copy them and paste, they behave like lines, not splitting line at current position and inserting text at split point.
It may sound odd, but it extremely useful and saves a lot of keystrokes and mouse clicks when editing text.

@zufuliu
Copy link
Owner

zufuliu commented Apr 28, 2020

Is SCI_COPYALLOWLINE what you want?

SCI_COPYALLOWLINE works the same as SCI_COPY except that if the selection is empty then the current line is copied. On Windows, an extra "MSDEVLineSelect" marker is added to the clipboard which is then used in SCI_PASTE to paste the whole line before the current line.

@zufuliu
Copy link
Owner

zufuliu commented Apr 28, 2020

Implemented in 95f1459.

@umnyaga
Copy link
Author

umnyaga commented Apr 29, 2020

That is only one line. But I meant to make multiple line selection, not just single line. Thought I do not know if it's doable or not, I am not familiar with Scintilla.

@zufuliu
Copy link
Owner

zufuliu commented Apr 29, 2020

I tried Visual Studio 2017, it not behaviors with multiple line selection. Is there free available editors/IDEs/tools behaviors with multiple line selection?

@umnyaga
Copy link
Author

umnyaga commented Apr 29, 2020

As I mentioned, in old days almost any decent editor had line selection, along with stream (character) and column selection modes. But as editors evolved or new ones appeared, line selection mode disappeared.
One example of modern one is VIM, which still has line selection. See https://vim.fandom.com/wiki/Cut/copy_and_paste_using_visual_selection. v behaves like regular section in Notepad2, but V is line selection and Ctrl+V is column selection.
Another one is Slickedit (unfortunately it's commercial product), which has all 3 selection modes.
I may guess that Emacs could have too, but I need to check on that.

@zufuliu
Copy link
Owner

zufuliu commented Apr 29, 2020

It seems line selection is already in Notepad2:
Ctrl + Shift + Space to select current line.
Press and Hold Alt to do column/rectangle selection.

What is missing are arrow keys during selecting.

@umnyaga
Copy link
Author

umnyaga commented Apr 30, 2020

Not exactly even with one line. If you do Ctrl + Shift + Space to select current line and copy it into clipboard. Then go to other line filled with text, put the cursor in the middle it and paste. What you will get is splitted line at the point of cursor with inserted text at split point. That's just standard selection.

@zufuliu
Copy link
Owner

zufuliu commented Apr 30, 2020

I think Cut (Ctrl+X), Cut Line (Ctrl+Shift+X) and Copy Line (Ctrl+Shift+C) (under Edit -> Lines) can be changed to add MSDEVLineSelect tag like Copy (Ctrl+C).

manually select lines from line number margin will not add MSDEVLineSelect tag (Visual Studio not add this tag).

Make selecting line with Ctrl + Shift + Space, then copy like Vim (Shift+V then y) maybe harder to implement, as it need to distinguish from selecting line from line number margin.

@umnyaga
Copy link
Author

umnyaga commented Apr 30, 2020

zufuliu, that's interesting idea, I like it. What about using keyboard shortcuts, like it's done In Slickedit.
Ctrl+L (or Alt+L), do not remember exactly, starts line selection, selecting current line, and as cursor moves up/down consecutive lines are added to the selection. Once selection is finished it can be copied/cut with MSDEVLineSelect tag.

@zufuliu
Copy link
Owner

zufuliu commented Apr 30, 2020

I think am on the wrong direction. Scintilla actually has a line selection mode SC_SEL_LINES
https://www.scintilla.org/ScintillaDoc.html#SCI_SETSELECTIONMODE

Add a shortcut or menu to toggle line selection mode will make most thing works.

@zufuliu
Copy link
Owner

zufuliu commented Apr 30, 2020

I think line selection works very better for now:

  • Copy Ctrl + C. when no text selected, copy current line with MSDEVLineSelect set.
  • Cut Ctrl + X. when no text selected, cut current line with MSDEVLineSelect set.
  • Cut Line Ctrl + Shift + X. cut current line with MSDEVLineSelect set.
  • Copy Line Ctrl + Shift + C. copy current line with MSDEVLineSelect set.
  • Ctrl + Shift + Space. change current selection to line selection mode, MSDEVLineSelect is set after copy or cut. bug for only single line is fixed.
  • add a menu/option to disable default line selection mode.

@zufuliu
Copy link
Owner

zufuliu commented May 9, 2020

@umnyaga any feedback on current behavior ?

@umnyaga
Copy link
Author

umnyaga commented May 9, 2020

@zufuliu not yet. I do not build Notepad2 myself, waiting for next release to check it out.

@umnyaga
Copy link
Author

umnyaga commented May 11, 2020

@zufuliu I tried the build you mentioned. Yes, it works as I wanted, that is great. First free modern editor which supports line selection!
Couple notes though.
Ctrl+Ins does not work, but it should exactly like Ctrl+c.
Shift+Del and Ctrl+X work but there is strange thing. Once you press one of the shortkey, it removes current line and put it into clipboard, but after that Left and Right arrows do nothing, the cursor does not move. Besides it would be good to stay on current column After Ctrl+X or Shift+Del instead of jumping to the beginning of the line.

@umnyaga
Copy link
Author

umnyaga commented May 11, 2020

Oh, one more thing. Ctrl+Shift+Space starts line selection, then select several lines and press Del. It should remove all selected lines. But what happens, the editor puts one empty line in the place of selection. It should not.

zufuliu added a commit that referenced this issue May 12, 2020
Fix wrong anchor/caret position after change to line selection.
@zufuliu
Copy link
Owner

zufuliu commented May 12, 2020

@umnyaga Thank you for the tests. These bugs are fixed by e342a8c, fa1c29f and d68be45.
Feel free to test latest build at https://ci.appveyor.com/project/zufuliu/notepad2/builds/32818579

@oicu
Copy link

oicu commented May 18, 2020

也有使用半个空格的

半个空格比现在的一个空格较合理,不会误判为多了个空格,也能知道空行也是选择状态。

@zufuliu zufuliu added the upstream scintilla Changes depends on upstream Scintilla label May 18, 2020
@zufuliu
Copy link
Owner

zufuliu commented May 18, 2020

Ticket for the "extra space" after selected lines is created at https://sourceforge.net/p/scintilla/feature-requests/1356/

@zufuliu zufuliu modified the milestones: v4.20.05, v4.20.06 May 19, 2020
@oicu
Copy link

oicu commented May 21, 2020

Ticket for the "extra space" after selected lines is created at https://sourceforge.net/p/scintilla/feature-requests/1356/

thx,我根据你之前提供的方法,只保留 1/4 个空白就好看了。

rcSegment.left -= vsDraw.aveCharWidth * 3/4 ; // remove "extra space"

@zufuliu
Copy link
Owner

zufuliu commented May 21, 2020

临时这样吧,等Scintilla修改后会用size表示额外的空白宽度。

@zufuliu zufuliu removed this from the v4.20.06 milestone Jun 12, 2020
@zufuliu zufuliu added this to the v4.20.07 milestone Jun 23, 2020
zufuliu added a commit that referenced this issue Jun 24, 2020
@zufuliu zufuliu added the 🛠workaround Workaround available label Jun 24, 2020
@zufuliu
Copy link
Owner

zufuliu commented Jun 24, 2020

Added workaround in 421e910. you can use size (in [0 - 100], default is 100, i.e. 100% character width) to set the extra fill width. This may be changed based on what will be implemented in Scintilla.

@zufuliu
Copy link
Owner

zufuliu commented Jul 16, 2020

Close this for now.
issue 1: line selection mode is available since v4.20.05r3026.
issue 2: eol-selected width can be set by size property, it's unknown when it will be implemented in Scintilla (maybe 5.0 or later).

@zufuliu zufuliu closed this as completed Jul 16, 2020
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
Fix wrong anchor/caret position after change to line selection.
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
…udio's "Expand Selection to Containing Block", issue zufuliu#186.
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
RaiKoHoff pushed a commit to RaiKoHoff/notepad2 that referenced this issue Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅enhancement upstream scintilla Changes depends on upstream Scintilla 🛠workaround Workaround available
Projects
None yet
Development

No branches or pull requests

3 participants