topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday April 18, 2024, 3:30 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: [BEST] Boxer Editor Scripting Thread  (Read 11954 times)

AbteriX

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,149
    • View Profile
    • Donate to Member
[BEST] Boxer Editor Scripting Thread
« on: March 25, 2008, 07:16 AM »
Boxer Editor Scripting Thread to learn and exchange scripts for Boxer Text Editor


Boxer Text Editor at DonationCoder
Boxer Text Editor - 51% Off!


Boxer includes a powerful macro language ... similar in style to the C programming language

===> Boxers Example Macros



Learning C:
Wiki english
The C Book — Table of Contents and free PDF download

C lernen:
Wiki deutsch
Galileo Computing  <openbook>  C von A bis Z kostenloser download


- - -

Hi, i just trying myself learning how to scripting Boxer
My first attempt is to make an ROT13-macro ('cus i see no such function in Bx and i want to encrypt an Reg-key)

Infos about ROT13:
http://www.senses0.o...popzees/rot/rotn.php
http://en.wikipedia.org/wiki/ROT13

Infos bezüglich ROT13:
http://holger.thoelk....name/skripten/rot13
http://de.wikipedia.org/wiki/ROT13


With PSPad i have simply an Tool "user conversion" with an text file like:
[Table]
97=110
98=111



With Bx (Boxer) i think i have to do an script?

If anyone is interested to take part in ... ('cus my lunch break is over  :P )

I tried the following till now (partly pseudo code)


Code: C [Select]
  1. // macro description goes here
  2. // modify char to value-x higher char like ROT13
  3. // f.ex.  A=65ascii    >    65+13=78    >     78ascii=N    >>>  char 'A' convert to char 'N'
  4. macro newmacro()
  5. {
  6. Const X = 13;
  7. GetSelection(mySEL);
  8.  
  9. For Each SingleChar in mySEL
  10.     isalpha(SingleChar)
  11.        newchar = ToAsciiValue(SingleChar) + X
  12.            newchar = ToChar(Newchar)
  13.  
  14.            InsertCharacter(newchar)
  15.  
  16. Next
  17. }

« Last Edit: March 25, 2008, 06:10 PM by AbteriX »

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: [BEST] Boxer Editor Scripting Thread
« Reply #1 on: March 25, 2008, 08:49 AM »
I wonder why you want to "encrypt a registry key" with ROT13? Just for fun and testing? It's pretty useless for anything else :)
- carpe noctem

Boxer Software

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 31
  • Author of the Boxer Text Editor
    • View Profile
    • Boxer Software
    • Read more about this member.
    • Donate to Member
Re: [BEST] Boxer Editor Scripting Thread
« Reply #2 on: March 25, 2008, 09:23 AM »
Stefan,

Here's a Boxer macro that will get the selected text, add 13 to each character within the selection, and then replace the selection with the new text:

Code: C [Select]
  1. macro newmacro()
  2. {
  3. string str;
  4. int i, len;
  5. int constant = 13;
  6.  
  7. // get the length of the selected text
  8. len = GetSelectionSize();
  9.  
  10. // make sure selection size won't
  11. // exceed maximum string size
  12. if (len >= 2048)
  13.         {
  14.         Message("Error", "Too much text is selected.");
  15.         return;
  16.         }
  17. else if (len == 0)
  18.         {
  19.         Message("Error", "No text is selected.");
  20.         return;
  21.         }
  22.  
  23. // get selection into 'str'    
  24. GetSelection(str);
  25.  
  26. // loop to process each character in 'str'
  27. for (i = 0; i < len; i++)
  28.         if (str[i] != '\r' && str[i] != '\n')
  29.                 str[i] += constant;
  30.        
  31. PutSelection(str);
  32. }

Best,

David Hamel
Boxer Software

allen

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,206
    • View Profile
    • Donate to Member
Re: [BEST] Boxer Editor Scripting Thread
« Reply #3 on: March 25, 2008, 09:36 AM »
That's not an actual rot13 conversion, though--it's a literal +13 and only one direction I think. . .

This does rot13
Code: C [Select]
  1. // Macro for rot13 text conversion
  2.  
  3. macro rot13()
  4. {
  5.   // Define primary alphabet key
  6.   string base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  7.   // Define the conversion key
  8.   string conv = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm";
  9.   // Declare some vars
  10.   string output,sel; // selection text
  11.   char thischar;
  12.   // Check for selected text; if none,
  13.   // print message to status bar and exit macro
  14.   if ( getselectionsize <= 0 ) {
  15.     statusmessage("Nothing was selected.");
  16.     return;
  17.   } else if (getselectionsize >= 2048) {
  18.     statusmessage("Selected text exceeds allowed size.");
  19.     return;
  20.   }
  21.   // Fetch selected text
  22.   int thispos=0,thischarpos,selsize=getselection(sel);
  23.  
  24.   // Convert text
  25.   while(thispos<selsize) {
  26.     thischar = sel[thispos];
  27.     thischarpos=strchr(base,thischar);
  28.     if ( thischarpos >= 0 ) {
  29.       thischar = conv[thischarpos];
  30.     }
  31.     output += thischar;
  32.     thispos++;
  33.   }
  34.   Delete;
  35.   PutString(output);
  36. }

Boxer Software

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 31
  • Author of the Boxer Text Editor
    • View Profile
    • Boxer Software
    • Read more about this member.
    • Donate to Member
Re: [BEST] Boxer Editor Scripting Thread
« Reply #4 on: March 25, 2008, 09:44 AM »
Hi Allen,

Thanks for jumping in.  I'm unfamiliar with ROT13, so I just worked from his pseudo-code.

Between our two macros, I think we've shown the concepts pretty well.

Best,

David Hamel
Boxer Software

allen

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,206
    • View Profile
    • Donate to Member
Re: [BEST] Boxer Editor Scripting Thread
« Reply #5 on: March 25, 2008, 09:53 AM »
ROT13 is just a silly way of rotating through the alphabet as a 52 character index (caps and lowercase unique) to mask text. It's naturally bi-directional, not at all secure, but I guess can mask things from search engines and obfuscates the information from those unfamiliar with ROT13 . . . (Yvxr lbh svir zvahgrf ntb!) :)

AbteriX

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,149
    • View Profile
    • Donate to Member
Re: [BEST] Boxer Editor Scripting Thread
« Reply #6 on: March 25, 2008, 10:22 AM »
Thanks fellows!  You are quick and helpful, very kind of you.  :-*
So i have smtg to learn this evening. And i hope this thread will encourage people to try this scripting too.

.. .. .. .. .. ..

WRT ROT13 and Registry?
Some key in Reg are "encrypted" by M$ thereself, like
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\....

I can remember there is an other key too,   
and i had known an trick to decrypt this key automatically by adding an new key (and/or value)
But ths trick is not presend right now  :-\  :'(

EDIT: here a few links about this topic
http://www.codeproje...istryencryption.aspx
http://www.autohotke...forum/topic9154.html
http://blog.didierst...u%E2%80%99re-joking/

EDIT:
And here is the trick

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ Explorer\UserAssist\
New key "Settings"
New DWORD "NoEncrypt"   set to "1 "

Found by
http://www.winhelpli...ist-schluessels.html


And sorry for false "encrypt" / "decrypt" using/mix-up.

---

That's why i want use ROT13... to de-crypt an key/value like them above.
And for to see how this works in Boxer  :D

.. .. .. .. .. .. .. .. ..

ROT13 is also handy to exchange text (email addy f.ex.) in forum not all should read easily (or crawl) .
F.ex. to ask an trick-question and add the answer "rot-ed"  :P

.. .. .. .. .. .. .. .. ..

Please people, come on and fill this tread with live..... what's to script next?
« Last Edit: March 25, 2008, 11:02 AM by AbteriX »

allen

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,206
    • View Profile
    • Donate to Member
Re: [BEST] Boxer Editor Scripting Thread
« Reply #7 on: March 25, 2008, 10:34 AM »
Here's one I use fairly frequently. It takes the body of a text file and activates it as a mailto link, sending it to your default e-mail client.  The arbitrary buffer size limits the size of document this works with, but it's handy if I'm working on something and want to jot down a quick message without switching to my mail client.
- If nothing is selected, line 1 is subject and the rest is the body
- If there is a selection, it is treated as the body and you are prompted for the subject
Code: C [Select]
  1. // Send the selected text as an e-mail message
  2.  
  3. macro SendAsEmail()
  4. {
  5.   // Set prompt to 0 to disable subject prompt
  6.   int prompt = 1;
  7.   int inc;
  8.   string line;
  9.   string sel;
  10.   string subj;
  11.   string strout;
  12.   // Check for selection, if nothing selected
  13.   // Line 1 = subject, rest = body
  14.   // This is to ensure cursor placement doesn't
  15.   // truncate the url encoding
  16.   if ( GetSelectionSize <= 0 ) {
  17.     GetLineText(1,subj);
  18.     ChangeString(subj," ","%20");
  19.     for ( inc = 2; inc <= LineCount(); inc++ ) {
  20.       GetLineText(inc,line);
  21.       ChangeString(line," ","%20");
  22.       line += "%0a";
  23.       sel += line;
  24.     }
  25.   } else {
  26.     // Prompt for SUBJECT only if "prompt" is not 0
  27.     // Otherwise, blank subject is sent
  28.     if ( strlen(subj) < 1 && prompt > 0 ) {
  29.       GetString("Subject of Message",subj);
  30.       ChangeString(subj," ","%20");
  31.     }
  32.     // Fetch body, add spaces and line endings
  33.     GetSelection(sel);
  34.     ChangeString(sel,"\n","%0a");
  35.     ChangeString(sel," ","%20");
  36.   }
  37.   // Assemble mailto string
  38.   strout = "?subject=";
  39.   strout += subj;
  40.   strout += "&body=";
  41.   strout += sel;
  42.   // Send to mail client
  43.   OpenEmail(strout);
  44. }

AbteriX

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,149
    • View Profile
    • Donate to Member
Re: [BEST] Boxer Editor Scripting Thread
« Reply #8 on: March 29, 2008, 07:23 PM »
I have thought i have seen this feature in Boxer, but didn't find it. So i have taken this to try my first Boxer script.

Find user string and select lines till the string occurs first.
f.ex.
- scroll through an long text and wrote an char didn't exist in the whole text, like an '#'
- go back above to your start line (hint: bookmark) and search(via script) for '#' .... the script will select all lines between.

Find-and-select-to-find
Code: C [Select]
  1. // Find an string. Select all lines till the line where this string occurs first.
  2.  
  3. macro newmacro()
  4. {
  5. int LineStart, LineEnd, LineCurr;
  6. string FindAndSelectmyFind, myFind;
  7.  
  8.         LineStart = LineNumber; // current line number at macro start
  9.  
  10.         //REM ReadValue(FindAndSelectmyFind, myFind); // read last stored search value
  11.         GetString("Find what: ", myFind); // string to find and select to
  12.         //REM WriteValue(FindAndSelectmyFind, myFind); // save value for re-use
  13.  
  14.         if (myFind != "")
  15.         {
  16.         // go across all lines from current start line to EOF, line by line
  17.                 for (LineCurr = LineStart; LineCurr <= LineCount(); LineCurr++)
  18.                 {
  19.                         if (LineContainsREi(LineCurr, myFind)) // if search string is found in line
  20.                 {
  21.                                         LineEnd = LineCurr; // set var LineEnd to number of current line
  22.                                 break; // stop the for loop
  23.                         }
  24.                 }
  25.  
  26.                 GoToLine(LineStart); // go back to start line where we came from
  27.                 // go through all lines from our start line to the line where the string was found, line by line    
  28.                 for (LineCurr = LineStart; LineCurr <= LineEnd; LineCurr++)
  29.                 {
  30.                                 SelectDown; // select each line between
  31.                 }
  32.         }
  33. }


Unfortunately it seams as " GetString("Find what: ", myFind); "  didn't support to show user an suggestion?
I exspected something like: " int GetString(string prompt, string result, string suggestion) "
I will search for an alternative.



Perhaps this script is an improvement-idea for David.  ;) Smtg similar like "Go to..." and []extend selection ?

Next i will try to script  Find-and-select-to-bookmark ;-)

.

Boxer Software

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 31
  • Author of the Boxer Text Editor
    • View Profile
    • Boxer Software
    • Read more about this member.
    • Donate to Member
Re: [BEST] Boxer Editor Scripting Thread
« Reply #9 on: March 30, 2008, 09:12 AM »
Hi Stefan,

I have thought i have seen this feature in Boxer, but didn't find it. So i have taken this to try my first Boxer script.

If you have a selection started, and then issue the Find command, there's an "Extend Selection" option on the Find dialog that should do what you like.

(Note: if the existing selection is of any size, the Scope will default to searching within the selection, so be sure to change the Scope to suit your need in order to enable the Extend Selection option.)


Best,

David Hamel
Boxer Software