The MASM Forum

Projects => ObjAsm => Topic started by: Biterider on March 04, 2025, 08:38:50 PM

Title: New Editor
Post by: Biterider on March 04, 2025, 08:38:50 PM
Hello
A long time ago I started coding an editor that I wanted to extend with an internal automation engine for addins. My intention was to use LUA.
Other things got in the way and I only got back to it a few weeks ago.
It was much more complicated than I expected. In particular, synchronising all the editor features is a real challenge. Hats off to those who have managed it. For some features I used RadAsm and Notepad++ as a reference.

Current features are:
Caret management
Scrolling
Insertion and deletion
Drag and Drop
Load/Save/SaveAs file
Syntax Highlithing
Configuration (ini-file) and precoded defaults
Multiple synchronized Views of a single file
Zoom in and out
Line numbering
Copy/Paste/Replace

Not yet implemented:
Do/Undo
Interlisense
LUA
Window management
Project management
Addins management
etc.


Regards, Biterider


Title: Re: New Editor
Post by: daydreamer on March 04, 2025, 09:24:48 PM
Good luck Biterider  :thumbsup:
Editors I use has "undo/redo" menu text
Numbers of undo/redo only limited by memory or like image program setting of max memory to use for undo/redo? Or max number of undo/redo limited to 32, 64?
Title: Re: New Editor
Post by: Biterider on March 05, 2025, 08:00:13 AM
Hi
I have a question for those who have played with UTF-8 as input for ML/UASM.
Is there anything to be aware of?
For this project, I'm coding the editor code buffer using WIDE chars (Unicode/UTF-16). Now, when I save the content, I want to save it as UTF-8 and pass it to the assembler.
Does this work or are there any pitfalls?

Regards, Biterider
Title: Re: New Editor
Post by: jj2007 on March 05, 2025, 08:08:30 AM
Quote from: Biterider on March 05, 2025, 08:00:13 AMI have a question for those who have played with UTF-8 as input for ML/UASM

Masm, UAsm & friends don't care what you use, as long as it doesn't have nullbytes in it, like Utf-16 does. So just send Utf-8 without a BOM. No pitfalls. The assembler simply doesn't know about that "encoding" stuff ;-)

Example:
Quoteinclude \masm32\MasmBasic\MasmBasic.inc
  Init
  PrintLine "Введите текст здесь"   ; "Enter text here" in Russian
  PrintLine "Нажмите на эту кнопку"   ; "Click on this button" in Russian
EndOfCode

Now this is RTF, but have a look at the attached plain text source.
Title: Re: New Editor
Post by: zedd151 on March 05, 2025, 08:17:53 AM
Quote from: jj2007 on March 05, 2025, 08:08:30 AMUtf-8 without a BOM
That is key. UTF8 without a BOM looks like, tastes like and smells like a plain,  ordinary ANSI ascii text file. You can see this in a hex editor.

On Win 10, Notepad saves as UTF8 (no BOM) by default, and examining the file in a hex editor it looks exactly as if were saved as ANSI ascii. And I spent a lot of time selecting "ANSI" to save with Notepad, until I found this out. Hope this helps...

Saving as UTF8 with BOM in notepad, it appends hex bytes "EF", "BB", BF" to the file. It still opens though with qeditor and when saving, qeditor does not retain the 3 hex bytes.

Now after saving an .asm file as utf8 WITH BOM in notepad, "error A2044: invalid character in file" upon assembling (or trying to) it with ml.exe
For utf8 without BOM, it assembles fine with ml.exe.
Title: Re: New Editor
Post by: jj2007 on March 05, 2025, 09:00:56 AM
Quote from: zedd151 on March 05, 2025, 08:17:53 AMOn Win 10, Notepad saves as UTF8 (no BOM) by default

Indeed, the source above looks right in a Win10 Notepad, but not (yet) in RichMasm and other editors.

Notepad opens both attached files correctly. One is Utf8, the other uses my local codepage. There is no fool-proof way to find out the encoding, so apparently Notepad uses some heuristic method...
Title: Re: New Editor
Post by: Biterider on March 07, 2025, 05:59:59 AM
Hi
Deciding which file format is best is a case-by-case decision. 
UTF-8/16, ANSI are valid options for a good editor. I'll add some entries to the ini file to automatically select the best choice based on the file extension.

One cool feature suggested by HSE is to offset the line numbering on a given line to track macro error messages. It can also be used for other tasks, such as simple item counting.

For testing purposes, I implemented this by right-clicking on the selection bar at the vertical position of the zero line number. A second click resets to normal operation (see attached image).

Regards, Biterider
Title: Re: New Editor
Post by: Biterider on March 10, 2025, 07:44:15 AM
Hi
Here we go!
In the first post I attached the first binary (alpha release).
Source code can be downloaded from Github.

For those who want to experiment, open the zip file and extract the 2 files into the same folder.
At the moment the files are opened and saved in UTF-8 format. The 2 windows on the left have no functionality yet.

Any feedback is very welcome.

Regards, Biterider
Title: Re: New Editor
Post by: jj2007 on March 11, 2025, 06:46:47 AM
Quote from: Biterider on March 10, 2025, 07:44:15 AMSource code can be downloaded from Github

Link?

The editor runs but I don't see the window. Quick test:
include \masm32\MasmBasic\MasmBasic.inc
  SetGlobals hWin, rc:RECT
  Init
  .if WinByTitle("Assembler Development Environment")
mov hWin, eax
invoke GetWindowRect, hWin, addr rc
deb 4, "The window", rc.left, rc.top, rc.right, rc.bottom
invoke MoveWindow, hWin, 27, 27, 1200, 666, 0
invoke ShowWindow, hWin, SW_MINIMIZE
invoke ShowWindow, hWin, SW_RESTORE
  .endif
EndOfCode
The window
rc.left        32767
rc.top          32767
rc.right        34067
rc.bottom      33507

Is there somewhere a shr in the source that should have been sar?

Attached an exe to make it visible. Looks good :thumbsup:
Title: Re: New Editor
Post by: Biterider on March 11, 2025, 07:38:14 AM
Hi JJ
Thank you for giving it a try  :thumbsup:
The sources are here https://github.com/ObjAsm/ObjAsm-C.2/tree/master/Projects/X/AsmDevEnv (https://github.com/ObjAsm/ObjAsm-C.2/tree/master/Projects/X/AsmDevEnv), but keep in mind that this is an alpha release. There is still a long way to go.

The effect you see is because I fixed the window size to my screen resolution while testing the application. I simply forgot to reset it back to the normal operation.

Regards, Biterider