DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: [BEST] Boxer Editor Scripting Thread  (Read 15,088 times)

AbteriX

  • Member #520
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,150
[BEST] Boxer Editor Scripting Thread
« on: March 25, 2008, 12:16 PM »
Boxer Editor Scripting Thread to learn and exchange scripts for Boxer Text Editor


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


Quote
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.org.mv/popzees/rot/rotn.php
http://en.wikipedia.org/wiki/ROT13

Infos bezüglich ROT13:
http://holger.thoelking.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)
// macro description goes here
// modify char to value-x higher char like ROT13
// f.ex.  A=65ascii    >    65+13=78    >     78ascii=N    >>>  char 'A' convert to char 'N'
macro newmacro()
{
Const X = 13;
GetSelection(mySEL);

For Each SingleChar in mySEL
    isalpha(SingleChar)
       newchar = ToAsciiValue(SingleChar) + X
	   newchar = ToChar(Newchar)

	   InsertCharacter(newchar)

Next
}

Greetings, Stefan.
« Last Edit: March 25, 2008, 11:10 PM by AbteriX »

f0dder

  • [Well, THAT escalated quickly!]
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
    • Participated in NANY Challenge Once
Re: [BEST] Boxer Editor Scripting Thread
« Reply #1 on: March 25, 2008, 01:49 PM »
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

  • Author of the Boxer Text Editor
  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 31
Re: [BEST] Boxer Editor Scripting Thread
« Reply #2 on: March 25, 2008, 02:23 PM »
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)
macro newmacro()
{
string str;
int i, len;
int constant = 13;

// get the length of the selected text
len = GetSelectionSize();

// make sure selection size won't
// exceed maximum string size
if (len >= 2048)
	{
	Message("Error", "Too much text is selected.");
	return;
	}
else if (len == 0)
	{
	Message("Error", "No text is selected.");
	return;
	}

// get selection into 'str'	
GetSelection(str);

// loop to process each character in 'str'
for (i = 0; i < len; i++)
	if (str[i] != '\r' && str[i] != '\n')
		str[i] += constant;
	
PutSelection(str);
}

Best,

David Hamel
Boxer Software

allen

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,206
    • Participated in NANY Challenge Once
    • Cody Award
    • Programming School - Deluxe Bonus Medal
    • Military Service Badge - US Navy
    • Linux User
    • Writer
Re: [BEST] Boxer Editor Scripting Thread
« Reply #3 on: March 25, 2008, 02:36 PM »
That's not an actual rot13 conversion, though--it's a literal +13 and only one direction I think. . .

This does rot13
Code: (c)
// Macro for rot13 text conversion

macro rot13()
{
  // Define primary alphabet key
  string base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  // Define the conversion key
  string conv = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm";
  // Declare some vars
  string output,sel; // selection text
  char thischar;
  // Check for selected text; if none, 
  // print message to status bar and exit macro
  if ( getselectionsize <= 0 ) {
    statusmessage("Nothing was selected.");
    return;
  } else if (getselectionsize >= 2048) {
    statusmessage("Selected text exceeds allowed size.");
    return;
  }
  // Fetch selected text
  int thispos=0,thischarpos,selsize=getselection(sel);

  // Convert text
  while(thispos<selsize) {
    thischar = sel[thispos];
    thischarpos=strchr(base,thischar);
    if ( thischarpos >= 0 ) {
      thischar = conv[thischarpos];
    }
    output += thischar;
    thispos++;
  }
  Delete;
  PutString(output);
}

Boxer Software

  • Author of the Boxer Text Editor
  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 31
Re: [BEST] Boxer Editor Scripting Thread
« Reply #4 on: March 25, 2008, 02:44 PM »
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
    • Participated in NANY Challenge Once
    • Cody Award
    • Programming School - Deluxe Bonus Medal
    • Military Service Badge - US Navy
    • Linux User
    • Writer
