Editing text areas with external editor?
Posted by: spremino
Date: September 04, 2009 07:00PM

Hello,

is there a K-meleon way to edit a text area with an external editor? That's what the It's All Text addon for Firefox does:

https://addons.mozilla.org/en-US/firefox/addon/4125

Thanks

Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 04, 2009 08:06PM

there's an extension called text archive which saves selected text portions in individual txt files.. the files are opened in kmeleon for reviewing but not in a text editior..you can easily open the file from their folder in your text editor of choice.

check it out:
http://kmext.sourceforge.net/ext4.htm

try it for now and i'll try to change the code to make an additional extension to open in notepad..or do you prefer selecting a text editor?

Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 04, 2009 09:00PM

archivedit:
http://kmext.sourceforge.net/files/archivedit.7z

opens selected text in notepad2(included) for editing.
notepad2 is an excellent editor as it accomodates both basic simple needs and script/coding requirements. if you don't like notepad2, you can use your editor of choice fby renaming your editor exe to notepad2.exe and copying it to k-meleon\tools\archivedit\ (replace original notepad2.exe)

Re: Editing text areas with external editor?
Posted by: JujuLand
Date: September 05, 2009 03:08AM

Quicknote does also the trick.

A+


Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:31.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/75.0

Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr




Re: Editing text areas with external editor?
Posted by: spremino
Date: September 07, 2009 06:39PM

Quote
disrupted
archivedit:
http://kmext.sourceforge.net/files/archivedit.7z

opens selected text in notepad2(included) for editing.

Thank you.

I've copied the content of the archive into K-Meleon installation directory, and I can see it among installed Macro Extensions. How am I expected to run it?

Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 08, 2009 04:18AM

rightclick on the selected text in kmeleon and from the context menu select the 'archive edit' command

Re: Editing text areas with external editor?
Posted by: spremino
Date: September 08, 2009 08:45PM

Done.

It fails with this cryptic message box (garbage characters included):

---------------------------
AutoIt Error
---------------------------
Line 7 (File "C:\Programmi\K-Meleon\k-meleon.exe"):

FÆE˜‰Ehœ'F

Error: Unterminated string.


---------------------------
OK
---------------------------

Any hint?

Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 09, 2009 01:48AM

it's weird because it is working fine here and this isn't even line 7 in the script.. the kmeleon path is not required and even if it would have been passed from the macro and not written in the script.

try this one..written from scratch instead of modifying text archiver:

http://kmext.sourceforge.net/files/archivedit.7z

works from the same menu-select text>archive edit

also try quicknote, it saves selected in text files which can be accessed from xul for editing

Re: Editing text areas with external editor?
Posted by: spremino
Date: September 09, 2009 03:25PM

Thank you very much, this works!

Could you please give me some directions to improve it further?

I've checked the .kmm file along with Macro Reference, but I don't understand how I could show the "Archive edit" menu item whenever I'm in a text area, no matter if there is selected text or not. If that cannot be achieved, always having the menu item shown would be enough. Moreover I'd like, once the file is modified and saved by the editor, to put the content back into the original text area and activate the foreground window.

Any suggestion? Thanks.

Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 10, 2009 12:13AM

i'll look into expanding it to add the contextmenu in other areas, however pasting back the edited text is not likely to happen.. they's no connection between the text editor and the kmeleon text field so kmeleon can't detect when you were really done editing and paste back the text for you (does the ff extension do that?)

an autoit script can monitor the text editor till its closed and paste back the text bu that means:
1- the autoit script has to copy the text continoustly while you're editing becuase it doesn't know when will you close the window (bad memory management)
2- autoit does not know where to paste the text in kmeleon, may paste in wrong fields causing problems
3- you might finish editing but decide to leave the text editor window open, autoit will not know it's time to paste back the text.

too many variables= too many potential bugs

what i think you need is a bbcode editor either implemented inside with a macro for that theres bbcode macro by desga (search the forum or macro resources) or opened externally: just download or use your bbcode editor of choice, tell us about it and we can make it open with a macro from within kmeleon. you can also try panzerpad plus extension available at the extensions page kmext.sf.net

Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 10, 2009 05:13AM

updated to display in text filed and open in notepad as you've requested.. download from same link


# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)

