Dear Hutch,
Many thanks for all your hard work with QEditor. It is, in short, a masterpiece. I'm no good with the mouse, and have been searching for a keyboard friendly editor. The speed is truly addictive and I really enjoy the ability to customise the menus. Your new blue look is very pleasing on the eye, especially with font selection. If this little gem was packaged up as QEditor5 (with word wrap) I'm sure we would see it on the "most loved editor" lists before long.
I have searched the MASM forum to read the posts about QEditor - it really deserves its own section.
After a bit of experimentation (QE ver 4.0g - all this in just 37,192 bytes!) I have a couple of questions:-
1. CRTL-M
If I start a new instance of QE and merge files into this unsaved document with the mouse all works well.
However if I use CTRL-M in an unsaved file I am asked to save the file.
If I answer either yes or no, I loose all the contents of the unsaved file.
No gives me a blank unsaved file, yes gives me a blank named saved file.
2. Get File
The menu editor has a very useful "Get File" function, preventing filename typos.
Is there any way to expose this in the editor and the scripting engine?
I found getfolder function, but sadly no getfile.
I would like to use QE as a general text editor, because it's portable, ultrafast, rock solid and programmable. As soon as I discovered QE4 I looked back at my collection of text editors to make a wish list of functions. I have been trying to write a number of these text manipulation functions as scripts (e.g. yankline, blockup, bullet, number, cutappend). This is proving more difficult than I expected.
As many people (like me) can't write plugins, is there any chance of an extension of the scripting environment? Sorry if this seems inappropriate for the MASM forum, but this is such a good editor I could not resist. With just a few more functions the scripting engine would be capable of almost all the common editing functions.
I know you have designed the software very carefully and wisely resisted many requests for feature creep. However I'm feeling brave...
1. Passing variables to the editor specific commands:
To manipulate text in the editor it is necessary to move the cursor depending upon the number of lines or characters in a string. This would allow scripts to reselect the text, and users to press F12 to repeat the action (e.g. Move a block of text up a line at a time). Would it be possible for these functions to accept an integer variable?
e.g. newline #1 - To insert a variable number of new lines
selectline #1 - Positive and negative
setsel #1 - Positive and negative
undo #1 - Positive and negative
left #1
right #1
up #1
down #1
back #1
2. Passing variables to the string functions.
In the same way as in the previous point, it would help to send integer variables to all the string manipulation functions.
e.g. $1 = Right$ $0 #1
$1 = Mid$ $0 MyStart MyLen
3. Passing variables to the arithmetic functions
I'm struggling to add two integer variables together, sorry:-
; Add two integer variables - fails.
#1 = len Word1$
#2 = len $0
#3 = add #1 #2
msgbox #3 "Result" MB_OK
4. New string function: lines
In order to loop through lines in a block of text, or reselect that block in the editor, it would be very helpful to have a "wickedly crafted" function to count the number of lines in any string variable.
e.g. lines $0 (returns #0 with the number of lines)
5. New string function: find
In order to extract a line at a time, or any other substring, scripts need to be able to extract start/stop points to feed into the updated mid$ function. A function to return the integer position, of the first character in the search string would enable this capability. It would need to accept an integer or integer variable for which occurrence to find. A return value of 0 indicates "string occurrence not found"
e.g. find $0 lf counter ; Finds the end of the line.
find $0 "<br>" 2
find $0 $1 1
I suspect this is not efficient once in a loop, but without investing in loop constructs it is the only way to get the job done.
6. New clipboard access functions: setclip and getclip
The view clipboard function is very useful, keeping a snapshot copy. The ability to "Cut Append" and "Copy Append" would also enhance functionality. To enable this in the scripting engine:
; Cut Append
STRING MyText$
; Cut the selection
cutsel
Mytext$ = $0
; Check if there is a selection
if$ Mytext$ = ""
end
; Get the clipboard
getclip
; Set the clipboard
setclip $0 Mytext$
; setclip should be able to add in literals, converted integer variables and supported C escapes
; e.g. setclip $0 "/n/t" Loop# Mytext$
end
7. New file functions: filename and reload
To allow external applications to act upon the text in the editor we need to save it, run the applications and then reload the text. The savefile function, with no parameters saves the current file. The openfile function does not appear to have the same default. I can't find a way to access the current file name "drive:/path/name.ext", could a simple function "filename" return this string?
; Spell check
savefile
filename
run P:\MyPrograms\EDITORS\Addins\Yourspell\YourSpell.exe $0 ; read below about passing variables
reload
8. Passing variables to run and exec
At present the run/exec functions do not accept parameters after the target file. Also they don't have access to the name of the current file. This would be really helpful for many enhancements, archiving/CVS/FTP/Spellchecking.
e.g. Sync with website
; Up-load a file
savefile
filename
exec P:\bin\FTPSync\FTPSync.exe $0 /FTPSYNCDATA:.. /FULL /QUIET
9. Word wrap
To attract the wider praise it deserves QE needs word wrap. Does the added code significantly degrade the performance of QE? Even when it is switched off? TopGun is great and offers wrapping, but no font selection, no custom menus and most importantly no scripting engine.
Please accept these suggestions from an someone who admires the work already done. After 20 y of playing with software (I'm a surgeon) this gem will be on my USB stick with or without any changes.
Kind Regards
Gavin
P.S. Below is a copy of my menu.ini some of the scripts don't work properly, but you get the idea of my personal "ideal editor". I have been using Autohotkey to translate hotkeys to menu navigation for QE. I hope you share my enthusiasm, QE has the potential to be a really useful customisable general editing environment.
[&Text]
&Delete line CTRL-SHIFT-Y,{e}\scripts\YankLine.qse
-
Cut &Append CTRL-ALT-X,{e}\scripts\CutAppend.qse ; incomplete
&Copy Append CTRL-ALT-C,{e}\scripts\CopyAppend.qse ; incomplete
-
Paste &Unformatted CRTL-SHIFT-V,{e}\scripts\pasteunformatted.qse ; uses external application
-
&View Clipboard CTRL-SHIFT-S,P:\MyPrograms\EDITORS\Addins\Clipboards\clipbrd.exe ; Would love to call your clipboard snapshot code from here.
-
&Filter... CRTL-ALT-F,P:\MyPrograms\EDITORS\Addins\TextFilter\TextFilter.exe "{a}" ; posh grep
&The Wordweb... CRTL-ALT-T,P:\MyPrograms\EDITORS\Addins\Wordweb\wordweb.qsc
-
&Spell check... CRTL-ALT-S,{e}\scripts\spellcheck.qse ; uses Yourspell - incomplete
Tidy &HTML...,P:\MyPrograms\EDITORS\Addins\HTMLTidyGUI\tidyGUI.exe -f "{a}" -c P:\MyPrograms\EDITORS\addins\HTMLTidyGUI\NoWrap.ini
W&3 Validate...,P:\MyPrograms\EDITORS\Addins\W3Validate\sp\validate.bat "{a}"
-
&Wrap on CTRL-SHIFT-W,{e}\scripts\wordwrap.qse ; incomplete
Wrap &off CTRL-SHIFT-U,{e}\scripts\unwrap.qse ; incomplete
[&Block]
&Indent PgDn,{e}\plugins\indentb.dll
&Outdent PgUp,{e}\scripts\outdent.qse ; incomplete
-
Trim &Whitespace CRTL-ALT-W,{e}\plugins\rtrim.dll
-
Dupli&kate CRTL-ALT-K,{e}\scripts\duplikate.qse ; incomplete
Shift &Up CRTL-ALT-U,{e}\scripts\lineup.qse ; incomplete
Shift &Down CRTL-ALT-D,{e}\scripts\linedown.qse ; incomplete
-
&Bullet CRTL-ALT-B,{e}\scripts\bullet.qse
&Number CRTL-ALT-N,{e}\scripts\number.qse
&Renumber CRTL-ALT-R,{e}\scripts\renumber.qse ; incomplete
-
&Modify ,{e}\plugins\blockp.dll
Comment &//,{e}\plugins\cblockc.dll
Comment Semi&colon,{e}\plugins\ablockc.dll
&Strip comments,{e}\scripts\StripComments.qse ; incomplete
-
More text &functions...,{e}\plugins\addmenu.dll
[&Insert]
&File... CRTL-ALT-I,{e}\scripts\loadfile.qse
-
File &name CRTL-SHIFT-N,{a}\scripts\insertfn.qse ; incomplete
&Get a file CRTL-SHIFT-G,{a} \scripts\getafn.qse ; incomplete
-
TA&B CRTL-SHIFT-I,{a}
&Character...,charmap.exe
&HTML Colour...,{e}\cpicker.exe
-
&Time F6,{e}\scripts\insertt.qse ; incomplete
&Date F7,{e}\scripts\insertd.qse ; incomplete
[&Project]
&Run file CRTL-SHIFT-R,{e}Shellex.exe "{a}"
Re&load file CRTL-SHIFT-L,{e}qeditor.exe "{a}" ; incomplete
&Compare with...,P:\MyPrograms\EDITORS\Addins\TextDiff\TextDiff.exe "{a}" ; incomplete
&Backup file... CRTL-SHIFT-B,P:\MyPrograms\EDITORS\Addins\Vbackup\Vbackup.exe {p} zVersions /IF {a} /NS /Q
-
Open &Directory... F5,{e}Shellex.exe "{p}"
&Text Viewer... CRTL-SHIFT-O,P:\MyPrograms\EDITORS\Addins\TextView\Textview.exe "{a}"
&Search Directory... CRTL-SHIFT-G,P:\MyPrograms\EDITORS\Addins\Astrogrep\Astrogrep.exe "{p}"
-
Load Binary File As Hex,{e}\plugins\bin2hex.dll
Save Hex File As Binary,{e}\plugins\hex2bin.dll
[S&cripts]
&Run a Script SHIFT-F12,{e}\scripts\runscript.qse ; incomplete - can't call a script from a script!
Re&peat script F12,{e}\scripts\repeat.qse ; incomplete
-
Open &Directory,{e}Shellex.exe {e}\scripts
-
Insert &Text as Script,{e}\plugins\txt2qse.dll
Insert &Binary as Script,{e}\plugins\bin2qse.dll
[E&xtras]
Activate &Keys,P:\MyPrograms\DEV\AutoHotKey\AutoHotkey.exe {e}Qeditor.ahk
&Define Keys,{e}qeditor.exe {e}Qeditor.ahk
-
&Google search...,{e}prun.exe "http://www.google.com/search?"
-
&WinSorter...,P:\MyPrograms\EDITORS\Addins\winsorter\winsorter.exe
Multiple &Clipboards..,P:\MyPrograms\EDITORS\Addins\Clipboards\Clipboards.exe
[&Desktop]
&Cascade QE,P:\MyPrograms\SHELLS\Addins\vDesktop\TileWindows.exe -c
Tile &Vertical,P:\MyPrograms\SHELLS\Addins\vDesktop\TileWindows.exe -v
Tile &Horizontal,P:\MyPrograms\SHELLS\Addins\vDesktop\TileWindows.exe -h
-
&Show desktop,{e}shellex.exe P:\MyPrograms\SHELLS\Addins\showDesktop.scf
&Multiple desktops ALT-X,P:\MyPrograms\SHELLS\Addins\vDesktop\desktops.exe /accepteula
[Help]
&Editor Help,{e}\help\qeditor.chm
Hot &Key Help CRTL-SHIFT-K,{e}Shellex.exe {e}\help\QEKeys.xls
Set F1 help file CRTL-SHIFT-H,{a}
-
Help &Directory,{e}Shellex.exe {e}\help
-
MASM Site,{e}prun.exe "http://www.masm32.com/board/index.php"
Gavin,
Certainly an interesting read but a harder task than you may think. QE is coded in MASM to get the necessary precision and while it is intentionally plain in terms of its interface, it is a nightmare under the hood because of the complexity it must manage. The later scripting engine "QSE" lives in a DLL of its own and the guts of it are a true joy to behold as it must both parse the script fast enough then run its commands. For obvious reasons I am very wary of trying to post modify it but in its original design it can both run external DLLs as well as QE plugins and it supports a reasonably large number of Windows API function that can be called in a couple of different ways. What I do if I need additional capacity that cannot be done in a viable manner with the script commands is write a DLL that receives any of the handles required for QE components (edit window, main window, toolbar etc ....) and then write the DLL to do what is required.
The basic design excludes wordwrap as wordwrap would interfere with many of the text functions as well as the autoindent, QE is specifically a code editor in this sense where wordwrap would mess up the formatting of source code. I supply TopGun for any who need that characteristic. I had a quick look at the code and the Ctrl+M is coded correctly but it does not work correctly so I will have to track down whatever is broken there and fix it.
Its 2am here and I am not far off brain dead o let me have a look at a number of things when I am awake enough to make sense of it.
Not sure if this will work to you Gavin, but worked here (XP). It's a plugin to wrap,unwrap. But, have some time that I do not program DLL's, so in my opinion, is better wait some experienced programmer take a look at this and say something or change something. So, do it at your own risk.
Dear Mineiro,
:U Many thanks this works well for me on XP, I will test on Vista and Win 7 over the next few days.
It feels like Christmas has come early!
Kind Regards
Gavin
Hi,
I have used AutoHotkey to add custom keyboard shortcuts to QE (www.autohotkey.com) . Please find below a script that only sends keys to QE4. It can be altered to suit all needs :bg.
; This AutoHotkey file serves to interpret between custom control keys, and the inbuilt/menu keys of QE
; The following line directs the hotkeys only to qe4 windows
#IfWinActive ahk_class qe4_class
; &Text Menu
^+y::SendInput !td
^!x::SendInput !ta
^!c::SendInput !tc
^+v::SendInput !tu
^+s::SendInput !tv
^!f::SendInput !tf
^!t::SendInput !tt
^!s::SendInput !ts
; ::SendInput !th
; ::SendInput !t3
^+w::SendInput !tw
^+o::SendInput !to
; &Block Menu
; ::SendInput !bi
; ::SendInput !bo
^!w::SendInput !bw
; Inbuilt ::SendInput !bf
^!k::SendInput !bk
^!u::SendInput !bu
^!d::SendInput !bd
^!b::SendInput !bb
^!n::SendInput !bn
^!r::SendInput !br
; ::SendInput !bm
; ::SendInput !b/
; ::SendInput !bc
; ::SendInput !bt
; &Insert Menu
^!i::SendInput !if
^+n::SendInput !in
^+g::SendInput !ig
; ::SendInput !ib
; ::SendInput !ic
; ::SendInput !ih
; Inbuilt ::SendInput !it
; Inbuilt ::SendInput !id
; &Project Menu
^+r::SendInput !pr
^+l::SendInput !pl
; ::SendInput !pc
^+b::SendInput !pb
F5::SendInput !pd
^!v::SendInput !pt
^!g::SendInput !ps
; S&cripts
+F12::SendInput !cr
; Inbuilt ::SendInput !cl
; Inbuilt ::SendInput !cp
^F12::SendInput !cd
; T&ools
;::SendInput !ok
;::SendInput !od
;::SendInput !og
;::SendInput !ob
;::SendInput !ow
; &Desktop
; ::SendInput !dc
; ::SendInput !dv
; ::SendInput !dh
; ::SendInput !ds
!x::SendInput !dm
; ::SendInput !db
/*
Full keyboard mapping
Key Control Function Encoding Script
F1 ContextHelp QE Code
F2 Find QE Code
F3 FindNext QE Code
F4 Replace QE Code
F5 RunDlg QE Code
F6 InsertDate QE Code
F7 InsertTime QE Code
F8 Run Makeit.bat QE Code
F9 ToggleAutoIndent QE Code
F10 ActivateMenu QE Code
F10 CTRL ActivateMenu QE Code
F11 Explore QE Code
F12 RepeatScript QE Code
F12 SHIFT RunScript Wishlist
F12 CTRL Set/CreateDirectory QE Code
A CTRL SelectAll QE Code
B CTRL Backup QE Code
C CTRL Copy QE Code
D CTRL DOSShell QE Code Would be nice to specify shell (e.g. bash.exe)
E CTRL Free Free
F CTRL LeftTrim (&Flush) QE Code
G CTRL Gotoline QE Code
H CTRL Free Free
I CTRL NewInstance QE Code
I CTRL-SHIFT InsertTAB QE Code
J CTRL Free QE Code
K CTRL Alt Spell Check Application Yourspell
L CTRL LowerCase QE Code
M CTRL MergeFile QE Code
N CTRL NewFile QE Code
O CTRL OpenFile QE Code
P CTRL PrintFile QE Code
Q CTRL SaveallandClose QE Code
R CTRL ReverseText QE Code
S CTRL Save QE Code
T CTRL ToggleSelectionbar QE Code
U CTRL UpperCase QE Code
V CTRL Paste QE Code
W CTRL OpeninNewWindow QE Code
X CTRL Cut QE Code
Y CTRL Redo QE Code
Z CTRL Undo QE Code
Back CTRL LoadScript QE Code
ESC Exit QE Code
Del Delete QE Code
PgUp CTRL Indent QE Code
PgDn CTRL UnIndent QE Code
A CTRL-SHIFT SortAscending QE Code
B CTRL-SHIFT Backup Application Vbackup
C CTRL-SHIFT EditColors QE Code
D CTRL-SHIFT SortDes QE Code
E CTRL-SHIFT EditMargins QE Code
F CTRL-SHIFT EditFonts QE Code
G CTRL-SHIFT GetFileName WishList
H CTRL-SHIFT EditHelp QE Code
J CTRL-SHIFT Free Free
K CTRL-SHIFT ViewHotkeys Excel ..\help\QEKeys.xls
L CTRL-SHIFT Reload WishList
M CTRL-SHIFT EditMenus QE Code
N CTRL-SHIFT PasteFileName WishList
O CTRL-SHIFT Wrap Off QE DLL
P CTRL-SHIFT Free Free
Q CTRL-SHIFT Free Free
R CTRL-SHIFT RunFile Application Shellexec
S CTRL-SHIFT Clipboard QE Code
T CTRL-SHIFT EditTabs QE Code
U CTRL-SHIFT Unwrap QE DLL Thanks to Mineiro
V CTRL-SHIFT Paste Unformmated Script+App
W CTRL-SHIFT Wrap QE DLL Thanks to Mineiro
X CTRL-SHIFT Free Free
Y CTRL-SHIFT CutLine Script ..\script\YankLine.qse
Z CTRL-SHIFT Free Free
A CTRL-ALT Free Free
B CTRL-ALT &Bullets Script ..\scripts\bullet.qse
C CTRL-ALT Copy&Append WishList
D CTRL-ALT Shift&Down Script ..\scripts\LineDown.qse - unfinished
E CTRL-ALT Free Free
F CTRL-ALT &Filter Application TextFilter
G CTRL-ALT (&Grep) Application AstroGrep
H CTRL-ALT Free Free
I CTRL-ALT &File Script ..\script\loadfile.qse
J CTRL-ALT Free Free
K CTRL-ALT Dupli&kate Script ..\scripts\Duplikate.qse - unfinished
L CTRL-ALT Free Free
M CTRL-ALT Free Free
N CTRL-ALT &Number Script ..\scripts\number.qse
O CTRL-ALT &TextViewer Application TextViewer
P CTRL-ALT Free Free
Q CTRL-ALT Free Free
R CTRL-ALT &Renumber WishList
S CTRL-ALT &SpellCheck Application Yourspell
T CTRL-ALT &TheWordweb Script ..\script\wordweb.qsc
U CTRL-ALT Shift&Up Script ..\scripts\LineUp.qse - unfinished
V CTRL-ALT Free Free
W CTRL-ALT Right&Trim Plugin Rtrim.dll
X CTRL-ALT CutAppend WishList
Y CTRL-ALT Free Free
Z CTRL-ALT Free Free
The unfinished scripts are mainly due to an inability to reselect the text after undertaking an action.
Reselecting text would allow that action to be repeated F12!
The items on the wishlist are on hold.
*/
As you can see there are some functions I am unable to code in the scripting engine (marked unfinished or "wishlist"). I considered using AHK to do these manipulations, but that approach would not allow use of F12 to repeating the action.
Once again many thanks to Hutch for showing what can be achieved with wickedly crafted code!
Kind Regards
Gavin
PS The text wrapping DLL works on all the systems I have tried - Many thanks Mineiro
Hi Gavin,
The Ctrl+M was easy to fix, it was a typo. VK_M when it should have been VK_N which is why you got a new file when you used the key combination for Merge. Seems to work OK now. See if there are any other problem specific to the editor and I will try to solve any of those as well.
The script engines are both external DLLs that are loaded on call and QE stores the last request to either script engine so that F12 repeats the request. Its a shame you are not into writing DLLs as the plugin interface can do just about anything as it has direct access into all of the QE interface component handles.
RE: some of the script requirements, you should be able to do many of them using the "Editor Specific Commands" in the help file.
I have attached the fixed version of QE with Ctrl+M working correctly.
Here is how to do the ADDs in QSE. Both the add and sub work like assembler notation, not by assignment.
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
STRING word1$ ; allocate 2 named strings
STRING word2$
word1$ = "12345" ; write text to them
word2$ = "67890"
; --------------------------------
; How to add two integer variables
; --------------------------------
#1 = len word1$ ; get 1st string length
#2 = len word2$ ; get 2nd string length
add #1 #2 ; add value #2 to #1
num2str #1 $125 ; convert result to a string
msgbox $125 "Result" MB_OK ; display it in a message box
end
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Dear Hutch,
Many thanks for releasing a fix. I am grateful for your commitment to maintaining QE. I will enjoy experimenting and will watch for future releases.
Kind Regards
Gavin
Dear Hutch,
I have been using QE as my main editor and crave your indulgence on a couple of points.
1. Word selection: If I double click on the first word on a line the selection includes the preceding EOL. Is this a planned extension of the selection? I find it makes cutting or dragging the first word of a line a bit messy.
2. CTRL-I: I would like to set my tab spaces to match the width of the tab character. Is this related to the font size or is there a magic number I can set so they match up?
Kind Regards
Gavin