IDE - Delete line under cursor

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Marc56us
Addict
Addict
Posts: 1108
Joined: Sat Feb 08, 2014 3:26 pm
Location: France

IDE - Delete line under cursor

Post 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:
RSBasic
Moderator
Moderator
Posts: 1122
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: IDE - Delete line under cursor

Post by RSBasic »

Alternative:
1. Press End key
2. Press Ctrl + Shift + Back key
ImageImageImageImage
Marc56us
Addict
Addict
Posts: 1108
Joined: Sat Feb 08, 2014 3:26 pm
Location: France

Re: IDE - Delete line under cursor

Post 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
User avatar
skywalk
Addict
Addict
Posts: 3554
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: IDE - Delete line under cursor

Post 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
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
ssb
User
User
Posts: 44
Joined: Wed Jun 21, 2006 11:09 am

IDE - Delete line under cursor

Post 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! :(
User avatar
Danilo
Addict
Addict
Posts: 3010
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: IDE - Delete line under cursor

Post 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.
ssb
User
User
Posts: 44
Joined: Wed Jun 21, 2006 11:09 am

Re: IDE - Delete line under cursor

Post by ssb »

On Windows it never worked though
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: IDE - Delete line under cursor

Post 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.
Keep it BASIC.
User avatar
skywalk
Addict
Addict
Posts: 3554
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: IDE - Delete line under cursor

Post 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.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
kenmo
Addict
Addict
Posts: 1922
Joined: Tue Dec 23, 2003 3:54 am

Re: IDE - Delete line under cursor

Post 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
Marc56us
Addict
Addict
Posts: 1108
Joined: Sat Feb 08, 2014 3:26 pm
Location: France

Re: IDE - Delete line under cursor

Post 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
(English is not my native language, I use an online translator.)
User avatar
skywalk
Addict
Addict
Posts: 3554
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: IDE - Delete line under cursor

Post by skywalk »

Please NO.
[Ctrl+Y] = standard action for Redo. The opposite of [Ctrl+Z] = Undo.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
kenmo
Addict
Addict
Posts: 1922
Joined: Tue Dec 23, 2003 3:54 am

Re: IDE - Delete line under cursor

Post 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.
Post Reply