Feature sugg: Drag text to a scrollbar position

English main discussion
Post Reply
  • Author
  • Message
Offline
Posts: 84
Joined: Wed Jan 27, 2016 6:53 pm
Location: Europe

Feature sugg: Drag text to a scrollbar position

Post by SaFeTyPe »

Hello,

lets say the user wants to move text to the bottom of a longer text document.

He can either use ctrl-x, then scroll to the appropriate position, then position the cursor, then hit ctrl-v.

Or he can drag the text all the way down with the mouse by drag and drop, waiting a long time.

My idea would be that the user can drag the text to a specific scrollbar position (not releasing the mouse button!), then akelpad would show that area of the document, and then the user could move the mouse pointer to the left again and position the cursor exactly where the text should be dropped/inserted.

Offline
Posts: 84
Joined: Wed Jan 27, 2016 6:53 pm
Location: Europe

Post by SaFeTyPe »

Here's another feature suggestion:

Byte-neutral move-by-keyboard

Currently, moving of text can be done either by drag'n'drop, or cut'n'paste.
Drag'n'drop will ensure that the file has the same byte size throughout the process. Cut'n'paste will cause the file to temporarily be smaller due to the cut operation. It also clutters the clipboard with items that are typically of no use in a clipboard manager.

I would therefore like to suggest a hybrid between drag'n'drop and keyboard-driven cut'n'paste:

1. user selects text
2. user hits a trigger shortcut.
3. the caret (I mean: the blinking line (cursor)) changes its form (for example a square is added similarly to the square that is added to the mouse pointer in drag'n'drop).
4. the user moves the cursor to where he wants the text to be pasted. the text remains in its original place, and selected.
5. the user hits Enter to paste the selection to the new location.
6. the user can abort the process by hitting ESC. (esc has to work in this situation also when the user has disabled ESC as program exit (in hotkeys), of course).
7. There should be separate handling for cut and for copy operation.

These are the advantages:
- clipboard neutrality (see above)
- backup consistency (backups will always feature all data, even if snapshops they were taken during a cut'n'paste operation)
- unlike mouse drag'n'drop, it is much easier to navigate to a dropping location in a remote location of the text file (no need to wait for the text to scroll).

--
EDIT: some more thoughts:
- there should be an option that after pasting, the pasted text remain selected/or not.
- there should be an option for the user to decide whether or not the function will also work across tabs/across separate instances of Akelpad.

Offline
Posts: 84
Joined: Wed Jan 27, 2016 6:53 pm
Location: Europe

Post by SaFeTyPe »

Drag to Pos1: Drag to margin area to facilitate standard drop operation (currently "forbidden")

Here is a similar, arguably more important suggestion for improvement:

I have the left margin to "8" in settings. When I drag text, I usually want to drag it to the very beginning of a line. However the mouse pointer turns into a "forbidden" sign when it is within the white margin area. I is kind of fiddly to hit the narrow area each time I'm dragging a text area. Would it be possible to define the left margin as a drop area? Ironically, the left margin is already a selection area when selecting the text for drag'n'drop. In that situation, the mouse pointer nicely turns into a line selection pointer.

I think I described the problem clearly - please don't hesitate to ask if something is left unclear.

Thanks for considering this suggestion for improvement.

Offline
Posts: 582
Joined: Mon Apr 08, 2013 9:50 pm
Location: Win7SP1x64, APx64

Post by Drugmix »

The idea of using a hotkey so you could drag'n'drop is... silly: if you can hit a hotkey - why'd you drag'n'drop?
If cutting and pasting encumbers some clipboard manager... well that's the problem of that clipboard manager, not the text editor.

I don't know what you mean by 'backup consistency', I'd rather think of consistency of the undo/redo history, but that's not much of a problem to undo/redo twice instead of once. If one would like to improve undo/redo usage I'd rather ask for adding support of forks, so that user could safely undo N steps, then fork the history, type whatever/test whatever and then be able to get back to the state when the undo/redo history got forked and load the old fork, so he could redo the changes that would be lost otherwise.

But you are completely right that the user experience would be better if moving the cursor to the scrollbar while dragging text would scroll the scrollbar to that position, but then, again, it is something that shouldn't be fixed/added only to a single particular program, it needs an OS-wide solution (just like your request about smooth scrolling).

I like writing AHK-scripts that improve user experience and I'll take a look if that's easily doable (I know it's doable, but not sure if it's easily doable), so if you like - I could tell you if I manage to script that.

Offline
Posts: 84
Joined: Wed Jan 27, 2016 6:53 pm
Location: Europe

Post by SaFeTyPe »

I have had bad experiences with AHK scripts (none that I have written, but that I have used). They are often unreliable or otherwise mess with the original program.

By backup consistency I mean this: Let's say you are sorting and rearranging your lecture notes that are in a text file. Then either your hdd crashes, or you want to go back 20 minutes in time because you messed up your text somehow. Or you just want to see what it looked like 20 minutes ago. Let's say the archived backup text from 20 minutes ago is mytext-20.bak . The problem now is that it is likely that this backup file lacks a portion of text: The portion that you was cut on the clipboard and not yet pasted. So if you restore mytext-20.bak, you lose that portion of text. However had you used mouse-drag-n-drop instead of keyboard-cut-n-paste, the problem would not have happened. However mouse-drag-n-drop has the disadvantage that it only works near-range (unless you can drag onto the scrollbar as I suggested - but that does not work either, of course). So to solve the problem I suggested that cut-and-paste operations should only "flag" a selected portion of text as cut, but not actually cut it from the file. Instead the real cut-and-paste operation should be done in one step upon pasting. Similar to the way files are cut and pasted in a file manager.

Forked undo/redo is of course a premium feature. I guess it would require some visualization. I would not dare to request that, but sure, it would be great :-)

Offline
Site Admin
Posts: 6311
Joined: Thu Jul 06, 2006 7:20 am

Post by Instructor »

SaFeTyPe

Code: Select all

var hWndEdit=AkelPad.GetEditWnd();
var oSys=AkelPad.SystemFunction();
var lpPoint;
var nCursorPos;
var nSelStart=AkelPad.GetSelStart();
var nSelEnd=AkelPad.GetSelEnd();
var nSelLen=nSelEnd - nSelStart;

if (nSelLen)
{
  if (lpPoint=AkelPad.MemAlloc(8 /*sizeof(POINT)*/))
  {
    oSys.Call("user32::GetCursorPos", lpPoint);
    oSys.Call("user32::ScreenToClient", hWndEdit, lpPoint);
    nCursorPos=AkelPad.SendMessage(hWndEdit, 215 /*EM_CHARFROMPOS*/, 0, lpPoint);
    if (nCursorPos < nSelStart || nCursorPos > nSelEnd)
    {
      AkelPad.Command(4153 /*IDM_EDIT_CUT*/);
      if (nCursorPos < nSelStart)
        AkelPad.SetSel(nCursorPos, nCursorPos);
      else
        AkelPad.SetSel(nCursorPos - nSelLen, nCursorPos - nSelLen);
      AkelPad.Command(4155 /*IDM_EDIT_PASTE*/, 0x4 /*PASTE_SELECT*/);
    }
    AkelPad.MemFree(lpPoint);
  }
}
Last edited by Instructor on Mon Feb 22, 2016 7:20 am, edited 1 time in total.

Offline
Posts: 84
Joined: Wed Jan 27, 2016 6:53 pm
Location: Europe

Post by SaFeTyPe »

Wow, thank you! This will solve a lot of problems!

But I can't get it to work (because I'm a n00b). Could somebody please post instructions for the average user? I have already put the file into the scripts folder, and I tried to use the Hotkey plugin with it. Sorry for needing help and thank you.

Offline
Site Admin
Posts: 6311
Joined: Thu Jul 06, 2006 7:20 am

Post by Instructor »

SaFeTyPe
1. Yes. Save "MoveTextToCursor.js" in "[AkelPad]\AkelFiles\Plugs\Scripts\" folder.
2. Assign hotkey in Hotkeys plugin to command:

