Author Topic: my editor project  (Read 7946 times)

zedd151

  • Member
  • *****
  • Posts: 1937
Re: my editor project
« Reply #30 on: October 07, 2022, 07:44:53 PM »
I had gotten sidetracked with other things, so I did very little work on the editor since my last post here. I Will post the updated code once I do get to working on it again.
Regards, zedd.
:tongue:

zedd151

  • Member
  • *****
  • Posts: 1937
Re: Latest progress
« Reply #31 on: October 08, 2022, 05:46:17 AM »

Now have the 'Edit' menu functions working. The usual stuff. Undo, Redo, Cut, Copy, Paste, Select All.
Edit items also easily accessible directly on the menu bar:
U - Undo
R - Redo
-
X - Cut
C - Copy
V - Paste
-
A - Select all


Shifted the resource ID's a little bit too. I like the resource ID's in numerical order at least close to the same way they appear on the menu.

Attachment 'basic editor6.zip' removed but is included in the archive In this post
« Last Edit: November 17, 2022, 12:38:04 PM by zedd151 »
Regards, zedd.
:tongue:

zedd151

  • Member
  • *****
  • Posts: 1937
Re: my editor project
« Reply #32 on: October 08, 2022, 05:50:11 AM »
Was originally an accidental duplicate post here.
To make this post more useful, I'll tell you...
Work on the editor is a little slow.
But, "slow and steady wins the race". - S. Tortuga, 1935
 :biggrin:
From time to time, I take a break from this project to work on my sudoku game. When I need a break from working on that I come back to the editor code. My goal is to have both projects finished by the years end; and start the new year with a clean slate.  :greensml:
« Last Edit: October 08, 2022, 12:58:55 PM by zedd151 »
Regards, zedd.
:tongue:

zedd151

  • Member
  • *****
  • Posts: 1937
Re: my editor project
« Reply #33 on: October 08, 2022, 02:00:06 PM »
Most of the file handling code is done. Open, Save, Save As...
Checks if file has been modified before opening a different file, or exiting; if user clicks yes, SaveAs dialog pops up to prevent accidentally overwriting current file.   :mrgreen:  Been there done that

Have not yet added code for dragging a file over the icon (GetCommandLine) or richedit window (DragQueryFile). Will be added shortly. Will be testing this version of the editor in the meantime.  :biggrin:


Attachment 'basic editor7.zip' removed but is included in the archive In this post
« Last Edit: November 17, 2022, 12:38:52 PM by zedd151 »
Regards, zedd.
:tongue:

zedd151

  • Member
  • *****
  • Posts: 1937
Re: my editor - auto backup?
« Reply #34 on: October 08, 2022, 02:42:45 PM »
I have been pondering for some time about adding a function to automatically create a backup file upon opening a source file without having to manually "Save As...". I have been playing with a piece of code to do that. I think that in a future version of this WIP, I will incorporate this function. If it works out well, I will keep it in the final version.
The backup file would always be created, overwriting the previous one if it exists. A menu option of course will be needed to 'restore from backup', which would be done automatically upon clicking that menu item. The contents of the editor would reflect the restored file. I still have to figure out some details to not overwrite a good backup with the current (that needs to be restored) code in the editor. Possibly use a temp file to do the exchange? Keep it in memory until closing?  Will chew on this for a bit...
After a little thinking:
Probably I would keep the orginal in memory until exiting the editor, then write the backup to file before exiting. This way the backup copy will be there for the user to restore from.  :wink2:
So I think that is what I will try in the editor next...  :biggrin:  a bit later that is or tomorrow.
Regards, zedd.
:tongue:

jj2007

  • Member
  • *****
  • Posts: 13872
  • Assembly is fun ;-)
    • MasmBasic
Re: my editor project
« Reply #35 on: October 08, 2022, 07:30:38 PM »
These are good intentions :thumbsup:

What I do is create a temp file when the user changed something, and update that file every time user edits the source. If user saves (or exits without saving), the temp file gets deleted.

If a crash happens (a very rare event, e.g. computer blocked and you had to press the power button for 5 seconds), then on opening the source a dialog pops up asking whether you want the last version.

The logic is simple, and the system has never failed me.

I have a second rescue system, see below. Sometimes it happens to me that I make major edits, and then realise the bloody beast doesn't build any more because of some deeply hidden glitch. And, bad luck, I already saved the bad version. In this case, I can revert to the last successfully built version. That happens to me once every two or three months, but in those occasions I was very grateful to have that feature :biggrin:

zedd151

  • Member
  • *****
  • Posts: 1937
Re: my editor ... tab replacement test
« Reply #36 on: October 09, 2022, 12:21:41 AM »
Experimenting with code to replace TAB with 4 spaces. I used to have code for this, but it is lost. This code seems to work ok.
Code: [Select]
      .if msg.message == WM_CHAR
        .if msg.wParam == VK_TAB
          mov msg.wParam, VK_SPACE
          invoke DispatchMessage, addr msg
          invoke DispatchMessage, addr msg
          invoke DispatchMessage, addr msg
          invoke DispatchMessage, addr msg
          jmp StartLoop
        .endif
      .endif
