Custom text wrapping script

Post your working scripts, libraries and tools
kkwillmert
Posts: 3
Joined: 14 Sep 2017, 15:22
GitHub: kkwillmert

Custom text wrapping script

14 Sep 2017, 16:00

In my search for a script that would help me write a hotkey to wrap highlighted text (for use in code header block comments), I stumbled across an old script by Gehn in the archived forums: https://autohotkey.com/board/topic/2459-custom-text-wrapping-script/

Unfortunately, the script doesn't work on the current AutoHotkey version, I think probably because it uses array-style reference syntax (square brackets) in pseudo-array variable names within function calls (e.g. StringLen), which I'm guessing probably worked prior to the implementation of associative arrays (see https://autohotkey.com/docs/misc/Arrays.htm).

But I really wanted it, so I took the time to correct the bugs and spruce it up a bit. Since this took me most of a day and I found it pretty useful, I thought I should share (see below) :D

Suggested improvements would be appreciated. If anyone is interested in seeing the hotkey I wrote that utilizes this script, I can post that too.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Last edited by kkwillmert on 19 Sep 2017, 13:46, edited 1 time in total.
Helgef
Posts: 2228
Joined: 17 Jul 2016, 01:02
Contact:

Re: Custom text wrapping script

14 Sep 2017, 16:42

Nice, thanks for sharing :thumbup:
Maybe add msgbox % wrappedText after Gosub , WrapText in the example.
Note:
wrappedText would be: "C:\Games\`nGuild`nWars\`nGW.exe"
actually becomes C:\Games\`nGuild Wars\GW.exe

Cheers.
carno
Posts: 78
Joined: 20 Jun 2014, 16:48

Re: Custom text wrapping script

17 Sep 2017, 22:09

I would like to see the hotkey you wrote that utilizes this script. Please post that too with an example how to do it.
kkwillmert
Posts: 3
Joined: 14 Sep 2017, 15:22
GitHub: kkwillmert

Re: Custom text wrapping script

19 Sep 2017, 14:02

Helgef wrote:Maybe add msgbox % wrappedText after Gosub , WrapText in the example.


Done :-)

Helgef wrote:Note:
wrappedText would be: "C:\Games\`nGuild`nWars\`nGW.exe"
actually becomes C:\Games\`nGuild Wars\GW.exe


Thanks for catching that, that's the OP's example and I didn't actually test it out :oops: . I'm not sure if I broke his multiple character set functionality when I fixed up the script to work in current AutoHotkey versions, or if it didn't work to begin with, but unfortunately I won't have the time to figure it out for a while :-(
kkwillmert
Posts: 3
Joined: 14 Sep 2017, 15:22
GitHub: kkwillmert

Re: Custom text wrapping script

19 Sep 2017, 14:12

carno wrote:I would like to see the hotkey you wrote that utilizes this script. Please post that too with an example how to do it.


Here you go! I'm using this in Windows 10, not sure how well it will behave for other OS's.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



So with this hotkey set up, you could highlight all of this text...

Code: [Select all] [Download] GeSHi © Codebox Plus

/* **************************************************************************************************

This is a code header comment:

This is a really long purpose that has lots of text and stuff and is going to be way super long so that i will want it to wrap because i am writing an autohotkey for wrapping text and in order to wrap text i need some super long text to test the routine on because i need to know if it's actually working the way i want or not and stuff.

************************************************************************************************** */


...then hit Ctrl + Shift + W, and it would paste over it with this text:

Code: [Select all] [Download] GeSHi © Codebox Plus

/* **************************************************************************************************

This is a code header comment:

This is a really long purpose that has lots of text and stuff and is going to be way super long so
that i will want it to wrap because i am writing an autohotkey for wrapping text and in order to wrap
text i need some super long text to test the routine on because i need to know if it's actually
working the way i want or not and stuff.

************************************************************************************************** */


In this type of comment format, you can also use the hotkey to re-do the wrapping on the text after you make an edit.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 14 guests