Cursor mark to enable jump-back-to.

Ideas for new features

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply

Would you like to able to temporarily mark exact cursor position?

Yes
2
50%
Not bothered
2
50%
 
Total votes: 4

User avatar
Cloink
Posts: 81
Joined: Thu Sep 09, 2004 1:44 pm

Cursor mark to enable jump-back-to.

Post by Cloink »

I commonly write a bit of code, say a function call, then decide to assign the result to a variable (instead of in-situ) as it will be used a number of times.

So I cut the code-snippet to clipboard - here I want to MARK THIS POSITION - go up a line, myvar = <paste-code-snippet>; - now copy the varname - now I want to JUMP TO MARKED POSITION and put in the new variable.

There are many other occasions I want to be able to jump back to a cursor position I was at just a moment ago before a digression to create/copy something I will then fill in back at that last cursor position. So, say, CTRL-H says 'Mark HERE', then CTRL-J later says 'Jump back there'.

I can't be the only one that does this...!

Note that ctrl-F2, mark overall line, does not achieve what I need, I need to know exact position along line too.
HerNameWasTextPad
Posts: 59
Joined: Fri Apr 18, 2008 3:25 am

Post by HerNameWasTextPad »

Unless I've misunderstood what you've said . . . I've got some good news for you.

TextPad (at least 4.7.3) already has this ability:

- Make your selection or cut or whatever
- Position the cursor at the beginning of the line to which you want to RETURN
- USING THE SCROLL BAR, scroll so that the line to which you want to GO is in plain view
- Search -> Go To... -> Line -> [Type the line number to which you want to GO, i.e., the one to which you've scrolled, which is now in plain view] -> Go To
- Do the rest of your business at the place to which you've GONE
- Search -> Go To... -> Go To
- You're now back at the place from which you departed
I came in on 4.5 in 2001, moved to 4.7.2 in 2004, moved to 4.7.3 in 2007, moved to 5.4 in 2010, and am excited about 2013. I've said it many times before, and I'll say it many times again: "I love this program."
User avatar
Cloink
Posts: 81
Joined: Thu Sep 09, 2004 1:44 pm

Mark HERE / Do stuff / JUMP back there

Post by Cloink »

Sorry, I think you've misunderstood. I think I could achieve what you're saying simply by CTRL-F2 (mark line - not exact cursor position), then F2 to return to the start of that line, which doesn't achieve my aim.

Your step2 immediately loses the position along the line from whence the cursor came, and other steps mean it would be impossible to put it all into a macro to assign to a single shortcut key, since it would require my input.

As I said before:-
> CTRL-H .. [mark HERE]
> Do stuff
> CTRL-J ... [JUMP back there]

Next CTRL-H sets a new HERE for CTRL-J to JUMP back to. (Exact shortcut-keys obviously not important as I could reassign.)

Any other ideas how I may be able to achieve this welcome!
HerNameWasTextPad
Posts: 59
Joined: Fri Apr 18, 2008 3:25 am

Post by HerNameWasTextPad »

At some eventual point, it dawned on me that you do in fact want to mark somehow the EXACT cursor position.

I presented the use of Search -> Go To... because it can accomplish the return to a line in a way that is INDEPENDENT of whatever bookmarks might already be in place, which can be very useful if, like me, you often already have a bunch of bookmarks in place that would prevent an otherwise quick return to a chosen line.

Back to the task, however, of remembering the EXACT cursor position:

If I had the same need as you, what method would I employ to get the job done?

- First, I would have in place all of the tool buttons and keyboard shortcuts, in addition to the all-important status bar, that I would need in order to facilitate the following actions
- I would position the cursor at the EXACT location that I need to remember and read the status bar to determine the coordinates
- I would click the New Document tool button and type the coordinates (and most likely Save As... the file); for example, I would type 73, 279, and then "Next Document" my way back to the "work" file
- I would do whatever subwork I needed to do in the work file
- I would "Previous Document" my way back to the "coordinates" file to fetch the coordinates
- I would "Next Document" my way back to the "work" file and position the cursor at the EXACT coordinates

While this algorithm sounds long-winded and click-heavy, once you get into the swing of it, you will realize that it is the best way of getting the job done. Actually, there are only 4 single clicks per code-snippet, if you use tool buttons. If you assign, say, "Alt+," to "Next Document," and "Alt+." to "Previous Document," then holding the Alt key continuously for an Alt+. and Alt+, pair would be almost like a single Ctrl+J.

As a bonus, you end up with a log file of all of the spots in the work file that you worked on.

Ya gotta love this program.
I came in on 4.5 in 2001, moved to 4.7.2 in 2004, moved to 4.7.3 in 2007, moved to 5.4 in 2010, and am excited about 2013. I've said it many times before, and I'll say it many times again: "I love this program."
User avatar
Cloink
Posts: 81
Joined: Thu Sep 09, 2004 1:44 pm

Post by Cloink »

Ha! I'm so clever!

Not really, just had the nouse to read TextPad's help for Tool parameter macros, and they do have the common sense to include $Line & $Col. So it's a simple matter of two tools - one to store the cursor position in an external dat file, the other to read that in, and make a call back to TP passing the file/line/col on the command line.

If you didn't know, you can call TextPad with a filename and, in brackets after the filename, the line/col you want the cursor positioned at in the file. Doesn't matter if the file's already open, it just positions the cursor - e.g.

Code: Select all

TextPad.exe "file blah.txt"(10,20)
So for anyone that's interested...

TP_MarkHere.bat:

Code: Select all

echo %TextPad_exe% "%1"(%2,%3)>C:\tp.dat
which stores the command I am going to execute in the subsequent tool in a Dat file; it is called from the Tool by passing file/line/col:

Code: Select all

...\TP_MarkHere.bat $FileName $Line $Col
And then...
TP_JumpToMark.bat:

Code: Select all

type C:\tp.dat>C:\tp.bat
C:\tp.bat
which copies the command to an executable Bat file and runs it. Now to assign these tools to ctrl-h and ctrl-j. Sorted.

Well, time will tell. Not ideal as there is a significant delay while the tool runs, but as HNWTP pointed out, there's not much you can't do with TextPad.
HerNameWasTextPad
Posts: 59
Joined: Fri Apr 18, 2008 3:25 am

Post by HerNameWasTextPad »

Go ahead: Ask me if I'm surprised.

Some things just don't get old. TextPad is one of them. The whole time Helios was probably thinking, "Why should we update TextPad? It can already do just about everything a text editor should do. Don't the users read the help screens and forum postings?"

By the way, I just read

Help -> Help Topics -> Index -> parameters -> Display -> "Command Line Parameters" -> "Notes"

and

Help -> Help Topics -> Index -> macros -> Display -> Tool Parameter Macros -> Display -> "Tool Parameter Macros."

The more users who use TextPad, the better--for all of us--so I always like to present algorithms that ALL users can use, regardless of whether users are able to code.
I came in on 4.5 in 2001, moved to 4.7.2 in 2004, moved to 4.7.3 in 2007, moved to 5.4 in 2010, and am excited about 2013. I've said it many times before, and I'll say it many times again: "I love this program."
Post Reply