News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Another ASM editor

Started by NoCforMe, September 03, 2022, 06:54:23 AM

Previous topic - Next topic

NoCforMe

#60
Progress.

I solved the messed-up-buttons-scrolling-with-the-listbox issue by sidestepping it. (I never did solve the problem of scrolling the listbox with the buttons attached to it as its children.) Instead, the cubbyholes are now in a static control container that's always at the top (yeah, it would be nice to make its position configurable, but too bad for that). The listbox, if there is one (assuming the config file is present and was parsed correctly) starts below it. And it all works! The listbox even scrolls correctly (try resizing the window vertically and see what happens).

Phew! I went through so many gyrations to get this to work. When I first created a static window and put the buttons inside it, they worked OK, except they had an ugly white border around them where the edge wasn't getting painted the background color of the static. I tried catching WM_CTLCOLORBTN and passing a brush the color of the background; no go. (All the while I was scouring the web for advice. Found lots of stuff on Code Project and Stack Overflow and others, but nothing that worked.)

Then I tried going the owner-draw route. Ugh. What a goddamn can of worms that is. At first I could only get the ugly pre-Vista looking buttons--remember, all square? Then I started delving into ... oh nooooooo ... themes. That's really a squirming, festering can o'worms. I was actually able to get to the same point I was before I started: buttons with the new look (no text, since I'd have to draw that myself) but still with the damned white border! And of course, to use any of the theme stuff you have to find the right DLL, use LoadLibrary() and GetProcAddress(), and then a bunch of push-push-calls because nobody ever got around to adding this stuff to our Masm32 libraries, even though it's been, what? 10-12 years ago that this stuff came out?.

Oh, and I almost forgot that at one point I was wrestling with the "theme" stuff (OpenThemeData() specifically), just couldn't get it to work at all, when it dawned on me that maybe those functions need Unicode names, not ANSI; sure enough, that was the problem.

Then I found a little something that worked: in addition to catching WM_CTLCOLORBTN, you need to catch NM_CUSTOMDRAW notifications (which is odd, since it's no longer an owner-draw control); when the dwDrawStage = CDDS_PREERASE (and the moon is in the right phase and it's a month with an "R" in it), you do a FillRect() of the button using the background color. Which fixes it. No owner-draw needed, just a little subclassing.

What a mess Win32 is ...

Anyhow, try this version out. I promise I'll start making some substantive progress soon (switching to a RichEdit control so I can add search and replace, which no self-respecting editor can be without).
Assembly language programming should be fun. That's why I do it.

jj2007

Works fine :thumbsup:

Some points for consideration:
- I like the idea of a multiple clipboard, but I'll rarely need more than one extra copy
- Are the up/down arrows for searching for each cubby hole really needed? For comparison, see another solution below; to start a search, either type the word in the Find box, or select a word in the main window and hit F3.
- The listbox has [Inserts] on top, but when you scroll down, it disappears.
- Goodies at the end does not show unless you scroll down.
IMHO both Inserts and Goodies should be separate push buttons. Another solution is to put the Insert into a menu: thus, no listbox claiming precious space. The bookmarks below to the right cost space, too, but in my experience they are a better investment than a menu of inserts that I need only occasionally.

My 2cts ;-)

NoCforMe

All good points. I'm going to have to wait until I actually start using it to see what I like. Like a saying (title of a song): You won't know until you find out.

"[Inserts]" at the top is just a heading. You could put Goodies at the top by editing the .cfg file. (Someday there'll be a built-in config editor ...)
Assembly language programming should be fun. That's why I do it.

NoCforMe

I've been busy. Here's the latest version. It has:

  • Printing (you can select a different font for printing, in Format--> Printer Font)
  • Full search & replace (you can also search from the "cubbyholes")
  • Bookmarks (well, one set; use menu icons at top)
  • Uppercasing/lowercasing (menu icons)
Still lots of unfinished stuff:

  • Save/restore to .ini file (under construction)
  • Print formatting: margins, header & footer
  • Turn word wrap on/off
  • Put filename in window title bar
  • Popup context menu in edit window
The .ini file will save the current font (face, size, etc.), and the window size & position. It's got to be smarter than the stupid stupid scheme used by Notepad. Drives me nuts: even if you have multiple instances open, if you change the font in one and close it, even though there are several more open, it changes the font to what you had the next time you open a new instance. Stupid.

My idea: keep track of how many instances are open, and only save the .ini values when the last one is closed. (There could even be some options to control how this works.)

Bookmarks: The bitmaps are pretty fugly, I know; my meager attempts at hand-antialiasing. And there's only one set: I was thinking of something like the Cubbyholes for multiple bookmark setting/going-to buttons.

I learned a lot about RichEdit controls coding this.

I've actually been using the editor, and I kind of like it. Takes some getting used to (I've been using Notepad for far, far too long ...) And of course I can't really use it yet to develop itself, since I can't make a new .exe while the old one is open.

So let me know if you have any brilliant ideas on how to improve this. Also, play around with the configuration file, add some stuff of your own.
Assembly language programming should be fun. That's why I do it.

hutch--

Hi David,

It seems to run OK on my Win10. The "Inserts" list works OK but the font is being clipped by the container. You may have to specify a font size that fits the line spacing.

NoCforMe

