Author Topic: wxScintilla 2.01  (Read 21530 times)

Offline cgarcia109

  • Multiple posting newcomer
  • *
  • Posts: 24
wxScintilla 2.01
« on: September 24, 2009, 05:54:18 pm »
i merged scintilla 2.01 with cb wxscintilla

http://www.megaupload.com/?d=Q9HTFWP0

wxscintilla.h line 4019
/* TODO
    // This is already done through SendMsg
    SciFnDirect GetDirectFunction(); direct function
    sptr_t GetDirectPointer();  scintilla object
    // getting an raw text pointer is done too?
    uptr_t GetCharacterPointer();
    void GrabSCIFocus();
    bool LoadLexerLibrary(const wxString& path): Currently not implemented!

SetSelection confusing, theres actually another function
old msg SCI_SETSEL(anchor,pos)              void SetSelection(int,int)
new msg SCI_SETSELECTION(caret, anchor)     void _SetSelection(int,int)
*/

keep changebar code
keep codeblocks stuff (wxsmith ...)
keep INCLUDE_DEPRECATED_FEATURES that are removed in scintilla 2.01
keep some functions in Editor.cxx
    PositionFromLocationClose
    NotifyMove
    CopySelectionFromRange
keep some code in LexD.cxx line 81
keep in LexHTML
    LexerModule lmASP
    LexerModule lmPHP
    and related code
    they are removed in 2.01 and its use is discouraged
keep SVector.h
    allocFailure and related code
keep SCNotification scn = {{0}}; ScintillaBase.cxx Editor.cxx
    SCNotification scn = {0}; in scintilla 2.01 lots of warnings
keep in RunStyles.cxx|.h
    char *PersistantForm() const;
    void FromPersistant(const char *form);
    static bool PersistantSame(const char *form1, const char *form2);
keep all around the code checks like:
    var = 0
    type var = new type
  • ;

    if (!var) return; // all these checks are removed in scintilla 2.01
   
I keeped some of this stuff cos i dont know if its used by codeblocks in any way or indirectly by changebar, i could look into it but im tired of this thing

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: wxScintilla 2.01
« Reply #1 on: September 24, 2009, 07:25:59 pm »
We already have a test-branch including Scintilla 2.01:

Code
svn co svn://svn.berlios.de/codeblocks/branches/scintilla

should work for anonymous svn-access.

Offline cgarcia109

  • Multiple posting newcomer
  • *
  • Posts: 24
