Author Topic: Idea collecting: What i wanna do with scripting  (Read 8524 times)

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Idea collecting: What i wanna do with scripting
« on: April 29, 2009, 03:45:58 pm »
Often i had an feature request - then i think "i can do this on my own, if once scripting is supported"

So i collect here my ideas (and maybe you too?),
maybe to aid Alex to find out what is needed for scripting?
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Idea collecting: What i wanna do with scripting
« Reply #1 on: April 29, 2009, 03:52:33 pm »
EDIT: already there

=>"Tools > Keyboard Settings..."
=> Edit.SmartHighlight  (current word under cursor)


I just have assign an shortcut to it  :D :top:

EDIT:  or hold CTRL-key while clicking on an word  ;D
« Last Edit: May 03, 2009, 06:46:30 pm by Stefan »

Offline Arthur

  • Registered User
  • Hero Member
  • *
  • Posts: 653
  • Karma: +1/-0
  • He who is ashamed of asking is afraid of learning.
    • View Profile
    • My Blog
Re: Idea collecting: What i wanna do with scripting
« Reply #2 on: April 29, 2009, 04:55:24 pm »
I few ideas:

1) Strip out irrelevant text (e.g. HTML, code comments, etc.);
2) Generate a new file based on an existing one;
3) Batch modify a bunch of files;
4) Capture and present certain text;
5) Perform complex searches/replacements (e.g. conditional ones, for instance when a value X is greater than Y, and so forth)

scottbilas

  • Guest
Re: Idea collecting: What i wanna do with scripting
« Reply #3 on: May 03, 2009, 02:52:39 am »
Use scripting to enhance syntax parsing and coloring. For example, queries from the HE editor to a custom lexer to get all the functions in the file - something not always possible with a regex. Or scripts to do small scale refactoring ("convert this property into a function getter/setter"). It doesn't have to be super complex or complete. Could start out with a few helpers to enhance the lexer in ways that regex's can't.

For the internal API, consider taking a look at VS.NET 2010. I've heard really great things about its extensibility model. Perhaps it has elements that would be easy to implement in HE. Here's a good interview on it from @shanselman: http://bit.ly/PFgG.

This would probably rule out a slow scripting language due to the performance requirements of background parsing, but perhaps you can use C# with dynamic compiling and assembly generation.

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2181
  • Karma: +37/-3
    • View Profile
    • HippoEDIT
Re: Idea collecting: What i wanna do with scripting
« Reply #4 on: May 03, 2009, 06:23:29 pm »
Hello Scott,

I do not think, that scripting should be used in synatx highlighting. For this purpose I think best would be a compiled lexer plugin I am also planning (some early versions of HE already had support of external lexers, but now this already does not work..)

But for some refactoring tools as getters/setters generation - yes :)

Best regards,
Alex.
P.S: thanks for link ;).

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Idea collecting: What i wanna do with scripting
« Reply #5 on: June 03, 2009, 04:38:46 pm »
Often i copy some info from Internet and paste it into an editor.

This give me an result like this:

  28.
      If UCase(Mid(args(c1),3,Len(ALongSwitch))) = (UCase(ALongSwitch)) Then
  29.
      Found = True
  30.
      ASign = InStr(args(c1),"=")
  31.
       
  32.
      If ASign <> 0 Then



Here i wanna wrote an script like:

Until HE.EOF
  WS.SendKeys(END)
  WS.SendKeys(Ctrl+Shift+ArrowRight)
  WS.SendKeys(DEL)
  WS.SendKeys(TAB)
  HE.LineDown
Loop


To get:

  28.        If UCase(Mid(args(c1),3,Len(ALongSwitch))) = (UCase(ALongSwitch)) Then
  29.        Found = True
  30.        ASign = InStr(args(c1),"=")
  31.         
  32.        If ASign <> 0 Then



EDIT: i have wrote this like an script, but would work as simple keystroke recording macro too.
Start Recording
  END
  Ctrl+Shift+ArrowRight
  DEL
  TAB
  Pos1
  ArrowDown
Stop Recording
Run Macro
Run Macro multiple times: [X] till EOF
« Last Edit: June 04, 2009, 07:42:26 am by Stefan »

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Idea collecting: What i wanna do with scripting
« Reply #6 on: June 05, 2009, 08:09:01 am »
Find an label and copy line and next two lines into new tab

curTab = HE.ActiveTab.FullFileName

sel = HE.ActiveTab.FullFileName & vbCRLF & vbCRLF  & "ToDo's:" & vbCRLF

For i = 1 To MaxLinesCount - CurrentLineNumber
 result = Find("//ToDo")
  IF Result Then
    Goto.POS1
    Selection.Mode(Line)
    Selection.Start
    Goto.EOL(select true)
    Goto.ArrowDown
    Goto.ArrowDown
    Selection.End
    sel = sel & vbLF &  Selection.Area
  End IF