# ---------- edit selected text


$_archedit=getfolder(RootFolder)."\\Tools\\archivedit";

archivedit{
setclipboard("");
id(ID_EDIT_COPY);
exec($_archedit."\\archivedit.exe ");
}

archivfield{
setclipboard("");
id(ID_EDIT_SELECT_ALL);
id(ID_EDIT_COPY);
exec($_archedit."\\archivedit.exe ");
}

archivedit_BuildMenu{
setmenu(Selection,inline,t_chiver,4);
setmenu(t_chiver,macro,"Archive Edit",archivedit);
setmenu("TextPopup",macro,"Archive Edit",archivfield,3);
}

$OnInit=$OnInit."archivedit_BuildMenu;";
#-------------------------------------------
$macroModules=$macroModules."txtarchiveditor;";


; AutoIt Version: 3.3.0
; Language: English
; Platform: Win9x/NT
; Author: yanni

#NoTrayIcon
#Include <Clipboard.au3>
#Include <File.au3>


$textarchive=ClipGet()
$pendedit=(@tempdir & "\kmtextedit.txt")
$txteditor=(@scriptdir & "\notepad2.exe")
_FileCreate(@tempdir & "\kmtextedit.txt")

$defaultpath=(@ScriptDir)
FileWriteLine ($pendedit, "" )
FileWriteLine ($pendedit, $textarchive)
sleep(88)
$runner=($txteditor & " " & $pendedit)
run($runner)
exit


also check this thread
http://kmeleon.sourceforge.net/forum/read.php?1,88206,88435

Re: Editing text areas with external editor?
Posted by: panzer
Date: September 11, 2009 12:11PM

Quote
disrupted
archivedit:
http://kmext.sourceforge.net/files/archivedit.7z

opens selected text in notepad2(included) for editing.
notepad2 is an excellent editor as it accomodates both basic simple needs and script/coding requirements. if you don't like notepad2, you can use your editor of choice fby renaming your editor exe to notepad2.exe and copying it to k-meleon\tools\archivedit\ (replace original notepad2.exe)

It does not work with notepad++, portable Km 1.53.

Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 11, 2009 07:08PM

well..i'm not really surprised, not all programs can work by changing their paths and renaming the exec binary.. especially when they rely on other files like libraries or configurations, probably notepad++ is one of them.

it's supposed to be for basic text editing and notepad2 does a great job for that plus it's fairly more than adequate for most script editing.

for more professional scripts editing; there's the code tester extension which shell executes the code with its corresponding program as setup on the user's system. it can even embed the code (like js or php) in an html file if the user chooses that option.

Re: Editing text areas with external editor?
Posted by: spremino
Date: September 12, 2009 08:55PM

Quote
disrupted
i'll look into expanding it to add the contextmenu in other areas, however pasting back the edited text is not likely to happen.. they's no connection between the text editor and the kmeleon text field so kmeleon can't detect when you were really done editing and paste back the text for you (does the ff extension do that?)