Re: [BEST] Boxer Editor Scripting Thread
« Reply #5 on: March 25, 2008, 02:53 PM »
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

  • Member #520
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,150
Re: [BEST] Boxer Editor Scripting Thread
« Reply #6 on: March 25, 2008, 03:22 PM »
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.codeproject.com/KB/security/registryencryption.aspx
http://www.autohotkey.com/forum/topic9154.html
http://blog.didierstevens.com/2006/07/24/rot13-is-used-in-windows-you%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.winhelpline.info/forum/security-firewall/29066-exakter-sinn-des-userassist-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?
Greetings, Stefan.
« Last Edit: March 25, 2008, 04:02 PM by AbteriX »

allen

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,206
    • Participated in NANY Challenge Once
    • Cody Award
    • Programming School - Deluxe Bonus Medal
    • Military Service Badge - US Navy
    • Linux User
    • Writer
Re: [BEST] Boxer Editor Scripting Thread
« Reply #7 on: March 25, 2008, 03:34 PM »
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)
// Send the selected text as an e-mail message

macro SendAsEmail()
{
  // Set prompt to 0 to disable subject prompt
  int prompt = 1;
  int inc;
  string line;
  string sel;
  string subj;
  string strout;
  // Check for selection, if nothing selected
  // Line 1 = subject, rest = body
  // This is to ensure cursor placement doesn't
  // truncate the url encoding
  if ( GetSelectionSize <= 0 ) {
    GetLineText(1,subj);
    ChangeString(subj," ","%20");
    for ( inc = 2; inc <= LineCount(); inc++ ) {
      GetLineText(inc,line);
      ChangeString(line," ","%20");
      line += "%0a";
      sel += line;
    }
  } else {
    // Prompt for SUBJECT only if "prompt" is not 0
    // Otherwise, blank subject is sent
    if ( strlen(subj) < 1 && prompt > 0 ) {
      GetString("Subject of Message",subj);
      ChangeString(subj," ","%20");
    }
    // Fetch body, add spaces and line endings
    GetSelection(sel);
    ChangeString(sel,"\n","%0a");
    ChangeString(sel," ","%20");
  }
  // Assemble mailto string
  strout = "?subject=";
  strout += subj;
  strout += "&body=";
  strout += sel;
  // Send to mail client
  OpenEmail(strout);
}

AbteriX

  • Member #520
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,150
Re: [BEST] Boxer Editor Scripting Thread
« Reply #8 on: March 30, 2008, 12:23 AM »
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)
// Find an string. Select all lines till the line where this string occurs first. 

macro newmacro()
{
int LineStart, LineEnd, LineCurr;
string FindAndSelectmyFind, myFind;

	LineStart = LineNumber; // current line number at macro start

	//REM ReadValue(FindAndSelectmyFind, myFind); // read last stored search value
	GetString("Find what: ", myFind); // string to find and select to
	//REM WriteValue(FindAndSelectmyFind, myFind); // save value for re-use

	if (myFind != "")
	{
	// go across all lines from current start line to EOF, line by line
		for (LineCurr = LineStart; LineCurr <= LineCount(); LineCurr++)
   		{
	  		if (LineContainsREi(LineCurr, myFind)) // if search string is found in line
       		{
					LineEnd = LineCurr; // set var LineEnd to number of current line
        			break; // stop the for loop
	   		}
		}

		GoToLine(LineStart); // go back to start line where we came from
		// go through all lines from our start line to the line where the string was found, line by line    
		for (LineCurr = LineStart; LineCurr <= LineEnd; LineCurr++)
  		{
				SelectDown; // select each line between
  		}
	}
}


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 ;-)

.
Greetings, Stefan.

Boxer Software

  • Author of the Boxer Text Editor
  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 31
Re: [BEST] Boxer Editor Scripting Thread
« Reply #9 on: March 30, 2008, 02:12 PM »
Hi Stefan,

Quote
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

Original address: https://www.donationcoder.com/forum/index.php?topic=12785.0