Author Topic: About the Joy of Writing an Editor  (Read 636 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13284
  • Assembly is fun ;-)
    • MasmBasic
About the Joy of Writing an Editor
« on: October 03, 2022, 10:12:25 PM »
I use SciTE for almost everything.
It seems to be all the rage to create yet another editor for assembly code, so here's mine.
Oh, yeah I've got SimplEd. A dialog box based richedit editor. Have made a lot of additions and enhancements to it, mostly for formatting code in my particular (peculiar?) style.
Code editors are like girlfriends, you pick what you like if it works for you. QE is a pure ASCII editor, programmable menus
TinyIDE is a 7.0 kBytes editor that offers a little bit more than Notepad, at least to the assembler programmer :biggrin:

Many of our members have programmed their own editor. Recently I got seriously p*ssed of because when I typed e.g. myDword in the find box, the listbox said "no matches". So I had to click on "Case" to make the search case-insensitive.

One click too much for my taste, so I opened the source and fixed the problem (solution: if there are no matches, I relaunch the find in case-insensitive mode, pick the first match, correct the find box to MyDword and relaunch in case-sensitive mode). So from now on, I'll find matches for wm_command even if the search mode is case-sensitive.

Of course, it took me some time to dig through code that I hadn't touched for years, but the joy of making that beast obey to my wishes was worth every minute I spent on this :tongue:

Below a screenshot (taken a few minutes ago) of my very first editor, written over 30 years ago. It had permanent bookmarks (I couldn't live without, I even had them in MS Word), a sophisticated listbox showing search matches, embedded graphics, and even a plot function. The screen and printer drivers were mine, programmed in 68000 Assembly. The less demanding parts I wrote in GfaBasic. I wrote and printed a whole book with this editor, and a renowned publisher took the photocopies "as is" to publish the book.

Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.

HSE

  • Member
  • *****
  • Posts: 2257
  • AMD 7-32 / i3 10-64
Re: About the Joy of Writing an Editor
« Reply #1 on: October 03, 2022, 11:16:34 PM »
Ambar monitor?
Equations in Assembly: SmplMath

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13284
  • Assembly is fun ;-)
    • MasmBasic
Re: About the Joy of Writing an Editor
« Reply #2 on: October 03, 2022, 11:20:48 PM »
Ambar monitor?



By far the best black and white monitor of the 1990ies. My screenshot is taken from the Steem emulator, though.
Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.

zedd151

  • Member
  • *****
  • Posts: 1583
Re: About the Joy of Writing an Editor
« Reply #3 on: October 03, 2022, 11:32:07 PM »
Ich spreche kein deutsch :tongue:  "I don't speak German"
I've failed my German language tutoring by our neighbor Mrs. Kuckla (when I was a tot). But google I think does a fair job.
Nugget and Gypsy Youtube channel. New videos twice a week or so. If you like the videos, please subscribe and comment.  :biggrin:

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13284
  • Assembly is fun ;-)
    • MasmBasic
Re: About the Joy of Writing an Editor
« Reply #4 on: October 04, 2022, 12:56:33 AM »
Btw where is your SimpleEd? Did you post it somewhere?

Oh, yeah I've got SimplEd. A dialog box based richedit editor. Have made a lot of additions and enhancements to it, mostly for formatting code in my particular (peculiar?) style. Another one that is the base code for one of my plugin builder (for qeditor) programs, and a coupla two or three more editors that are less noteworthy unless I've already sent them to the circular file
Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.

zedd151

  • Member
  • *****
  • Posts: 1583
Re: About the Joy of Writing an Editor
« Reply #5 on: October 04, 2022, 03:39:52 AM »
Oh no, I'd never post THAT code (SimplEd). At least in its current form.  :tongue:
I  could clean it up a bit and also use more standard functions where I thought I had better alternatives at the time. Some of that code is rather clunky for lack of a better term. It all works though, so I keep it for writing code for qeditor plugins as it has its own plugin interface.  :biggrin:
I have also renamed it some time ago to "Plugin Tester". After I finish my current project I'll look into making it 'ready for the masses' (clean it up and add some comments when needed) and post it for anyone interested.
edited to add:
Found a semi-usable version of SimplEd. Will post it later today if I have the time to clean it up a bit and add some comments. Look for it in a thread near you.  :cool:

Here --> SimpleEd
« Last Edit: October 04, 2022, 05:28:41 AM by zedd151 »
Nugget and Gypsy Youtube channel. New videos twice a week or so. If you like the videos, please subscribe and comment.  :biggrin:

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13284
  • Assembly is fun ;-)
    • MasmBasic
Re: About the Joy of Writing an Editor
« Reply #6 on: October 06, 2022, 07:18:21 PM »
Some basic features I expect from an editor ;-)



See the "a" to the upper right of the Find: box? That's the edit history, my MFUF (Most Frequently Used Feature). I rarely use the arrows to the left and right, because the keyboard shortcut is easier to use: Alt right arrow.

Let's say I work on an invoke line, and I need a variable name from a different location. I click on the bookmark that takes me there, copy the name, and then hit Alt right arrow. A millisecond later I can paste it directly to complete the edit.
Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13284
  • Assembly is fun ;-)
    • MasmBasic
