Selction or Current Line Macro

General questions about using TextPad

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

Post Reply
User avatar
Drxenos
Posts: 210
Joined: Mon Jul 07, 2003 8:38 pm

Selction or Current Line Macro

Post by Drxenos »

Is is possible to create a macro that act on the current selection, or the current line if nothing is selected?

I realize I can create one to do one or the other, but I want one to handle both.

TextPad has a command to duplicate the current line, and I can easily make a macro to duplicate the current selection, but I to create one shortcut key to either (depending on if there is a selection or not). VS does this and I really like the feature.

Thanks.
User avatar
AmigoJack
Posts: 482
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Post by AmigoJack »

Macros are recording, not creating. If the feature "select current line if nothing is selected yet" does not exist as an action you could choose from the menu, then you can't record it.

Macros are no scripts either, where you could insert conditions ("if ... then ...").
User avatar
Drxenos
Posts: 210
Joined: Mon Jul 07, 2003 8:38 pm

Post by Drxenos »

AmigoJack wrote:Macros are recording, not creating.
Sigh. Pedantry at it's best. When I RECORD a macro, I am CREATING a macro.
AmigoJack wrote:If the feature "select current line if nothing is selected yet" does not exist as an action you could choose from the menu, then you can't record it.

Macros are no scripts either, where you could insert conditions ("if ... then ...").
That's plainly obvious or I wouldn't have asked. It doesn't mean someone hasn't devised a trick or two. The so-called "if/then" is a high-level construct. There are ways of doing a conditional that don't involve it.
User avatar
Drxenos
Posts: 210
Joined: Mon Jul 07, 2003 8:38 pm

Post by Drxenos »

Ha! I've figured it out. It can be done. It's not ideal, but it works.

Also, I wrote it. I didn't record it.
User avatar
AmigoJack
Posts: 482
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Post by AmigoJack »

Drxenos wrote:Pedantry at it's best.
It's "its" (because "at it is best" makes no sense, while the determiner "its" expresses belonging to "best").
Drxenos wrote:When I RECORD a macro, I am CREATING a macro.
Sure. But you don't create actions that otherwise aren't available - that's what "to record" implies. I was refering to actions, not macros itself.
Drxenos wrote:Ha! I've figured it out.
Too bad you keep it to yourself and tell it nobody, just because you seem to have a problem with me. Moreover you're able to edit posts instead of posting 2 replies in a row.
User avatar
Drxenos
Posts: 210
Joined: Mon Jul 07, 2003 8:38 pm

Post by Drxenos »

Sour grapes are sour.
ak47wong
Posts: 703
Joined: Tue Aug 12, 2003 9:37 am
Location: Sydney, Australia

Post by ak47wong »

Drxenos wrote:I've figured it out. It can be done. It's not ideal, but it works.
Drxenos, I'd be interested to know what solution you came up with.
User avatar
Drxenos
Posts: 210
Joined: Mon Jul 07, 2003 8:38 pm

Post by Drxenos »

ak47wong wrote:
Drxenos wrote:I've figured it out. It can be done. It's not ideal, but it works.
Drxenos, I'd be interested to know what solution you came up with.
The secret is finding a command that behaves differently with selected lines vs none selected. I found that setting a bookmark fits the bill. When lines are selected, it marks all of them. If not, it marks the line the cursor's on. Plus, there is a command to copy all bookmarked lines to the clipboard. Perfect.

Of course, the problem is you'll lose any bookmarks you currently have set. Also, it does "weird" things if the selected lines aren't fully selected. So...not so perfect, but functional. It can probably be refined...

All in all, what I currently have is:
BookmarkClearAll
BookmarkToggle
EditCopyTaggedLines
BookmarkClearAll
LineStart
EditPaste

I'd also found that if I create a simple macro (e.g., record a single keystroke), I can then just edit the macro manually, which is much easier than re-recording it for each test.

DrX
Post Reply