Author Topic: Ctl-F2 Question  (Read 7744 times)

0 Members and 1 Guest are viewing this topic.

Offline Gary Beene

  • Jr. Member
  • **
  • Posts: 96
  • User-Rate: +3/-0
Ctl-F2 Question
« 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?

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Re: Ctl-F2 Question
« Reply #1 on: November 07, 2013, 02:23:53 AM »
Yes, it is supposed to happen.

Code: [Select]
            ' // 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.
« Last Edit: November 07, 2013, 04:53:09 AM by José Roca »

Offline Paul Squires

  • Jr. Member
  • **
  • Posts: 90
  • User-Rate: +11/-5
    • PlanetSquires
Re: Ctl-F2 Question
« Reply #2 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
Paul Squires
FireFly Visual Designer SQLitening Database System JellyFish Pro Editor
http://www.planetsquires.com

Offline Gary Beene

  • Jr. Member
  • **
  • Posts: 96
  • User-Rate: +3/-0
Re: Ctl-F2 Question
« Reply #3 on: November 07, 2013, 03:52:09 AM »
Hi Paul!
Scintilla Help echos what you say ...
Quote
The 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.
« Last Edit: November 07, 2013, 04:04:59 AM by Gary Beene »

Offline Gary Beene

  • Jr. Member
  • **
  • Posts: 96
  • User-Rate: +3/-0
Re: Ctl-F2 Question
« Reply #4 on: November 07, 2013, 03:59:11 AM »
But, on a quick trial, if I use this in CSED ...
Quote
            Case %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.

Offline Gary Beene

  • Jr. Member
  • **
  • Posts: 96
  • User-Rate: +3/-0
Re: Ctl-F2 Question
« Reply #5 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.
Quote
            Case %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

Offline Gary Beene

  • Jr. Member
  • **
  • Posts: 96
  • User-Rate: +3/-0
Re: Ctl-F2 Question
« Reply #6 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))

Offline Gary Beene

  • Jr. Member
  • **
  • Posts: 96
  • User-Rate: +3/-0
Re: Ctl-F2 Question
« Reply #7 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.

Quote
scintilla-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


Offline Gary Beene

  • Jr. Member
  • **
  • Posts: 96
  • User-Rate: +3/-0
Re: Ctl-F2 Question
« Reply #8 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 ...
Code: [Select]
If SCI_GetModify(pSed.hEdit) Thenwould be replaced with this
Code: [Select]
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.
« Last Edit: November 07, 2013, 04:58:29 AM by Gary Beene »

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Re: Ctl-F2 Question
« Reply #9 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.


Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Re: Ctl-F2 Question
« Reply #10 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.

Offline Gary Beene

  • Jr. Member
  • **
  • Posts: 96
  • User-Rate: +3/-0
Re: Ctl-F2 Question
« Reply #11 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.

Offline Gary Beene

  • Jr. Member
  • **
  • Posts: 96
  • User-Rate: +3/-0
Re: Ctl-F2 Question
« Reply #12 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!