Ctl-F2 Question

Started by Gary Beene, November 07, 2013, 01:48:08 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Gary Beene

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?
  •  

José Roca

#1
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.
  •  

Paul Squires

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
Paul Squires
FireFly Visual Designer SQLitening Database System JellyFish Pro Editor
http://www.planetsquires.com
  •  

Gary Beene

#3
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.
  •  

Gary Beene

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.
  •  

Gary Beene

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
  •  

Gary Beene

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))
  •  

Gary Beene

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

  •  

Gary Beene

#8
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.
  •  

José Roca

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.

  •  

José Roca

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.
  •  

Gary Beene

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.
  •  

Gary Beene

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!
  •