Extensions :  K-Meleon Web Browser Forum
All about K-Meleon extensions. 
Pages: 12Next
Current Page: 1 of 2
Editing text areas with external editor?
Posted by: spremino
Date: September 04, 2009 12: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

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 04, 2009 01: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?

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 04, 2009 02: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)

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: JujuLand
Date: September 04, 2009 08:08PM

Quicknote does also the trick.

A+



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


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



Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc



Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: spremino
Date: September 07, 2009 11:39AM

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?

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 07, 2009 09:18PM

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

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: spremino
Date: September 08, 2009 01: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?

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

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

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: spremino
Date: September 09, 2009 08:25AM

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.

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 09, 2009 05:13PM

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

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 09, 2009 10:13PM

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://kmeleonbrowser.org/forum/read.php?1,88206,88435

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: panzer
Date: September 11, 2009 05:11AM

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.

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 11, 2009 12: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.

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: spremino
Date: September 12, 2009 01: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.

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: spremino
Date: September 12, 2009 01: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.

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 12, 2009 06:20PM

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

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: panzer
Date: September 14, 2009 09:02AM

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 09:03AM by panzer.

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 14, 2009 04: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)

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: JujuLand
Date: September 14, 2009 07:53PM

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:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0


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



Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc



Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 14, 2009 10:32PM

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

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: desga2
Date: September 15, 2009 08:17AM

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

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: spremino
Date: September 16, 2009 08:12AM

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.

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: disrupted
Date: September 16, 2009 07:41PM

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("[CLASSconfused smileycintilla]", "")
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




Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: rodocop
Date: February 11, 2016 07:18PM

Updated this old good extension - now it supports UTF editing (old version pasted a gibberish instead cyrillics for example).

AutoIt part still has some problems with non-latin text - sometime it inserts 'av' instead the edited text (it ignores '^' for 'Ctrl'-modifier in these cases and I cannot find the reason).

But you always can press CTRL+A,C by yourself here to paste manually.

It would be great if the author comes back to help me fix autoit script.

Also I've changed the context menu item from 'Archive edit' to 'External edit' to reflect what it does better.

And more - I have 2 versions;
- first with updated Notepad2
and second one
- with portable Notepad++ (yes, it works too!). But every of them requires its own au3-script and compiled exe (though I think it can be combined into 1 'if-then' cycle for a number of possible editors later).

Please try it and post your thoughts!



Edited 2 time(s). Last edit at 02/11/2016 07:19PM by rodocop.

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: JamesD
Date: February 17, 2016 07:02PM

Quote
rodocop
James, couldn't you help me if possible with AutoIt code in the archivedit extension that I'm trying to revive?

I will be happy to try. I am not an Autoit expert. What statement do you suspect causes the wrong letters?

Note: I need your help with the listbox locales file in Russian. I sent you an e-mail.

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: rodocop
Date: February 17, 2016 09:00PM

Mail is replied now.

About this case. Let's take only last function:
func writeback()
Opt("SendKeyDelay", 10) ;5 milliseconds
Opt("SendKeyDownDelay", 10) ;50 millisecond
WinsetTrans("[CLASS:KMeleon Browser Window]", "", 255);
WinsetState("[CLASS:KMeleon Browser Window]", "", @SW_enable);
if processexists("k-meleon.exe") then
BlockInput(1)
$shit=FileRead($pendedit)
ClipPut($shit)
WinActivate("[CLASS:KMeleon Browser Window]")
send("^a", $SEND_DEFAULT)
send("^v", $SEND_DEFAULT)
BlockInput(0)
sleep(100)
FileDelete($pendedit)
exit
else
FileDelete($pendedit)
exit
endif
endfunc
exit

It should activate K-Meleon window and send there Ctrl+A and Ctrl+V commands to paste edited text from clipboard to input field.

But time to time - according to very strange rules (not always!) and only if it touches cyrillic input - it pastes just 'av' string instead clipboard contents.

Thus it sends just plain 'a' and 'v' keystrokes instead Ctrl+A and Ctrl+V!

I've tried to change the rules for key sending (Opt lines) with adding bigger delay. I've tried $SEND_DEFAULT.

But no luck...

I'm lost here as I cannot guess why it behaves so. Maybe you could?

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: JamesD
Date: February 17, 2016 10:25PM

Possible it is covered by this statement from my Autoit help file.

There are a few parts of AutoIt that don't yet have full Unicode support. These are:

Send and ControlSend - Instead, Use ControlSetText or the Clipboard functions. 
Console operations are converted to ANSI.

My Autoit may be old. It is v3.3.12.0.

And it may be as simple as this for the 'send' statement.
To send UNICODE characters enter the character code (decimal or hex), for example this sends a Chinese character
    Send("{ASC 2709}") or Send("{ASC 0xA95}")



Edited 1 time(s). Last edit at 02/17/2016 10:32PM by JamesD.

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: rodocop
Date: February 18, 2016 12:17AM

I think so too as AutoIt wasn't actively developed after your version (current is 3.3.14 as I can recall).

And I have read that statement. But I think that modifier keys (like Ctrl) handlers cannot be treated as Unicode or something else in terms of encoding...

Well, let's use what we have. Better than nothing for those who needs it.

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: JamesD
Date: February 18, 2016 12:45PM

I now think it has something to do with which language was selected just prior to using both your extension and my extension for KMListBox.

Here is what I tried and the results for KMListBox:

Set language in Preferences to German. No restart = see German
Set language in Preferences to Russian. No restart = see Russian
Restart KM and now I get underscores where before I had Russian. I also see underscores for Troubleshooting in the Help menu and I went back to English without a restart to do this post.

Quote
rodocop
But time to time - according to very strange rules (not always!) and only if it touches cyrillic input - it pastes just 'av' string instead clipboard contents.

Suggest you test external editor extension in the same way that I tested KMListBox. If wrong characters happen in same situation, then maybe it is a KM problem.

Options: ReplyQuote
Re: Editing text areas with external editor?
Posted by: rodocop
Date: February 18, 2016 04:29PM

This is a known effect of l10n in KM since it learns to switch GUI lang without restart:

some menu items, provided directly by macros (not all macros - we need to understand which exactly), don't switch to new lang till restart.

So your test says that something is wrong in how your system handles macros encoding.

P.S. macros that behave so found by me are troubleshooting.kmm, useragentmode.kmm, xpinstallext.kmm and Paste and Search macro.

Options: ReplyQuote
Pages: 12Next
Current Page: 1 of 2


K-Meleon forum is powered by Phorum.