Code: Select all

Call("Scripts::Main", 1, "MoveTextToCursor.js")
3. Select text.
4. Move cursor to new position for text.
5. Press hotkey assigned in second step.

P.S.
With test version text in new position will be selected.

Offline
Posts: 84
Joined: Wed Jan 27, 2016 6:53 pm
Location: Europe

Post by SaFeTyPe »

Thank you!

MoveTextToCursor.js works nicely. It also works when I put the mouse cursor all the way to the very left border of the screen (0px position). That's excellent.

FYI: The test version (AkelPad.exe) says "Update English.dll". It also does NOT keep the text selected after I press my shortcut (ctrl-shift-ß currently) to paste it.

There is another convenience problem now: Let's say I have a 200kb text and I want to move a portion of text from the middle to the top with "MoveTextToCursor.js". I select the text and then go upwards. The problem now is that I cannot use PageUp on my keyboard because it will unselect the text. Is it possible to move the screen up/down with the keyboard just like pageup but without moving the cursor (with separe shortcut of course, not as a substitute for PageUp.).

PS. Also I think the new MoveTextToCursor.js would work nicely in combination with the context menu!!! Just rightlick at the left border where one wants to move the text and then "mo_v_e text here"! :-D I.e. rightclick, M. I will test if this works now. :-)

Offline
Posts: 84
Joined: Wed Jan 27, 2016 6:53 pm
Location: Europe

Post by SaFeTyPe »

I added

Code: Select all

SEPARATOR1
SET(8)
    "&Move Here" Call("Scripts::Main", 1, "MoveTextToCursor.js")
UNSET(8)
to the context menu and it works like a charm! <3 Akelpad <3

By doing "&M", one can easily press the M key because it is near to the touchpad where one did the rightclick just before. :-D

I did not know what to put into the the brackets behind "SET". Is "8" OK? (I did read context menu help file... but did not really understand...)

Offline
Site Admin
Posts: 6311
Joined: Thu Jul 06, 2006 7:20 am

Post by Instructor »

SaFeTyPe wrote:FYI: The test version (AkelPad.exe) says "Update English.dll".
Main menu -> View -> Language -> Internal
It also does NOT keep the text selected after I press my shortcut (ctrl-shift-ß currently) to paste it.
I have corrected the script - update it.
Is it possible to move the screen up/down with the keyboard just like pageup but without moving the cursor (with separe shortcut of course, not as a substitute for PageUp.).
See Scroll-Eng.txt:

Code: Select all

Call("Scroll::Settings", 2, 2)

Code: Select all

Call("Scroll::Settings", 2, 3)
I did not know what to put into the the brackets behind "SET". Is "8" OK? (I did read context menu help file... but did not really understand...)
You don't need to use SET(8). It can be useful only for Command() without text, for example:

Code: Select all

SET(8)
    "" Command(4151)
    "" Command(4152)
UNSET(8)

Offline
Posts: 84
Joined: Wed Jan 27, 2016 6:53 pm
Location: Europe

Post by SaFeTyPe »

Genius. Thank you!

Offline
Posts: 84
Joined: Wed Jan 27, 2016 6:53 pm
Location: Europe

Post by SaFeTyPe »

Instructor

Hello!

I have been using MoveTextToCursor.js in the last days, here are some remarks:

- 1. It works great
- 2. Suggestions for improvement:
2.1 ability to define in the Call command that either the text will remain selected or not (with a switch like 0/1).
2.2 In Undo, the command is treated as two actions (unlike drag and drop). Unless it is difficult to implement, I think it would be better if it were handled as one action (like drag and drop).
2.3 Idea: It would be helpful if there were also a switch that allows to define
- (1) if the text will be pasted exactly where the cursor is, or
- (2) if the text should be pasted to the beginning of the line where the cursor currently is.

example for 2.3: (mouse cursor ist "|")
This is an ex|ample sentence.

In (1), text will be pasted after "ex"
In (2), text will be pasted in front of "This".
Post Reply