Re: wxScintilla 2.01
« Reply #2 on: September 25, 2009, 01:20:10 am »
connection failed
connection is read only :(

dunno if you noticed (maybe you already fixed someway) that when you clear a rectangular seleccion, caret is placed in the mainRange but when selecting up-down
mainRange is the lower one, a Paste will start there, maybe this is not the desired behavior. Downloaded precompiled SciTE and works the same way so is something about scintilla itself.

[attachment deleted by admin]

Offline cgarcia109

  • Multiple posting newcomer
  • *
  • Posts: 24
Re: wxScintilla 2.01
« Reply #3 on: September 29, 2009, 05:10:54 am »
Well if someone is interested

Implemented all missing func
wxSciFnDirect GetDirectFunction()
wxUIntPtr GetDirectPointer()
void GrabSCIFocus()
bool LoadLexerLibrary(const wxString& path)

not really very useful just to have them done

Events:
wxEVT_SCI_AUTOCOMP_CANCELLED
wxEVT_SCI_AUTOCOMP_CHARDELETED
wxEVT_SCI_SETFOCUS
wxEVT_SCI_KILLFOCUS

Implemented DynamicLibrary in PlatWX.h that is not currently implemented
Ive build LexMarkDown as external lexer and tested to load it with
LoadLexerLibrary() works fine

http://www.megaupload.com/?d=WZQD8FIN

If you plan to use external lexers build with SCIMAKINGDLL defined, that will export some Scintilla symbols ( WindowAccesor, PropSetSimple, WordList, LexerModule )
When building an external lexer define SCIUSINGDLL and link against scintila lib (i.e. wxScintilla.a).

-------------------

// Multiple selections
SetMultipleSelection(true);
// Type to multiple selections at the same time
SetAdditionalSelectionTyping(true);
// virtual spaces (go anywhere in the line even without text)
SetVirtualSpaceOptions(wxSCI_SCVS_RECTANGULARSELECTION
    | wxSCI_SCVS_USERACCESSIBLE); // I dont like this one for coding

[attachment deleted by admin]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: wxScintilla 2.01
« Reply #4 on: September 29, 2009, 09:52:02 am »
Well if someone is interested
Are you aware that we have a scintilla branch that uses 2.01 already?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline cgarcia109

  • Multiple posting newcomer
  • *
  • Posts: 24
Re: wxScintilla 2.01
« Reply #5 on: September 29, 2009, 01:08:00 pm »
I do. That version doesnt include new scintilla notifications nor DinamicLibraryImpl and miss some defines.
It was missing new scintilla files in proyect (selection.cxx|.h lexMarkDown.cxx)
I have changed too
-SCNotification scn = {{0}};
+SCNotification scn; memset((void*)&scn,0,sizeof(scn));

And cleaned some scintilla files of uneeded includes to keep it alligned with scintilla code

ScintillaWX.cxx was missing #include <new> that i think its needed to get exception from bad allocations now that all allocations checks has been removed from scintilla.

[attachment deleted by admin]
« Last Edit: September 29, 2009, 01:13:41 pm by cgarcia109 »

Offline cgarcia109

  • Multiple posting newcomer
  • *
  • Posts: 24
Re: wxScintilla 2.01
« Reply #6 on: September 29, 2009, 07:32:37 pm »
theres some issue with rectangular selections
when you do a rectangular selection if the last line (the one with the caret that become the mainrange) is empty GetSelectionStart() and GetSelectionEnd() returns the same value. In this case cbEditor::HasSelection() returns false..

In cbEditor::HasSelection()

- return control->GetSelectionStart() != control->GetSelectionEnd();
+ return control->GetSelections()>0;

------------

No, that doesnt do it. GetSelections() always return 1+
« Last Edit: September 29, 2009, 07:47:10 pm by cgarcia109 »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: wxScintilla 2.01
« Reply #7 on: September 29, 2009, 08:49:28 pm »
That version doesnt include new scintilla notifications
That's not really true... anyways... I synced your code with the one from the branch and there were some mods I will test and probably apply. But most of it was indeed already implemented, just in a different order. It's just that you missed some aspects (so did I ... ;-) so I cannot directly apply it.

-SCNotification scn = {{0}};
+SCNotification scn; memset((void*)&scn,0,sizeof(scn));
This doesn't really change anything but it is technically more correct. hence I believe it'll suck some more CPU power, so it needs testing.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: wxScintilla 2.01
« Reply #8 on: September 29, 2009, 08:52:02 pm »
when you do a rectangular selection if the last line (the one with the caret that become the mainrange) is empty
I'm afraid I don't understand... If the last line is empty the rectangular is reduced to basically "n lines down and 0 chars left". For me this is an "empty selection"... Could you please post an example when this is not the case? E.g. a code snippet?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: wxScintilla 2.01
« Reply #9 on: September 29, 2009, 09:43:33 pm »
Martin:
please don't switch multiple select and additional selection typing on as default.

It should be configurable.
It's an interesting feature, but I don't think it will be used very much and at least additional selection typing (or better typing and deleting at multiple postions at the same time) can be used accidently, especially if a user uses ctrl+left-click for browse-marks and it can be annoying to undo changes you did not want and to click into the editor to have only one caret again.

I think the options can be placed on the Margins and caret pane.

I can do that, if it's okay for you.
« Last Edit: September 29, 2009, 10:07:43 pm by jens »

Offline cgarcia109

  • Multiple posting newcomer
  • *
  • Posts: 24
Re: wxScintilla 2.01
« Reply #10 on: September 29, 2009, 10:25:05 pm »
Its related about discovering when there is a selection done or not. From the scintilla documentation its said to use GetSelectionStart()!=GetSelectionEnd(), but this is outdated.

The thing is that empty ranges are kept in the slection range list, and each range has its own anchor and caret.

GetSelectionStart() {
    return Platform::Minimum(sel.MainAnchor(), sel.MainCaret());
}
GetSelectionEnd() {
    return Platform::Maximum(sel.MainAnchor(), sel.MainCaret());
}

Where MainAnchor and MainCaret refers to the anchor and caret of the MainRange

I think its shown better with an image

Using virtual spaces:


Without virtual spaces(is a rectangular selection):


The last selected "line" is kept as the MainRange of the selection and this is the one used by GetSelectionStart|End calls
Since the last range is empty cbEditor::HasSelection() would return false in both cases, what its not true.
Actually cbEditor as it is now wont copy nothing to clipboard. This is only with rectangular selections.

Ive tried with GetRectangularSelection[Anchor|Caret] but is not perfect.
A vertical empty selection would have diferents anchor caret values returning true.

I think its better just to add a new function/message to wxScintilla
bool IsSelectionEmpty()  --> SCI_ISSELECTIONEMPTY --> return sel.Empty()

I dont understand why this message doesnt exits

please don't switch multiple select and additional selection typing on as default.

Yes they should be selectable, some ppl will like them other not.
« Last Edit: September 29, 2009, 10:35:35 pm by cgarcia109 »

Offline eranif

  • Regular
  • ***
  • Posts: 256
Re: wxScintilla 2.01
« Reply #11 on: September 29, 2009, 10:39:08 pm »
You should use this to determine whether you got a selection (the below code works for multiple selection as well as for rectangular selections):

Code
bool wxScintilla::HasSelection() {
        return SendMsg (SCI_GETSELTEXT, 0, 0) > 0;
}

Its the safest and correct way to do it:
http://www.scintilla.org/ScintillaDoc.html#SCI_GETSELTEXT

Eran
« Last Edit: September 29, 2009, 10:40:53 pm by eranif »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: wxScintilla 2.01
« Reply #12 on: September 29, 2009, 11:28:09 pm »
What about using:
Quote from:  http://www.scintilla.org/ScintillaDoc.html#SCI_GETSELECTIONS
SCI_GETSELECTIONS
        Return the number of selections currently active.

Offline cgarcia109

  • Multiple posting newcomer
  • *
  • Posts: 24
Re: wxScintilla 2.01
« Reply #13 on: September 30, 2009, 12:20:40 am »
Code
bool wxScintilla::HasSelection() {
        return SendMsg (SCI_GETSELTEXT, 0, 0) > 0;
}

After some test...
That doesnt works with rectangular selections, cos all ranges receive a final '\n' char. Using virtual spaces if you select some empty space it would return a string like '\n\n\n'
sel.Empty() doesnt work neither cos it checks caret and anchor in real and virtual positions, what doesnt works fine in all cases.
Its needed to check all ranges for real.
You cant trust a single range, most scintilla functionality works over all ranges.

At the end i think this is the better way to check for real selections:

    case SCI_ISSELECTIONEMPTY:
        for (size_t i=0; i<sel.Count(); i++) {
            if(sel.Range(i).anchor.Position() != sel.Range(i).caret.Position())
                return false;
        }
        return true;

or outside scintilla:

    cbStyledTextCtrl* control = GetControl();
    size_t sels = control->GetSelections();
    for (size_t i=0; i<sels ; i++) {
        if (control->GetSelectionNCaret(i) != control->GetSelectionNAnchor(i))
            return true;
    }
    return false;
       
SCI_GETSELECTIONS
        Return the number of selections currently active.
That the first i tried, make more sense, but scintilla always have a selection. The caret alone is an empty selection. That function always return 1+
« Last Edit: September 30, 2009, 02:36:38 am by cgarcia109 »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: wxScintilla 2.01
« Reply #14 on: September 30, 2009, 08:47:17 am »
I think the options can be placed on the Margins and caret pane.
I can do that, if it's okay for you.
I don't have any plans to switch that on by default. You can do it, if you like. Just please wait until I commit some pending modifications to the scintilla branch to avoid conflicts.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