You are here: PSPad forum > English discussion forum > Shortcut key for inserting a custom XML tag on highlighted texts

Shortcut key for inserting a custom XML tag on highlighted texts

#1 Shortcut key for inserting a custom XML tag on highlighted texts

Posted by: STing | Date: 2014-07-18 08:41 | IP: IP Logged

Hi Folks,

My request is related to this thread posted a couple of years ago and I am not sure if the software has changed since then.
forum.pspad.com

Is it possible to include a feature in PSPad to insert a custom XML tag on a piece of segment which is selected?

For example if I select "football" in the segment below, it is possible to wrap a custom opening and closing tag around the selected text with a single key by this using one of the Function keys:

"I am playing football in a field" to
"I am playing <MyTag>football</MyTag> in a field."

Thanks,
Si

Edited 1 time(s). Last edit at 2014-07-18 08:42 by STing.

Options: Reply | Quote | Up ^


#2 Re: Shortcut key for inserting a custom XML tag on highlighted texts

Posted by: pspad | Date: 2014-07-18 09:03 | IP: IP Logged

Your Code Clip will looks like:

<MyTag>§|</MyTag>

The char § depends of the [Clip Settings] section in your clip file. If this section isn't present, the default values are:
[Clip Settings]
CursorChar=|
SelectionChar=§

Options: Reply | Quote | Up ^


#3 Re: Shortcut key for inserting a custom XML tag on highlighted texts

Posted by: STing | Date: 2014-07-18 09:31 | IP: IP Logged

Many thanks for replying.

Would you mind directing me to the menu or settings for "codeclips"?
I have no idea where to start this implementation.

I did however develop a workaround by simply create a couple of macros and assign the shortcuts keys F2 and F3 to insert the tags.

But it is not an elegant solution.

Just wondering also if it is possible to implement Java solution for this?
Something along this logic:

putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke( 'Z', KeyEvent.MODIFIER_ALT ) );

public void actionPerformed(ActionEvent e) {
JTextComponent n = PSPad.getInstance().getDocumentModel().getCurrentDocument().getUIComponent();
n.replaceSelection( "<MyTag>" + n.getSelectedText() + "</MyTag>" );
}

Edited 2 time(s). Last edit at 2014-07-18 09:38 by STing.

Options: Reply | Quote | Up ^


#4 Re: Shortcut key for inserting a custom XML tag on highlighted texts

Posted by: pspad | Date: 2014-07-18 10:13 | IP: IP Logged

Hello

Open PSPad help, go to chapter Working with PSPad / Context files

Options: Reply | Quote | Up ^


#5 Re: Shortcut key for inserting a custom XML tag on highlighted texts

Posted by: STing | Date: 2014-07-18 11:22 | IP: IP Logged

Thank you for the solution and it works well now.
Much appreciated.

Here' are the steps:
1) Navigate to the directory:
"\PSPad editor\Context\XML.DEF"

2) Open this file and insert the code under this section:
;---------------------------------------------------------------------
; XML (black)
;---------------------------------------------------------------------
;
[MyTag |G bold text <MyTag></MyTag>]*ALT+Q
<MyTag>§|</MyTag>
;

3) Save and restart PSPad.

The shortcuts can also be accessed via the drop down menu of the software:
Settings > Clips Hotkeys

Edited 1 time(s). Last edit at 2014-07-18 11:32 by STing.

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR