Powerbasic Museum 2020-B

Webmaster: José Roca (PBWIN 10+/PBCC 6+) (SDK Forum) => CSED Editor => Topic started by: Gary Beene on November 07, 2013, 01:48:08 AM

Title: Ctl-F2 Question
Post by: Gary Beene on November 07, 2013, 01:48:08 AM
With a file opened in CSED v1.03 and no changes made to the file, hitting Ctrl-F2 (bookmark) causes the toolbar Undo button to un-gray. Pressing it will insert an apostrophe.

That's not supposed to happen, is it?
Title: Re: Ctl-F2 Question
Post by: José Roca on November 07, 2013, 02:23:53 AM
Yes, it is supposed to happen.


            ' // Toggle the current bookmark
            CASE %IDM_TOGGLEBOOKMARK
               SCI_ToggleBookmark(pSed.hEdit)
               ' // Comment and uncomment the line just to make
               ' // the file dirty and force saving.
               SCI_BlockComment(pSed.hEdit)
               SCI_BlockUncomment(pSed.hEdit)
               EXIT FUNCTION


If you don't like it, find another way to force saving or lose the bookmarks.
Title: Re: Ctl-F2 Question
Post by: Paul Squires on November 07, 2013, 03:46:54 AM
Strange that the control does not allow you to force it to a dirty state. However, the website does say that it supports (for now anyways) the standard edit control message:

EM_SETMODIFY(bool isModified)

http://msdn.microsoft.com/en-us/library/windows/desktop/bb761651(v=vs.85).aspx
Title: Re: Ctl-F2 Question
Post by: Gary Beene on November 07, 2013, 03:52:09 AM
Hi Paul!
Scintilla Help echos what you say ...
QuoteThe following messages are currently supported to emulate existing Windows controls, but they will be removed in future versions of Scintilla. If you use these messages you should replace them with the Scintilla equivalent.

EM_SetModify(bool isModified)
I think that list has been in Scintilla for some time. Guess they're in no hurry to remove support for the 30 or so messages in the list.
Title: Re: Ctl-F2 Question
Post by: Gary Beene on November 07, 2013, 03:59:11 AM
But, on a quick trial, if I use this in CSED ...
QuoteCase %IDM_TOGGLEBOOKMARK
               SCI_ToggleBookmark(pSed.hEdit)
               ' // make the file dirty and force saving.
               SendMessage pSed.hEdit, %EM_SetModify, %True, 0      'BEENE
               Exit Function

With the above code compiled, if I open a file, use Ctrl-F2, then close CSED, I do not get a "Save Current Changes?" message.
Title: Re: Ctl-F2 Question
Post by: Gary Beene on November 07, 2013, 04:10:09 AM
And, this next trial returns 0 - showing that the EM_SetModify does not change the results of SCI_GetModify.
QuoteCase %IDM_TOGGLEBOOKMARK
               SCI_ToggleBookmark(pSed.hEdit)
               ' // make the file dirty and force saving.
               SendMessage pSed.hEdit, %EM_SetModify, 1, 0      'BEENE
               ? Str$(SCI_GetModify(pSed.hEdit))  '<--- returns 0
               Exit Function
Title: Re: Ctl-F2 Question
Post by: Gary Beene on November 07, 2013, 04:13:08 AM
And, for grins, I tried this too (EM_GetModify after using EM_SetModify)  ... also returns 0.
Quote? Str$(SendMessage(pSed.hEdit, %EM_GetModify, 0, 0))
Title: Re: Ctl-F2 Question
Post by: Gary Beene on November 07, 2013, 04:16:50 AM
Checking out the Scintilla-Interest group, it appears that I asked that question back in July,2010.

Quotescintilla-interest ›
Force Dirty State?
3 posts by 2 authors
   Gary Beene    
7/26/10
Is there a message I can use that is the opposite of SCI_SetSavePoint,
one that will force Scintilla into a "dirty" state?
   Gary Beene    
7/26/10
Umm... I can see where that would be a problem.  If I arbitrarily make
Scintilla "dirty", how will the undo/redo stack know where the save
point would be?
   Neil Hodgson    
7/26/10
gbeene:

> Is there a message I can use that is the opposite of SCI_SetSavePoint,
> one that will force Scintilla into a "dirty" state?

   No and there won't be.

   If you are trying to manage application level state like changing
the encoding a file will be saved in then manage that in the
application.

   Neil

Title: Re: Ctl-F2 Question
Post by: Gary Beene on November 07, 2013, 04:56:26 AM
Nope, not finding anything that will make an Sci dirty while adding nothing to the undo stack. Nor can I find anything that lets me remove the last added item from the undo stack while not affecting Sci_GetModify status.

I suppose one could create a new setting, pSed.BookmarkCount, which tracks the number of bookmarks in each Sci. Then, in the 11 places where the following (or some other SCI_GetModify statement), is used, modify the code something like this ...
If SCI_GetModify(pSed.hEdit) Thenwould be replaced with this
If SCI_GetModify(pSed.hEdit) or pSed.BookmarkCount Then

Since each bookmark (Ctrl-F2) adds an apostrophe to the undo stack, if I were doing lots of bookmarks, I might argue that the coding effort would be worth it.

But, I rarely use bookmarks, so it's not a priority for me.
Title: Re: Ctl-F2 Question
Post by: José Roca on November 07, 2013, 05:08:55 AM
Quote
Since each bookmark (Ctrl-F2) adds an apostrophe to the undo stack, if I were doing lots of bookmarks, I might argue that the coding effort would be worth it.

You can add a check to see if you already can undo before calling SCI_BlockComment(pSed.hEdit), SCI_BlockUncomment(pSed.hEdit). This will reduce the number of aphostrophes to one.

Title: Re: Ctl-F2 Question
Post by: José Roca on November 07, 2013, 05:14:01 AM
Anyway, the action of setting bookmarks in an unmodified file, followed with an undo (why to undo, if you haven't modified anything?), must be so rare that you are the first one to notice it.
Title: Re: Ctl-F2 Question
Post by: Gary Beene on November 07, 2013, 05:16:32 AM
Jose,
Yes, I like that idea.

There still could be multiple apostrophes. Whenever the user takes undo actions back to the save point, the first subsequent bookmark will give another apostrophe. 

But, especially when there's a lot of editing, I'd guess that your idea would normally reduce the apostrophe count greatly.
Title: Re: Ctl-F2 Question
Post by: Gary Beene on November 07, 2013, 05:17:27 AM
And, Jose,
You're right. If it was only noticed today, after a couple of years of release, it would be hard to argue that anyone really needs the change!