Next


HE.Tabs.New
Activate NewTab
write(sel)
HE.Tabs.Close(curTab)

.

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Idea collecting: What i wanna do with scripting
« Reply #7 on: September 27, 2009, 02:48:34 am »
I often copy tutorials or other many lines of text from the internet.
Often this are
- a few line as "header" or description - which i didn't want to break
- a few or more but very long lines - "the" text to reformat.
- a few lines below, f.ex. commants from other readers - which i didn't want to reformat


f.ex.:

Description Description Description Description
Description Description Description Description Description
Headline
Selected Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text

Comments Comments Comments Comments
Comments Comments Comments Comments Comments

-----------------



Now i need to reformat those lines. (Break each line longer then x chars at n chars and add linefeed)



1. select the part of the text to reformat.

2.
FOR EACH line IN lines
   IF line > 72 chars THEN
       GoOneLineUp
       IF line > 0 THEN //but shorter then 72
         GoOneLineDown
         GoToPos1
         Press ENTER   //add an empty line
      ELSE
         GoOneLineDown
       End IF

       While line > 55  
             break line at end-of-word after 55 chars
        Went

       GoOneLineDown
       IF line > 0 THEN   // if there is not already an empty line - add one
          GoToPos1
          Press ENTER
       End IF

   ELSE
       continue  // nothing to do
  End IF
NEXT

----------------------

Hmm, Most is covered by script language i think.
Editor only provide/write selected text.

varSelection = Editor.selection

Lines = array(varSelection, vbCRLF)
GoOneLineUp => Lines[X]-1
GoOneLineDowm => Lines[X]+1
GoToPos1+Press ENTER => Lines[X] & vbCRLF ? ? ?
and like this...

Editor.selection = varSelection
« Last Edit: September 27, 2009, 03:02:45 am by Stefan »

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Idea collecting: What i wanna do with scripting
« Reply #8 on: September 28, 2009, 01:47:44 pm »
I want to execute an script by an short cut which should do the following:

* execute an intern HippoEDIT command (Paste As HTML)
* insert a few line breaks \r\n
* insert an string like "<BR><BR><BR>"
* insert a few line breaks \r\n
* scroll the last line in the middle of screen
* save the document

.

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Idea collecting: What i wanna do with scripting
« Reply #9 on: September 28, 2009, 02:35:35 pm »
I want to execute an script while HippoEDIT is not visible.

For example as clip board collector.

* In HippoEDIT i set an global hotkey to execute the script from above ("Paste As HTM and format")
* Then i minimize HippoEDIT and went to my browser
* in browser i select and copy some text
* now i press the global hotkey to trigger HippoEDIT to execute the script...
 ... or i set HippoEDIT to use an EVENT "OnClipboardUpdate" :D

.

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Idea collecting: What i wanna do with scripting
« Reply #10 on: October 01, 2009, 01:02:49 pm »
Like Ctrl+D

i want to duplicate an line or block of code
AND automatically increase all found digits by 1

Examples1:
<form name="HE" action="" method="get" enctype="text/html">
<input type="radio" name="Radio1" value="Option1" ="" />
<input type="radio" name="Radio2" value="Option2" ="" /> Duplicated and increased to 2
<input type="radio" name="Radio3" value="Option3" ="" /> Duplicated and increased to 3
</form>

Examples2:
name_1=
app_1=
arg_1=
dir_1=

Duplicated and increased:
name_2=
app_2=
arg_2=
dir_2=



---------

I want to select an block/column only and de- or increase all found digits by n

.
« Last Edit: June 29, 2010, 09:12:18 am by Stefan »

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Idea collecting: What i wanna do with scripting
« Reply #11 on: October 01, 2009, 02:09:59 pm »

I want be able to execute an scripting command from an %placeholder% ... or like that.


  <title>Untitled</title>
  <meta name="generator" content="HippoEDIT" />
  <meta name="author" content="%USERNAME%" />
  <meta name="keywords" content="" />
  <meta name="description" content="" />
 </head>
 <body>
   <DIV style=width:65%%;>
%Clipboard{PasteAsHTML2}%
%HE.executeScript"Scripts\templates\PasteAsHTML.hes"%
  %|%
  </DIV>
 </body>

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Idea collecting: What i wanna do with scripting
« Reply #12 on: October 07, 2009, 10:07:36 am »
// Find lines containing 'Fixed' AND 'Buttonbar' AND copy this lines with surrounded lines to new tab


Pseudo code:
//store selection mode to set it later back to this mode
StoredSelectionMode = Current selection mode


