Page 1 of 1

IDE - Delete line under cursor

Posted: Thu Feb 11, 2016 4:47 pm
by Marc56us
Hi Fred,

A (long time) feature request in IDE: Edition / Delete Line (under cursor)
Yes, there are many patches, but these are patches :|
Remove entire line where cursor is, is very useful for fast code maintenance :!:

:idea: Do not set any shortcut: Let the user set the shortcut he wants to please everybody :wink:

Re: IDE - Delete line under cursor

Posted: Thu Feb 11, 2016 4:57 pm
by RSBasic
Alternative:
1. Press End key
2. Press Ctrl + Shift + Back key

Re: IDE - Delete line under cursor

Posted: Thu Feb 11, 2016 5:07 pm
by Marc56us
RSBasic wrote:Alternative:
1. Press End key
2. Press Ctrl + Shift + Back key
Yes, thanks, :wink: I knew I had read it on the forum.
But:
- Two sequences, and three fingers.
- Requires looking at the keyboard
- Not fast
- Not easy on a laptop
- Even slower than clicking on the line number and press 'del'

Delete entire line exist on scintilla and on any Editor and IDE

Re: IDE - Delete line under cursor

Posted: Thu Feb 11, 2016 5:14 pm
by skywalk
Search for "tool code" and add this...

Code: Select all

  Protected.i np = CountProgramParameters()
  If np
    Protected.i hSci = Val(GetEnvironmentVariable("PB_TOOL_Scintilla"))
    If hSci
      Select UCase(ProgramParameter())  ; 0-based index
      Case "UCASE"      ; Arguments: UCASE, Shortcut = [Ctrl+u]
        SendMessageTimeout_(hSci,#SCI_UPPERCASE,0,0,#SMTO_ABORTIFHUNG,#SCI_TMO_MS,@np)
      Case "LCASE"      ; Arguments: LCASE, Shortcut = [Ctrl+Shift+u], opposite of UCase line = [Ctrl+u]
        SendMessageTimeout_(hSci,#SCI_LOWERCASE,0,0,#SMTO_ABORTIFHUNG,#SCI_TMO_MS,@np)
      Case "LINEDEL"    ; Arguments: LINEDEL, Shortcut = [Ctrl+Shift+d], opposite of duplicate line = [Ctrl+d]
        SendMessageTimeout_(hSci,#SCI_LINEDELETE,0,0,#SMTO_ABORTIFHUNG,#SCI_TMO_MS,@np)
      Case "MVLINESUP"  ; Arguments: MVLINESUP, Shortcut = [Ctrl+Shift+Up]
        SendMessageTimeout_(hSci,#SCI_MOVESELECTEDLINESUP,0,0,#SMTO_ABORTIFHUNG,#SCI_TMO_MS,@np)
      Case "MVLINESDN"  ; Arguments: MVLINESDN, Shortcut = [Ctrl+Shift+Down]
        SendMessageTimeout_(hSci,#SCI_MOVESELECTEDLINESDOWN,0,0,#SMTO_ABORTIFHUNG,#SCI_TMO_MS,@np)
      EndSelect
    EndIf
  EndIf

IDE - Delete line under cursor

Posted: Thu Feb 11, 2016 7:35 pm
by ssb
Workarounds workarounds...
Why cannot have Scintilla's default key bindings?
Come on Fred do us a favor and implement this. For God's shake, it is a standard shortcut found on almost every editing application! :(

Re: IDE - Delete line under cursor

Posted: Thu Feb 11, 2016 8:21 pm
by Danilo
ssb wrote:Why cannot have Scintilla's default key bindings?
Works here on Mac, see: http://www.scintilla.org/SciTEDoc.html for default key bindings.

Code: Select all

Line delete.	Ctrl+Shift+L
On Mac OS X it is CMD+SHIFT+L, and it works.

Re: IDE - Delete line under cursor

Posted: Fri Feb 19, 2016 7:35 pm
by ssb
On Windows it never worked though

Re: IDE - Delete line under cursor

Posted: Fri Feb 19, 2016 10:02 pm
by heartbone
skywalk wrote:Search for "tool code" and add this...

Code: Select all

  Protected.i np {snip}  EndIf
I searched several places and came up empty.

Re: IDE - Delete line under cursor

Posted: Fri Feb 19, 2016 10:44 pm
by skywalk
Try here as a start.
My tool code is very customized for me and all within 1 exe. If the above link is not helpful I can make a generic 1 later.

Re: IDE - Delete line under cursor

Posted: Mon Feb 10, 2020 3:17 pm
by kenmo
Delete Line shortcut has been merged in Pull Request #54, should be available in PB 5.72 :)
https://github.com/fantaisie-software/purebasic/pull/54

Re: IDE - Delete line under cursor

Posted: Mon Feb 10, 2020 3:35 pm
by Marc56us
Thanks,

But I "see Delete selected lines"
Does it mean we need to select line(s) before or is it valable for line where cursor is ?
(even with no selection area)

By "Delete line under cursor" I mean like CTRL + D who dupplicate the line where cursor is, even if line is not selected (reverse video)

PS. CTRL + Y is a common shortcut for this and not used in PB IDE: good default shortcut

Re: IDE - Delete line under cursor

Posted: Mon Feb 10, 2020 3:56 pm
by skywalk
Please NO.
[Ctrl+Y] = standard action for Redo. The opposite of [Ctrl+Z] = Undo.

Re: IDE - Delete line under cursor

Posted: Mon Feb 10, 2020 4:03 pm
by kenmo
Yes, I think it behaves how you want:
- No selection: the line containing the cursor is deleted
- Selection within one line: the whole line is deleted
- Selection spanning multiple lines: all lines touching the selection are deleted

I tried to follow Scintilla's naming conventions. For example SCI_MOVESELECTEDLINESUP moves the selected lines OR else just the line containing the cursor.


I am looking at the IDE source right now: Ctrl+Y is default mapped to Redo on Windows/Linux.