Author Topic: syntax highlighting question  (Read 6622 times)

EricKane

  • Guest
syntax highlighting question
« on: April 23, 2006, 07:58:23 am »
rev2369
why syntax highlighting setting always change after I set option then restart CB.
as same as i save layout and after delete layout , what use does it have?
How could i keep my syntax highlighting setting when i update to new revision?

Max

  • Guest
Re: syntax highlighting question
« Reply #1 on: April 23, 2006, 01:37:15 pm »
It's a known bug. You will observe "color settings lost" when you change the editor settings .

There are two bug reports  open, 7063 and 7194. They are related to the same issue ( I think).

Pecan wrote a patch (990) for this issue, but the developpers didn't apply it. May be it is not the
right solution or there are more important task to be completed.

Wait for a new version in which this issue has been fixed, or apply the patch by yourself. :D

Bye

Massimo

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2750
Re: syntax highlighting question
« Reply #2 on: April 23, 2006, 01:40:45 pm »
Quote
Quote from: Pecan on April 11, 2006, 12:10:55 PM

It seems that in default.conf, only the current changes are being recorded.

Here's a proposed fix for this problem. It seems editorcolorset.cpp::save() was deleting the previous user settings
before writing the new user setting.

I'll submit a bug patch to berlios.
 
Code

Index: src/sdk/editorcolorset.cpp
===================================================================
--- src/sdk/editorcolorset.cpp (revision 2337)
+++ src/sdk/editorcolorset.cpp (working copy)
@@ -466,7 +466,8 @@
 {
  wxString key;
  ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("editor"));
- cfg->DeleteSubPath(_T("/color_sets/") + m_Name);
+ // The next stmt causes all previous user settings to be deleted        //pecan 2006/4/11
+ //-cfg->DeleteSubPath(_T("/color_sets/") + m_Name);                     //pecan 2006/4/11
 
  // write the theme name
  cfg->Write(_T("/color_sets/") + m_Name + _T("/name"), m_Name);

thanks
pecan

Patch is 990

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: syntax highlighting question
« Reply #3 on: April 23, 2006, 08:46:25 pm »
That patch fixes the symptom, but I am not sure if simply commenting out that line alltogether it is 100% the right thing yet.

The deletion of the subpath was introduced way back because otherwise you would not be able to ever delete an item added to a set. Something seems to go wrong though.
Without having looked at it closer, my guess is that DeleteSubPath should be moved into the loop and should be done once for each language, not for the whole big thing... will try and see.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: syntax highlighting question
« Reply #4 on: April 24, 2006, 08:51:02 pm »
After trying for a while, I've applied the patch for now, lacking a better solution (rev. 2376).

I know for sure that Yiannis explicitely asked for a DeleteSubPath() function because it would not work without it in some cases. Unluckily, I don't remember what it was... :S

However, for the time being, commenting out that line certainly makes things better. With settings lost every time, the app is quite unusuable. Let's see if it fails, and why :)

We might replace that wx container with std::map some day in the future, then we could read and write the complete colour settings using one SDK call, without iterating through elements, deleting subpaths, and all that tampering. Haven't got time for that conversion now, though.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2750
Re: syntax highlighting question
« Reply #5 on: April 25, 2006, 01:24:16 am »
After trying for a while, I've applied the patch for now, lacking a better solution (rev. 2376).
...
However, for the time being, commenting out that line certainly makes things better. With settings lost every time, the app is quite unusuable. Let's see if it fails, and why :)
...

Thank you. We all appreciate that. It's really been a pain in the @s.

thanks
pecan

Max

  • Guest
Re: syntax highlighting question
« Reply #6 on: April 26, 2006, 12:34:59 pm »
Dear All,

Unfortunately the color setting is not the only "setting" that looses the modification. If you try to add a new keyword
the modification will be lost. I flagged this bug in the #7063, the bug was closed after the application of the Pecan's patch.

I have opened a new bug report (#7275) to flag the issue.

In the meantime I am adding the keyword manually in the .conf file.

Thanks

Massimo

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2750
Re: syntax highlighting question
« Reply #7 on: April 26, 2006, 01:45:07 pm »
Dear All,

Unfortunately the color setting is not the only "setting" that looses the modification. If you try to add a new keyword
the modification will be lost. I flagged this bug in the #7063, the bug was closed after the application of the Pecan's patch.

I have opened a new bug report (#7275) to flag the issue.

In the meantime I am adding the keyword manually in the .conf file.

Thanks

Massimo

Did you get a chance to test with the patch? It looked like,
to me, that the highlite bug was causing the keyword bug
also.

I was under the impression that the patch fixed both.

Not so???
 

Max

  • Guest
Re: syntax highlighting question
« Reply #8 on: April 26, 2006, 07:07:41 pm »
Dear Pecan,

Yes, I am using the 2377, in which your patch was included. The bug is still present.

Try it. Open the editor setting -> Syntax Highlighting -> Keywords

In set 2 add a keyword

Click Ok and OK .


The new keyword is lost. It is not in the list as you can verify reopening the keyword dialog.

Massimo

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2750
Re: syntax highlighting question
« Reply #9 on: April 26, 2006, 09:06:37 pm »
You are so right. The problem is in a difference module altogether.
EditKeywordsDlg::OnSetChange() does not seem to be writing out the keywords.

I was wrong to associate my patch with this problem.

Well... as it turns out, the problem *is* in the same area as my patch.
But before I propose another patch, here's a little workaround that
you can use to set and save your keywords.

The trick is to change a highlite color before you exit the dialog.

1. add your keyword (maybe to set 2) but do *not* click on ok.
2. change the spin control to any other setting (maybe back to set 1)
3. now click on keyword dialog ok, but *not* on the full dialog ok
4. go change a color on something (maybe change UUID to grey)
5. now click on ok to exit the editor settings dialog

your keywords will be saved.
Sorry about the convoluted method. I'm sure it'll be fixed soon.

pecan

« Last Edit: April 26, 2006, 10:50:15 pm by Pecan »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2750
Re: syntax highlighting question
« Reply #10 on: April 27, 2006, 04:26:41 am »

...If you try to add a new keyword the modification will be lost...
I have opened a new bug report (#7275) to flag the issue.
In the meantime I am adding the keyword manually in the .conf file.


Here is a proposed patch for the problem. Will submit to berlios when it comes back up again.

Code
Index: src/sdk/editkeywordsdlg.h
===================================================================
--- src/sdk/editkeywordsdlg.h (revision 2371)
+++ src/sdk/editkeywordsdlg.h (working copy)
@@ -15,9 +15,10 @@
     protected:
         void OnSetChange(wxSpinEvent& event);
 
+        wxSpinCtrl* spnSet;
+    public:
         EditorColorSet* m_pTheme;
         HighlightLanguage m_Lang;
-        wxSpinCtrl* spnSet;
         wxTextCtrl* txtKeywords;
         int m_LastSet;
     private:
Index: src/sdk/editorconfigurationdlg.cpp
===================================================================
--- src/sdk/editorconfigurationdlg.cpp (revision 2371)
+++ src/sdk/editorconfigurationdlg.cpp (working copy)
@@ -635,6 +635,8 @@
      EditKeywordsDlg dlg(0, m_Theme, m_Lang);
         PlaceWindow(&dlg);
      dlg.ShowModal();
+        // Update the last modified keywords set            //pecan 2006/4/26
+        dlg.m_pTheme->SetKeywords(dlg.m_Lang, dlg.m_LastSet, dlg.txtKeywords->GetValue());
  }
 }
 

thanks,
pecan