AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PSPad searchNgoto

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
doublebogey



Joined: 20 Oct 2005
Posts: 23

PostPosted: Tue Aug 29, 2006 9:43 pm    Post subject: PSPad searchNgoto Reply with quote

Hi all.

Rajat recently released
'Active GoTo'
And he has actually had the script for a while, so this is not new.
I was starting on this a few days before Active GoTo got a little kick along. And with some parts of Rajats code included, I managed to get mine off the ground

They both work similar, with searchNgoto as follows
-incremental search of text in lines
-listview of results
-Only made for PSPad as that is what I use.
-Auto update when changing Tabs
-Search for anything, '=' 'lv_' '(' 'Var'
-Just handy for a newbie like me.
-
Comments, Suggestions and Improvements all welcome.
(please, as still learning)

Thanks
dB

Code:
#Persistent
Version=PSPad searchNgoto v1c
; Use Win+TAB to start or refresh
; Escape to minimise
; Enter Key to Goto Line Number
; Double click to Goto
; Created by DoubleBogey, with some parts from Rajat
Process ,Priority,,High
SetBatchLines -1                                                                ;Run forrest, Run
SetKeyDelay -1
SetTimer Update, 1000                                                           ;refresh list every 1 Second
posiGui:=A_Screenwidth-285                                                      ;position Search box on Right side of Screen
Return
#Tab::                                                                          ;win + Tab is hotkey
  Gui, Destroy                                                                  ;Destroy any Existing Gui
  Gui, +AlwaysOnTop -Caption +Border +ToolWindow                                ;keep window ontop, take away Border, title bar thin
  Gui, Add, Text,     x4    y4    , Search for `:                               ;add text
  Gui, Add, Edit,     x+5  y2  w80  vSearchstring gSearchItems                  ;add edit box with Gosub
  Gui, Add, Text,   x+5  , Goto line
  Gui, Add, Edit, x+5 w40 Number vLineNumberedit ,
  Gui, Add, ListView, x2   y+5  w250 r30  vchoice gListBoxClick -Multi grid AltSubmit,  #|Line Text
  Gui, Add, Button, w0 h0 Default gHitEnter, OK
  Gui, add, StatusBar,,There are %CountLines% matching Lines. Escape to Exit    ;add Status bar to window
  Gosub SearchItems                                                             ;initial fill ListView
  Gui, Show, y120 x%posiGui%,   %Version%                                         ;show the Gui
Return

Update:
  WinGetTitle, WinTitle, PSPad - [                                              ;get the title of the current active window
  IfNotEqual, Wintitle, %titleold%                                              ;If the window title has changed, then
    {
      Titleold=%wintitle%                                                       ;make the window titles the same
      Gosub, SearchItems                                                        ;refresh the ListView
    }
Return                                                                          ;do not refresh the ListView
SearchItems:
  WinGetTitle, WinTitle, PSPad - [                                              ;get the title of the current active PSPad window
  WinGet, ThisWindowID, ID, %WinTitle%                                          ;Retrieves the specified window's unique ID
  StringTrimLeft, FileName, WinTitle, 9                                         ;trim 9 Spaces from the left
  StringTrimRight, FileName, FileName, 1                                        ;trim 1 Spaces from the Right
  StringRight, TheFileExt, FileName, 1                                          ;get the last letter of the File extension
  IfEqual, TheFileExt, *, StringTrimRight, FileName, FileName, 1                ;if the last letter is *, trim 1 from Right
  Gui Submit, NoHide                                                            ;dont hide Gui
  LV_Delete()                                                                   ;Destroys the current list in the ListView
  Loop, Read, %filename%                                                        ;Read the file
      IfInString, A_LoopReadline,%Searchstring%                                 ;if search =
        {
          x1=%A_LoopReadline%
          x1=%x1%                                                               ;remove whiteSpaces
          LV_Add("",A_Index,x1)                                                 ;add the line to list view
        }
  CountLines:=LV_GetCount()                                                     ;Count Lines in ListView
  LV_ModifyCol()                                       ;auto width columns
  SB_SetText("There are " . CountLines . " matching Lines.    Escape to Exit")  ;update the Status bar
  GuiControlGet, lastss, , searchstring                                         ;get the current value from the Input box
  If  searchstring <> %lastss%                                                  ;compare the current value against the end of loop
    {                                                                           ;- for any keypresses whilst loop running
      Goto, searchitems                                                         ;recompile search results if search string different
    }

Return
ListBoxClick:                                                                   ;if mouse clicked
  Gui Submit, NoHide
  If A_GuiEvent = DoubleClick                                                   ;doubleclick in Listview
    {
      LV_GetText(LineNumber,A_EventInfo,1)                                      ;Line Number = value of column1
      WinActivate, ahk_id %ThisWindowID%
      WinWaitActive, ahk_id %ThisWindowID%
      Send, ^g                                                                  ;the PSPad shortcut to Goto line window
      WinWaitActive, Goto Line                                                  ;wait until the Goto window is active
      Send, %LineNumber%{Enter}                                                 ;Send the lineNumber followed by Enter
    }
If A_GuiEvent = Normal                                                          ;singleclick in Listview
{
      LV_GetText(LineNumber,A_EventInfo,1)                                      ;Line Number = value of column1
      GuiControl, , LineNumberedit, %LineNumber%                                ;update the Number edit box
}

Return
Hitenter:                                                                       ;if the enter key is hit whilst search active
  Gui Submit, NoHide                                                            ;get all the values from the Gui
  WinActivate, ahk_id %ThisWindowID%
  WinWaitActive, ahk_id %ThisWindowID%
  Send, ^g                                                                      ;Send the lineNumber followed by Enter
  WinWaitActive, Goto Line                                                      ;wait until the Goto window is active
  Send, %LineNumberedit%{Enter}                                                 ;Send the lineNumber followed by Enter
Return


GuiEscape:
Gui,destroy                                                                     ;kill the GUI
return
GuiClose:                                                                       ;shut me down
  ExitApp





_________________
Everyone makes mistakes, that's why they put erasers on pencils. Milhouse, The Simpsons
Back to top
View user's profile Send private message
Rabiator



Joined: 17 Apr 2005
Posts: 289
Location: Sauerland

PostPosted: Wed Aug 30, 2006 5:55 am    Post subject: Reply with quote

Nice idea! Cool
A hint: Change lines 71 and 86 in
Code:
      WinWaitActive, ahk_class TfGotoLine                                       ;wait until the Goto window is active
to make it international.
Back to top
View user's profile Send private message
Rajat



Joined: 28 Mar 2004
Posts: 1687

PostPosted: Wed Aug 30, 2006 7:31 am    Post subject: Reply with quote

full script searching!... nice thing! Smile

Rabiator wrote:

A hint: Change lines 71 and 86 in
Code:
      WinWaitActive, ahk_class TfGotoLine                                       ;wait until the Goto window is active
to make it international.

that's a cool trick Rabiator! thanks!
_________________
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3910
Location: Bremen, Germany

PostPosted: Wed Aug 30, 2006 9:03 am    Post subject: Reply with quote

But that class has to be specified by the user for each editor. I guess it is more complicated then using title. At the same time it should be more robust.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Rabiator



Joined: 17 Apr 2005
Posts: 289
Location: Sauerland

PostPosted: Wed Aug 30, 2006 10:58 am    Post subject: Re: PSPad searchNgoto Reply with quote

doublebogey wrote:
-Only made for PSPad as that is what I use.
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3910
Location: Bremen, Germany

PostPosted: Wed Aug 30, 2006 11:07 am    Post subject: Re: PSPad searchNgoto Reply with quote

Rabiator wrote:
doublebogey wrote:
-Only made for PSPad as that is what I use.
I know, it was not against your comment, it was in direction of Rajat, because he added it to activegoto. Which was up to now more or less independent of the editor. And it was only ment as a remark not to offend.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Rabiator



Joined: 17 Apr 2005
Posts: 289
Location: Sauerland

PostPosted: Wed Aug 30, 2006 2:12 pm    Post subject: Re: PSPad searchNgoto Reply with quote

I don't feel offended at all ^^, I just didn't realize that your answer belonged to another thread, "Active GoTo v3". Wink
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group