Unicode bookmarks
« Reply #7 on: October 08, 2022, 11:22:56 AM »
The new feature needs some more testing, but I am confident that I can release it in the coming week :tongue:

Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.

NoCforMe

  • Member
  • ****
  • Posts: 854
Re: About the Joy of Writing an Editor
« Reply #8 on: October 08, 2022, 12:42:32 PM »
By far the best black and white monitor of the 1990ies.

Um, sorry, no: that would have been the Wyse grayscale monitor I had on my (work) desktop in the very late 1980s. Forget the resolution but the display was gorgeous. It could also be turned on its side for portrait mode. Great piece of gear.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13284
  • Assembly is fun ;-)
    • MasmBasic
Better word selection
« Reply #9 on: October 10, 2022, 09:25:56 PM »
It has bugged me for a while that after clicking on some$, SPI_GETWORKAREA or EM_EXSETSEL I had to manually correct the selection to get the missing red bits selected. So, inspired by Z's editor thread, I solved the little problem :tongue:

Code: [Select]
  .elseif uMsg==WM_LBUTTONDBLCLK
  call GetTickCount
  mov LbDbl, eax
or ReDblClk, -1 ; a global variable
  .elseif uMsg==WM_LBUTTONUP
.if ReDblClk
and ReDblClk, 0
sm hRE, EM_EXGETSEL, 0, addr txrg
mov eax, txrg.chrg.cpMax
.if eax>txrg.chrg.cpMin ; seltyp==SEL_MULTICHAR doesn't work
sub txrg.chrg.cpMin, 5
inc txrg.chrg.cpMax ; include the character after the end of the selection
lea esi, tmpBuffer
mov txrg.lpstrText, esi
sm hRE, EM_GETTEXTRANGE, 0, addr txrg
lea edx, [esi+4]
xor ecx, ecx ; flag
.if byte ptr [edx]=="_"
inc ecx ; cpMin was decreased
.Repeat
    dec txrg.chrg.cpMin
    dec edx
.Until edx==esi || byte ptr [edx]<"A"
.endif
add txrg.chrg.cpMin, 5
mov eax, txrg.chrg.cpMax
sub eax, txrg.chrg.cpMin
inc ecx
.if byte ptr [esi+eax+2]!="$"
dec txrg.chrg.cpMax
dec ecx
.endif
jecxz @F
invoke SendMessage, hRE, EM_EXSETSEL, 0, addr txrg
@@:
.endif
.endif

if 0         ; timings for double-click correction
         16 µs for selecting MoveWindow
         18 µs for selecting null
         16 µs for selecting ecx,
         18 µs for selecting RECT.
         18 µs for selecting bottom]
         3670 µs for selecting some$
         2353 µs for selecting GETWORKAREA
endif
Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13284
  • Assembly is fun ;-)
    • MasmBasic
Re: About the Joy of Writing an Editor
« Reply #10 on: October 20, 2022, 06:52:30 AM »
For the curious, this is the plugin-related section of \Masm32\MasmBasic\Res\MenusRM.ini:

Code: [Select]
[System & Plugins] ; heading
Calculator,calc.exe ; entry
Control Panel,control.exe
Notepad,notepad.exe
Freecell,Freecell.exe ; spaces can be used
-
Import C structure§Converts MSDN structure on\nclipboard to Masm syntax,Plugins\Cstruct2Asm.exe
Find on disk VC§Find files containing\ntwo different strings in C headers,Plugins\FindOnDiskVC.exe #
Find on disk M32§Find files containing\ntwo different strings in Masm32 includes,Plugins\FindOnDisk.exe #
-
#plugins#

[&Help]

Exactly, it's the #plugins# line that makes you see Calculate selection and the Select e.g. '100/4+3' ... tooltip :cool:

(the technique is described here, replies #152 and #154)
« Last Edit: November 11, 2022, 01:05:59 PM by jj2007 »
Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13284
  • Assembly is fun ;-)
    • MasmBasic
About the Joy of Writing an Editor: Table of Contents
« Reply #11 on: October 23, 2022, 08:09:49 PM »
A little luxury for myself: With one click, I get the most relevant matches for a variety of issues. After 14 years of coding for the editor, I don't always remember where I treated certain issues. So I created the TOC option, and it really helps me to find my way in this 24,000 lines monster :tongue:

Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13284
  • Assembly is fun ;-)
    • MasmBasic
Re: About the Joy of Writing an Editor
« Reply #12 on: November 11, 2022, 01:07:54 PM »
I had the bright idea to allow true Unicode bookmarks, for our Chinese, Russian or Arabic friends who want to write their comments in their own language.

The good news: It works, see below :biggrin:

The bad news: In order to achieve this little feature, I had to change from RichEdit20A to RichEdit20W, and from RichEd20.dll to MsftEdit.dll - and that's a nightmare if your code is over 23k LOC (see also RichEdit wrap).

After numerous nights of bug chasing and fixing, RichMasm is now stable enough to be released - get it here.

Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13284
  • Assembly is fun ;-)
    • MasmBasic
Re: About the Joy of Writing an Editor
« Reply #13 on: November 15, 2022, 11:16:30 PM »
Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.