Hutch, thanks. If you have a spare moment (!!!), could you maybe post a quick screen shot? Trying to remove as much fugliness from this as possible. (Chrome is so important, dontcha think?)
Assembly language programming should be fun. That's why I do it.

jj2007

 :thumbsup:
- printing works fine
- word wrap doesn't
- bookmarks apparently not (?)
- statusbar should be reset ("bookmark set" and "Printing page 5" remain forever)

NoCforMe

Quote from: jj2007 on September 21, 2022, 09:45:30 AM
- word wrap doesn't
- bookmarks apparently not (?)
- statusbar should be reset ("bookmark set" and "Printing page 5" remain forever)

Word wrap "TBD". Pardon our dust.

Bookmarks should work: first one sets it (status bar says so), second one jumps to it.

Yes, that damn status bar. Need to figure out when to clear it.

Thanks for the QC check.
Assembly language programming should be fun. That's why I do it.

NoCforMe

#68
I've fixed some of the issues you pointed out, JJ. Plus added a bunch more stuff. That works! (Well, at least with my limited testing.)

New stuff:

  • Expanded bookmarks! Four of 'em. These are really handy.
  • A find dialog which opens from the menu or with Ctrl+F. F3 does a "find again" (need to fix it so F3 opens the dialog initially if it hasn't already been.)
  • Printing header works; you can put in date, time, filename, page #, just like Notepad (same syntax). Footer not implemented yet (you can fill it in, it just does nothing.) Soon.
  • I clear the status bar anytime the user makes a selection in the edit window.
  • Filename shown in title bar
Oh, and I saved the best for last: it now writes an .ini file that saves important stuff: font faces & sizes, window size & position, print header & footer, etc. Will always write the file in its "home" directory, no matter where you run the program. (This needs tested, but works for me fine so far.)

Still lots on the to-do list: Print margins (ugh), open files from command line, popup editing context menu, and I promise I'll get that word-wrap option done. Soon.

I'm sure someone will find a bug or three. Still in all, I'm pretty happy with it.

There's no .ini file in the zip, but it'll write one the first time you close it.

I'll post my code soon for those who are interested. (Source file is now ~170 Kb)

(Note: .exe has been updated with fixes for problems found by JJ below)
Assembly language programming should be fun. That's why I do it.

jj2007

Quick and dirty:
- on first launch, it looks like in the attached image, and the font is 1 point tiny (ok on second launch)
- dragging a file over the exe doesn't work - commandline ignored
- compare bookmarks Goto to RichMasm behaviour
- bookmarks are gone when you reopen the file
- in the find dialog, cancel doesn't work

NoCforMe

Sorry 'bout that: standards have been dropping here at NoCforMe Laboratories, GmbH; I had to fire the person who was supposed to have tested this release. (Just kidding.)

Fixed the tiny window problem (I was checking for the wrong return value after trying to open the .ini file, and never tested it without the file), and the no Cancel in the find dialog (that's what happens when you have two buttons both set to IDOK).

I hadn't planned on saving bookmarks, as they'd have to be tracked to a particular file. Do you reload yours in your editor? How do you save them? I probably won't do that.

Planning on having opening files from command line Real Soon NowTM. Updated .exe in previous post up there.
Assembly language programming should be fun. That's why I do it.

jj2007

Quote from: NoCforMe on September 24, 2022, 07:47:44 PMI hadn't planned on saving bookmarks, as they'd have to be tracked to a particular file. Do you reload yours in your editor? How do you save them? I probably won't do that.

For *.asc files, I save them embedded in the rtf code, i.e. they are permanent.
For plain test *.asm files, they are generated on opening the file, i.e. individually set bookmarks are lost when closing the file.

Note your current version doesn't adjust the bookmark position when the user inserts text.

NoCforMe

Quote from: jj2007 on September 24, 2022, 09:11:48 PM
Note your current version doesn't adjust the bookmark position when the user inserts text.

Yes, I noticed that and it bothers me too; the bookmark changes position when text is added or deleted. I use EM_GETSEL to get the current selection or position. But that position has got to change as the text in the control changes. How do you "anchor" a bookmark to a particular piece of text?

I suspect a lot of the functionality you have in your application is because you're actually exploiting a lot more of the capabilities of RichEdit. For me, it's just a convenient place to hold ANSI text. At least so far ...

Something else I noticed is that the character count I get from RichEdit (using EM_GETTEXTLENGTHEX) isn't accurate. (And I am using the GTL_PRECISE flag.) Close, but no cigar. I think it's because of how the control counts line endings (CR/LF). The number is definitely different from the actual file size.
Assembly language programming should be fun. That's why I do it.

jj2007

Quote from: NoCforMe on September 24, 2022, 09:44:57 PMHow do you "anchor" a bookmark to a particular piece of text?

Hidden text, plus a table that gets adjusted when EN_CHANGED occurs.

Quote from: NoCforMe on September 24, 2022, 09:44:57 PMSomething else I noticed is that the character count I get from RichEdit (using EM_GETTEXTLENGTHEX) isn't accurate.

RichMasm:
movi tlex.flags, GTL_PRECISE or GTL_NUMCHARS ;  this combi 5,000x faster than with either GTL_USECRLF or GTL_NUMBYTES!

Internally, the richedit control uses CR, not CRLF.

TimoVJL

For ASCII / ANSI / text source code needs a common style for bookmarks in commented text.
May the source be with you