//find first word
HE.PosLine(1)
For x = 1 to HE.LineCount
 Find line containing WORD
 Update arrayX with line number
Next x


//find second word and remember only lines already containing word 1
HE.PosLine(1)
For y = 1 to HE.LineCount
 Find line containing AnotherWORD
 If line number already in arrayX Then update arrayY with line number
Next y

// go to line containing both words, go 2 lines back, select whole line,
// go 6 lines down (to cover all related sentences), copy selection in background mode (still stay on current document)
For i = 0 to UBount(arrayY)
 If i > HE.PosLine() +2 THEN
   HE.PosLine(i) -2
 ELSE
   HE.PosLine(i)
 End IF
 enable line selection mode
 HE.PosLine(i) +6   //or For n=1To6 HE.ArrowDown
 Copy selection to Tab("xyz") in Background
 disable selection mode
Next i

Current selection mode = StoredSelectionMode


-------- or
Copy selection to clipboard,adding
Open new tab
paste

---------or
Write selection to %tmp%\tmp.tmp
Open new tab
Load ("%tmp%\tmp.tmp")




HE.PosLine(i) = set pos absolute
HE.PosLine() = get pos
HE.ArrowDown or HE.PosLine(+)  =  set pos relative
« Last Edit: October 07, 2009, 10:11:16 am by Stefan »

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Idea collecting: What i wanna do with scripting
« Reply #13 on: October 07, 2009, 03:50:34 pm »
Simple, but anyway here for an testing idea:

// Check for lines without <BR> at line end - and add <BR> on those lines

- Paste as HTML
- go pos 1
For i = 1 To HE.LineCount
  currLine = HE.WholeLineContent
  tmp = currLine
  Trim(tmp)
  Lcase(tmp)
  IF Not Right(tmp,4) = "
" Then
    HE.LineDelete
    HE.LineAdd(currLine) & " <BR>"
  // or maybe smtg like HE.LineAddAppend(" <BR>")
  End IF
Next

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Idea collecting: What i wanna do with scripting
« Reply #14 on: June 07, 2010, 02:33:35 pm »
Keep only one line of an hostname from an log file, and that has to be the last one in log (those one with newest time):

1) Transpose whole doc upside-down

2)
Till EOF
  For Each line
    Host = first alphanumeric chars till first coma
    If  InStr(HostArray, Host) Then
      delete line
    Else
     HostArray = HostArray & Host
    End If
  Next Line




Example Data

HostName-1, some dummy data, some dummy data, older date time 12:30
HostName-4, some dummy data, some dummy data, older date time 12:45
HostName-7, some dummy data, some dummy data
HostName-old1, some dummy data, some dummy data
HostName-1, some dummy data, some dummy data, newer date time 17:15
HostName-old9, some dummy data, some dummy data
HostName-4, some dummy data, some dummy data, newer date time 18:30
and 200 more




666
.


In the meantime i have done this need with an XYplorer script  (File manager from www.XYplorer.com):
Code: [Select]
$file = readfile("<curitem>");

   //sort lines upside-down:
   $count =1;
   $arrRev="";
   while(1)
   {
     $line = gettoken($file, $count, <crlf>);
     if ($line==""){break;}
     $arrRev = $line<crlf>$arrRev;
     incr $count;
   }
   //text $arrRev;


   //Collect only lines not already in $array:
   $file = $arrRev;
   $count =1;
   $array="";
   while(1)
   {
     $line = gettoken($file, $count, <crlf>);
     if ($line==""){break;}
     $token = regexreplace($line, "(.+?),.+", "$1");
     if (strpos($array, $token)== -1)
     {
       $array = $array$line<crlf>;
     }
     incr $count;
   }

   //Output:
   //text $array;
   writefile("<curitem>.clean.txt", $array, n);




Resulting in an new file based on the original name but added "clean.txt"
with this filtered line only (every hostname only onces):

HostName-4, some dummy data, some dummy data, newer date time 18:30
HostName-old9, some dummy data, some dummy data
HostName-1, some dummy data, some dummy data, newer date time 17:15
HostName-old1, some dummy data, some dummy data
HostName-7, some dummy data, some dummy data


Once available, i will rebuild this script with HE-script too.
« Last Edit: June 07, 2010, 06:26:28 pm by Stefan »

 

Related Topics

  Subject / Started by Replies Last post
7 Replies
6953 Views
Last post July 26, 2009, 10:40:08 pm
by alex
15 Replies
10732 Views
Last post April 21, 2009, 11:27:55 am
by Stefan
39 Replies
15736 Views
Last post April 22, 2010, 06:40:49 pm
by alex
2 Replies
4908 Views
Last post October 07, 2009, 01:50:53 pm
by alex
3 Replies
2617 Views
Last post November 30, 2011, 12:20:59 am
by alex