Pending... word selection that doesn't select trailing spaces when double click on word, attempt to write from scratch since I can't find that code either.

Attachment 'basic editor8.zip' removed but is included in the archive In this post
« Last Edit: November 17, 2022, 12:39:27 PM by zedd151 »
Regards, zedd.
:tongue:

zedd151

  • Member
  • *****
  • Posts: 1937
Re: my editor project
« Reply #37 on: October 09, 2022, 12:44:11 AM »
Regarding the last attachment...
While that code does replace a tab with 4 spaces, it does have one caveat that I just noticed. Using undo to undo the TAB, it only undoes one space at a time. Not a show stopper but could become a major irritation. Will have to try other means. Maybe later.


Some time later...
will be giving the richedit its own WNDPROC. I really shoulda done that already. I thought about that as I am going to give the richedit right-click edit menu access soon. So there's that bit, tab replacement, and word selection currently on my agenda. Once all of the "usual" functionality is finished I can then start with the custom functions.  :biggrin:
Regards, zedd.
:tongue:

jj2007

  • Member
  • *****
  • Posts: 13872
  • Assembly is fun ;-)
    • MasmBasic
Re: my editor project
« Reply #38 on: October 09, 2022, 02:00:53 AM »
4 x DispatchMessage, that's new for me, but I see the logic - a cute trick :thumbsup:

zedd151

  • Member
  • *****
  • Posts: 1937
Re: my editor project
« Reply #39 on: October 09, 2022, 02:01:46 AM »

4 x DispatchMessage, that's new for me, but I see the logic :thumbsup:
But it is a flawed method  :undecided: 
Quote from: zedd
While that code does replace a tab with 4 spaces, it does have one caveat that I just noticed. Using undo to undo the TAB, it only undoes one space at a time.

I'll figure out a better way
Regards, zedd.
:tongue:

zedd151

  • Member
  • *****
  • Posts: 1937
Re: whoops
« Reply #40 on: October 09, 2022, 02:13:42 AM »
Found a huge flaw.  :badgrin:  I would imagine that this also affects all the versions that use the ini file.  :undecided:
I copied the executable (version8) to the desktop. Alas, there is no ini file on the desktop. The program creates one though with both the background and text colors set to 0. No font or font size. Seems I forgot one small detail, creating an ini file with predefined defaults.  :greensml:
This will be remedied in short order before anything else, and will update the attachments. (Which brings up a question for hutch--)



Fixed the attachment above, "basic editor8.zip". Now writes a new ini file if it does not exist, with the default settings.
« Last Edit: October 09, 2022, 08:08:14 AM by zedd151 »
Regards, zedd.
:tongue:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10572
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: my editor project
« Reply #41 on: October 09, 2022, 07:58:49 AM »
Z, the trick is to always put the INI file in the same directory as the executable.

Use the library procedure,

    GetAppPath proc lpPathBuffer:DWORD

then write the INI to the same directory and read the INI file from that directory.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

zedd151

  • Member
  • *****
  • Posts: 1937
Re: my editor project
« Reply #42 on: October 09, 2022, 08:02:49 AM »
Thanks hutch but I fixed it already, it creates a default ini file if none present. I just forgot about that little detail.


Code: [Select]
        invoke exist, addr inifile              ; check if ini file exists
      .if eax == 0                              ; if not write default ini
        invoke writeafile, addr inifile, addr defini, 98
      .endif
  :biggrin:
Regards, zedd.
:tongue:

zedd151

  • Member
  • *****
  • Posts: 1937
Re: my editor project
« Reply #43 on: October 09, 2022, 09:12:59 AM »
All of the attachments where the editor uses an ini file have been fixed. Now the default ini file will be created if none is present. In the first couple versions, the ini file contains a few items that are not yet implemented, but will be subsequently implemented in later versions. The versions are the various stages of development. Will continue to post incrementally until the project is completed. version9 should be coming later this evening, if nothing else comes up.  :biggrin:
Regards, zedd.
:tongue:

zedd151

  • Member
  • *****
  • Posts: 1937
Re: my editor project
« Reply #44 on: October 09, 2022, 10:09:22 AM »
I've incorporated a batch of features in this version.

Left Trim  - removes leading  spaces from selected lines of text
Right Trim - removes trailing spaces from selected lines of text
Outdent 4  - shifts selected text to the  left by 4 spaces (unless left aligned)
Indent 4   - shifts selected text to the right by 4 spaces
Outdent 4  - shifts selected text to the  left by 1 space (unless left aligned)
Indent 4   - shifts selected text to the right by 1 space
Sort A     - ascending sort
Sort D     - descending sort

New menu bar items: (direct access by click on menu bar)

U - Undo
R - Redo
X - Cut
C - Copy
V - Paste
A - Select all

|<  = Left Trim
<<  = Outdent 4
<   = Outdent 1
>   = Indent 1
>>  = Indent 4
>|  = Right Trim


Attachment 'basic editor9.zip' removed but is included in the archive In this post
« Last Edit: November 17, 2022, 12:40:17 PM by zedd151 »
Regards, zedd.
:tongue: