small footprint 'text editor' program with command line ?

Discuss anything related to portable freeware here.
Post Reply
Message
Author
vmars316
Posts: 261
Joined: Thu Feb 09, 2012 11:47 am
Location: Colorado
Contact:

small footprint 'text editor' program with command line ?

#1 Post by vmars316 »

Hello & Thanks ,
Windows 10
I haven't figured out how to do this in Notepad ,
FIND and FINDSTR don't work for this , so :
Is there a small footprint 'text editor' program
that can be called from another program
passing to it a FIND 'text string'
so that it opens the *.txt file at that line ?

Thanks

vmars316
Posts: 261
Joined: Thu Feb 09, 2012 11:47 am
Location: Colorado
Contact:

Re: small footprint 'text editor' program with command line ?

#2 Post by vmars316 »

I am updating my app here:
clipLog/clipFind - The Portable Freeware Collection
And want to make it into a FULL Pim .
If I can't find an adequate 'text editor'
I'll have to write it myself .
Ugh!

User avatar
Midas
Posts: 6725
Joined: Mon Dec 07, 2009 7:09 am
Location: Sol3

Re: small footprint 'text editor' program with command line ?

#3 Post by Midas »

If going that way, there are plenty of dead FOSS projects you could probably fork... :|

appsuser
Posts: 136
Joined: Fri Feb 08, 2008 11:51 pm

Re: small footprint 'text editor' program with command line ?

#4 Post by appsuser »

Forgive me if I'm misunderstanding what you're looking for, but I often use AutoHotkey to supplement features I don't find in other programs. Wouldn't a small AutoHotkey program, working on Notepad or any text editor, do this just fine?

Seems there may be two ways to go about this. First, would be to start the text editor (notepad) and emulate the exact keystrokes you would normally use (like a macro). Second, would be to use AutoHotkey to search the text file, find the line number, then use a text editor that can open the text file to that line (like TED Notepad) .

vmars316
Posts: 261
Joined: Thu Feb 09, 2012 11:47 am
Location: Colorado
Contact:

Re: small footprint 'text editor' program with command line ?

#5 Post by vmars316 »

appuser :

Anyways , I get real close with this code in PureBasic :

Code: Select all

RunProgram("c:notepad.exe","","",0) 
w$="Untitled - Notepad" ; Specifies target window name. 
Delay(1000) : SendKeys(0,w$,"This is a test!") ; Type some dummy text. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}a{CONTROLUP}") ; Select it all. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}c{CONTROLUP}") ; Copy. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}f{CONTROLUP}") ; Find. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}v{CONTROLUP}") ; Paste. 
It works fine until
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}v{CONTROLUP}") ; Paste.

BUT it can't Paste into FIND box .
It always pastes into the text area .

Anyone know how to gain Focus and entry to the FIND box ?
I tried all kinds of combinations , but no go .

I was so close , but no-cigar :)
Thanks

appsuser
Posts: 136
Joined: Fri Feb 08, 2008 11:51 pm

Re: small footprint 'text editor' program with command line ?

#6 Post by appsuser »

This worked for me in AutoHotKey:

Code: Select all

SearchString = %1%
FilePath = %2%
SplitPath, FileName, OutFileName

Run, %windir%\system32\notepad.exe %FilePath%

WinActivate, "%FileName% - Notepad"
ControlFocus, "%FileName% - Notepad"

Sleep, 300

Send ^{f}

Send %SearchString%
Send {Enter}
Send {Alt down}{F4}{Alt up}
After compiling the script into an executable file, you get something like this:

AHKFind.exe %SearchString% %FilePath%

or, for example,

AHKFind "This is a test" %UserProfile%\Documents\test.txt

vmars316
Posts: 261
Joined: Thu Feb 09, 2012 11:47 am
Location: Colorado
Contact:

Re: small footprint 'text editor' program with command line ?

#7 Post by vmars316 »

Hmm...
Plz , how large is the program + Autokey overhead ?
Thanks

appsuser
Posts: 136
Joined: Fri Feb 08, 2008 11:51 pm

Re: small footprint 'text editor' program with command line ?

#8 Post by appsuser »

You don't need AutoHotKey after the script is compiled. The final binary executable is about 800KB.

vmars316
Posts: 261
Joined: Thu Feb 09, 2012 11:47 am
Location: Colorado
Contact:

Re: small footprint 'text editor' program with command line ?

#9 Post by vmars316 »

Well that sounds reasonable .
I will check it out .
Thanks

vmars316
Posts: 261
Joined: Thu Feb 09, 2012 11:47 am
Location: Colorado
Contact:

Re: small footprint 'text editor' program with command line ?

#10 Post by vmars316 »

Hmm...
Just needed to issue a sendkey to the "Find" window .
Works great , and compiles to 12kb .
Thanks

Code: Select all

RunProgram("notepad.exe","","",0) 
w$="Untitled - Notepad" ; Specifies target window name. 
Delay(1000) : SendKeys(0,w$,"This is a test!") ; Type some dummy text. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}a{CONTROLUP}") ; Select it all. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}c{CONTROLUP}") ; Copy. 
Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}f{CONTROLUP}") ; Find. 

Delay(1000) : SendKeys(0,"Find","{CONTROLDOWN}v{CONTROLUP}") ; Paste. 
w$="Untitled - Notepad" ; Specifies target window name. 

;Delay(1000) : SendKeys(0,w$,"{DELETE}")      ; Delete it. 
;Delay(1000) : SendKeys(0,w$,"{CONTROLDOWN}p{CONTROLUP}") 

Delay(1000) : SendKeys(0,w$,"This is a second test!") ; Type some dummy text. 

;Delay(1000) : SendKeys(0,w$,"{ALTDOWN}{F4}") ; Close the Notepad Window

Post Reply