EmEditor (text editor) Forum Index
   Macro Samples
     Macro: Select whole paragraph
Register To Post

Flat Previous Topic | Next Topic
Poster Thread
Stefan
Posted on: 5/7/2012 3:42 am
Home away from home
Joined: 7/14/2008
From: Germany, EU
Posts: 262
Re: Macro: Select whole paragraph
Thanks webern, but that doesn't explains why it works in one version and not in the other.

Anyway, i have now understood that i doesn't need the part
o.SetActivePoint(eePosLogical, 1, yPosEnd, true);

and also not the part
yPosEnd = o.GetActivePointY(eePosLogical);


New version:

// Shorten the object string, just for fewer typing:
o = document.selection;

// - - -

// Find something backwards/up, here empty line:
o.Find("^\\s*$",eeFindPrevious | eeFindReplaceRegExp);

// Remember the current line number:
yPosBegin = o.GetActivePointY(eePosLogical) +1;

// - - -

// Find again something downwards 
//   (here: find an blank line, non-greedy)
//   AND move the cursor that way to the found position :
o.Find("^\\s*$",eeFindNext | eeFindReplaceRegExp);

// Do an selection.
//   Set the start of the selection to the remembered line.
//   The end of the selection will be the current line:
o.SetAnchorPoint(eePosLogical, 1, yPosBegin); 




Similar i use now this to just select down
to the next blank line:


o = document.selection;

//Remember the current line number:
yPos = o.GetActivePointY( eePosLogical );

//Move cursor to found position (here: find an blank line):
o.Find("^$",eeFindNext | eeFindReplaceRegExp);

//Do an selection.
//Set the start of the selection to the remembered line:
o.SetAnchorPoint( eePosLogical, 1, yPos );




.
Flat Previous Topic | Next Topic


Subject Poster Date
   Macro: Select whole paragraph Stefan 5/2/2012 12:12 pm
     Re: Macro: Select whole paragraph Stefan 5/3/2012 12:57 pm
       Re: Macro: Select whole paragraph webern 5/3/2012 11:33 pm
         Re: Macro: Select whole paragraph Stefan 5/4/2012 6:16 am
           Re: Macro: Select whole paragraph webern 5/4/2012 1:33 pm
           » Re: Macro: Select whole paragraph Stefan 5/7/2012 3:42 am
               Re: Macro: Select whole paragraph Stefan 7/10/2012 6:18 am
                 Re: Macro: Select whole paragraph netsking 1/28/2013 11:30 am

Register To Post
 
English čeština Deutsch español français italiano 日本語 한국어 Русский 简体中文 繁體中文