Yes. I think it loops until you save the file and close it. Since Firefox macros are Javascript, you can loop using "setTimeout", that is: without blocking (I should check source code, but I haven't Firefox here). Could a K-Meleon macro loop without blocking?

I agree that a solution based on an external applications would be tricky.

Thank you very for your active help.

Re: Editing text areas with external editor?
Posted by: spremino
Date: September 12, 2009 08:59PM

Quote
disrupted
i'll look into expanding it to add the contextmenu in other areas...

Oh, no, thanks! External editing is only needed when in text areas. My only gripe was that I had to select some text for the context menu to show the macro. However, that's not important. I think that binding an accelerator to the macro would be enough.

Thank again.

Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 13, 2009 01:20AM

it's alright, i just added the command in same text field but when there is no selected text, it will automatcially select the text so you don't have to select text first.
i'll have to install that extension in firefox and understand how that loop works.. grr i hate javascript

thanks for your feedback spermino

Re: Editing text areas with external editor?
Posted by: panzer
Date: September 14, 2009 04:02PM

Quote
disrupted
well..i'm not really surprised, not all programs can work by changing their paths and renaming the exec binary.. especially when they rely on other files like libraries or configurations, probably notepad++ is one of them.

Well, I can always copy entire portable notepad++ into .kmm. Then it will work. smiling smiley



Edited 2 time(s). Last edit at 09/14/2009 04:03PM by panzer.

Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 14, 2009 11:38PM

yes that would probably work, copy notepad++ files to k-meleon\tools\archivedit folder and rename notepad++ to notepad2.. if you want to keep its name then edit in the autoitscript (archivedit.au3) change this statement:

$txteditor=(@scriptdir & "\notepad2.exe")
to
$txteditor=(@scriptdir & "\notepad++.exe")

and compile with autotit compiler
you will need atleast autoit 3.3.0

you can also keep notepad++ in it location and edit string to notepad++
$txteditor=("c:\where\notead++\isinstalled\path\notepad++.exe")

and compile script as archivedit.exe (replacing the original one)

Re: Editing text areas with external editor?
Posted by: JujuLand
Date: September 15, 2009 02:53AM

Hum,

I don't understand why you don't use inifile to set some parameters, and then have an autoit exe which can handle more parameters values.

Wouldn't it better ?

Same way for translation tongue sticking out smiley

A+


Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:31.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/75.0

Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr




Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 15, 2009 05:32AM

i add ini reading/writing functions when there's need to but this was originally just to answer's sperminito's request which personally i believe for his needs; desga's bbcode macro would;ve served better or even an external bbcode editor.. i use bbcode write by 'ahk german user' from ahk forums but we try to accommodate new users as much as possible so they don't feel the need to use that other gecko browser.. notepad2 is perfect for basic txt editing and even not-so-intense scripting , it also supports syntax schemes.

as for translation locales.......... well. you have to blame desga tongue sticking out smiley
it all started with a very simple autoit script i wanted for restarting km then things got out of hand after that and i never thought about locales and didn't even know theycan be included externally for autoit until quite recently i thought people just edit the source and compile or just use english. now i'm testing locales using jamesd km lister method and profile backup extension which does not have a lot to translate but i don't know german or french that good and i don't know spanish at all(except for pajero) and there are so many scripts now, most don't have many things to translate but even their accompanying km macros do not support locales.. all will need to be rewritten to include the locales.. it's going to take a while but eventually it will be done.. i hope sad smiley

Re: Editing text areas with external editor?
Posted by: desga2
Date: September 15, 2009 03:17PM

For Notepad++:
Quote
From Notepad++ website
Here's a little Notepad++ launcher which allows you to replace Notepad completely by Notepad++.

Installation Instruction:

* Backup your original Notepad.exe (we never know...).
* Copy notepad.exe which comes with this package into 4 directories (in given order) :
1. c:\windows\servicepackfiles\i386
2. c:\windows\system32\dllcache
3. c:\windows\system32
4. c:\windows
When you replace notepad.exe in c:\windows\system32 and c:\windows, a "Windows File Protection" message box appears, click Cancel. Then another message box appears, click OK.
* Modify you registry (if you use installer to install your Notepad++, you don't need to do this step): Create key \HKEY_LOCAL_MACHINE\SOFTWARE\Notepad++, then add your Notepad++ full path as the default value of this key. In my case, it's C:\Program Files\Notepad++.

Now Notepad++ is your default Notepad.

K-Meleon in Spanish

Re: Editing text areas with external editor?
Posted by: spremino
Date: September 16, 2009 03:12PM

Thank you very much, Disrupted, your updated plugin, which works as advertised!

My understanding is that the macro works by copying the text into clipboard, then running the editor and pasting text into it. It seems that you can't do better with what is available in K-Meleon's macro language. I've checked around the site, but it seems to me that K-Meleon's macro language lacks both a way to write non-blocking loops and a way to write files and detect modifications (maybe the latter absence is for security reasons, I've noticed that you can read a file, but not write one).

As for module configuration, my understanding is that K-Meleon targets users at ease with fiddling a bit with scripts.

Thank you again for your involvement.

Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 17, 2009 02:41AM

actually you can do lots of things with km macro language.. it's more advanced than you think and supports injecting jscript which makes it possible to convert some of ff extensions.. the problem is, that some(or many) js in ff extensions are coded to call certain services for ff which are not available in kmeleon..the trick is, recode the js functions to work properly in kmeleon which is not an easy task for a non-js dev. i'm not good at js, that's why i prefer writing equivalents with autotit because it's a language i can code in without having to pull my hair out.

i installed your addon in firefox and actually it's not very hard but again detested javascript..the main idea is; it creates a file(similar to what i did in autoit) and then waits for that file to be saved(this i did not do) so i took the concept and implemented it using autoit without the need for the js code.. i think it works pretty much the same as in ff now.

the context menu for selected text has been removed, you can only launch directly from text field without the need to select anything and select archivedit command



the text will be copied to a text file and opened in notepad2 now renamed to kmaredit.exe, the section(field) where the text edited will be copied to will change background colour to yellow so user kmows where the edited text will go


to ensure the user doesn't close kmeleon or do anything to mess up the procedure like switching tabs (foolproof), the kmeleon window gets disabled temporarily while kmaredit.exe is running, a popup notification will show at the bottom of the screen during edit mode notfying the user that km will be enabled when kmaredit is closed.. also for windows 2k and above, the km window will be set to a slight transparency so user knows it's disabled when transparent.


edit the text and close kmaredit or save and close.. in the end kmaredit must be closed so autoit knows it's time to paste the edited text.


e voila


download from same link
http://kmext.sourceforge.net/files/archivedit.7z

the drawback compared to the previous script is you can nlonger use your editor of choice and must only kmareditor.. don't rename the editor and put it in archivedit folder, only use the supplied kmareditor (notepad2)

sources:

# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)

# ---------- edit selected text

$_archedit=getfolder(RootFolder)."\\Tools\\archivedit";
$archivedcss=getfolder(RootFolder)."\\Tools\\archivedit\\archivedit.css";

archivfield{
setclipboard("");
injectCSS(readfile($archivedcss));
id(ID_EDIT_SELECT_ALL);
id(ID_EDIT_COPY);
exec($_archedit."\\archivedit.exe ");
}

archivedit_BuildMenu{
setmenu("TextPopup",macro,"Archive Edit",archivfield,4);
}

$OnInit=$OnInit."archivedit_BuildMenu;";
#-------------------------------------------
$macroModules=$macroModules."txtarchiveditor;";


; AutoIt Version: 3.3.0
; Language: English
; Platform: Win9x/NT
; Author: yanni

#NoTrayIcon
#include <GUIConstants E x.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#Include <Clipboard.au3>
#Include <File.au3>

$w=@DesktopWidth
$h=@DesktopHeight
$gw=$w - 260
$gh=$h - 60

$textarchive=ClipGet()
$pendedit=(@scriptdir & "\pendarch.txt")
$txteditor=(@scriptdir & "\kmareditor.exe")
_FileCreate(@tempdir & "\pendarch.txt")

$defaultpath=(@ScriptDir)
FileWriteLine($pendedit, "" )
FileWriteLine($pendedit, $textarchive)
sleep(88)
$runner=($txteditor & " " & $pendedit)
run($runner)
WinsetTrans("[CLASS:KMeleon Browser Window]", "", 188);
WinsetState("[CLASS:KMeleon Browser Window]", "", @SW_disable);
sleep(44)
$lockB = GUICreate("Archiveditmode", 280, 24, $gw, $gh, BitOR($WS_DLGFRAME, $WS_POPUP, $WS_EX_TOPMOST))
$Label1 = GUICtrlCreateLabel("Edit Mode: Please Close kmareditor when done. ", 8, 3, 278, 15)
WinSetOnTop("Archiveditmode", "", 1)
GUISetState(@SW_SHOW)
While 1
WinActivate("[CLASS:Scintilla]", "")
ProcessWaitClose("kmareditor.exe")
writeback()
WEnd

func writeback()
WinsetTrans("[CLASS:KMeleon Browser Window]", "", 255);
WinsetState("[CLASS:KMeleon Browser Window]", "", @SW_enable);
if process e xists("k-meleon.exe") then
BlockInput(1)
$shit=FileRead($pendedit)
ClipPut($shit)
WinActivate("[CLASS:KMeleon Browser Window]", "")
send("^a")
send("^v")
BlockInput(0)
sleep(40)
FileDelete($pendedit)
exit
else
FileDelete($pendedit)
exit
endif
endfunc
exit




K-Meleon forum is powered by Phorum.