示例#1
0
    //Called by PanelEdit.ZOpen.
    internal void Init_(byte[] text, bool newFile, bool noTemplate)
    {
        //if(Hwnd.Is0) CreateHandle();
        Debug.Assert(!Hwnd.Is0);

        bool editable = _fls.SetText(this, text);

        SetLineNumberMarginWidth_();

        if (newFile)
        {
            _openState = noTemplate ? _EOpenState.NewFileNoTemplate : _EOpenState.NewFileFromTemplate;
        }
        else if (App.Model.OpenFiles.Contains(_fn))
        {
            _openState = _EOpenState.Reopen;
        }

        if (_fn.IsCodeFile)
        {
            CiStyling.DocTextAdded(this, newFile);
        }

        App.Model.EditGoBack.OnPosChanged(this);

        //detect \r without '\n', because it is not well supported
        if (editable)
        {
            bool badCR = false;
            for (int i = 0, n = text.Length - 1; i <= n; i++)
            {
                if (text[i] == '\r' && (i == n || text[i + 1] != '\n'))
                {
                    badCR = true;
                }
            }
            if (badCR)
            {
                print.it($@"<>Note: text of {_fn.Name} contains single \r (CR) as line end characters. It can create problems. <+badCR s>Show<>, <+badCR h>hide<>, <+badCR f>fix<>.");
                if (!s_badCR)
                {
                    s_badCR = true;
                    Panels.Output.ZOutput.ZTags.AddLinkTag("+badCR", s1 => {
                        bool fix = s1.Starts('f');
                        Panels.Editor.ZActiveDoc?.Call(fix ? SCI_CONVERTEOLS : SCI_SETVIEWEOL, fix || s1.Starts('h') ? 0 : 1);                         //tested: SCI_CONVERTEOLS ignored if readonly
                    });
                }
            }
        }
    }
示例#2
0
文件: SciCode.cs 项目: alexfordc/Au
    protected override void OnHandleCreated(EventArgs e)
    {
        base.OnHandleCreated(e);

        Call(SCI_SETMODEVENTMASK, (int)(MOD.SC_MOD_INSERTTEXT | MOD.SC_MOD_DELETETEXT /*| MOD.SC_MOD_INSERTCHECK*/));

        Call(SCI_SETLEXER, (int)LexLanguage.SCLEX_NULL);         //default SCLEX_CONTAINER

        Call(SCI_SETMARGINTYPEN, c_marginLineNumbers, SC_MARGIN_NUMBER);
        Z.MarginWidth(c_marginLineNumbers, 40 * Au.Util.ADpi.BaseDPI / 96);

        _InicatorsInit();

        if (_fn.IsCodeFile)
        {
            //C# interprets Unicode newline characters NEL, LS and PS as newlines. Visual Studio too.
            //	Scintilla and C++ lexer support it, but by default it is disabled.
            //	If disabled, line numbers in errors/warnings/stacktraces may be incorrect.
            //	Ascii VT and FF are not interpreted as newlines by C# and Scintilla.
            //	Not tested, maybe this must be set for each document in the control.
            //	Scintilla controls without C++ lexer don't support it.
            //		But if we temporarily set C++ lexer for <code>, newlines are displayed in whole text.
            //	Somehow this disables <fold> tag, therefore now not used for output etc.
            Call(SCI_SETLINEENDTYPESALLOWED, 1);

            Call(SCI_SETMOUSEDWELLTIME, 500);

            CiStyling.DocHandleCreated(this);

            //Call(SCI_ASSIGNCMDKEY, 3 << 16 | 'C', SCI_COPY); //Ctrl+Shift+C = raw copy

            //Z.StyleFont(STYLE_CALLTIP, "Calibri");
            //Z.StyleBackColor(STYLE_CALLTIP, 0xf8fff0);
            //Z.StyleForeColor(STYLE_CALLTIP, 0);
            //Call(SCI_CALLTIPUSESTYLE);
        }
        else
        {
            Z.StyleFont(STYLE_DEFAULT, "Consolas", 9);
            Z.StyleClearAll();
        }

        Z.StyleForeColor(STYLE_INDENTGUIDE, 0xcccccc);
        Call(SCI_SETINDENTATIONGUIDES, SC_IV_REAL);

        //Call(SCI_SETXCARETPOLICY, CARET_SLOP | CARET_EVEN, 20); //does not work

        //Call(SCI_SETVIEWWS, 1); Call(SCI_SETWHITESPACEFORE, 1, 0xcccccc);
    }
示例#3
0
文件: SciCode.cs 项目: alexfordc/Au
 //Called by PanelEdit.ZOpen.
 internal void _Init(byte[] text, bool newFile)
 {
     if (!IsHandleCreated)
     {
         CreateHandle();
     }
     _fls.SetText(Z, text);
     if (newFile)
     {
         _openState = 1;
     }
     if (_fn.IsCodeFile)
     {
         CiStyling.DocTextAdded(this, newFile);
     }
 }
示例#4
0
    protected override void ZOnHandleCreated()
    {
        Call(SCI_SETMODEVENTMASK, (int)(MOD.SC_MOD_INSERTTEXT | MOD.SC_MOD_DELETETEXT /*| MOD.SC_MOD_INSERTCHECK | MOD.SC_MOD_BEFOREINSERT*/
                                                                                      //| MOD.SC_MOD_CHANGEFOLD //only when text modified, but not when user clicks +-
                                        ));

        zSetMarginType(c_marginFold, SC_MARGIN_SYMBOL);
        zSetMarginType(c_marginImages, SC_MARGIN_SYMBOL);
        Call(SCI_SETMARGINWIDTHN, c_marginImages, 0);
        zSetMarginType(c_marginMarkers, SC_MARGIN_SYMBOL);
        zSetMarginType(c_marginLineNumbers, SC_MARGIN_NUMBER);
        //zSetMarginType(c_marginChanges, SC_MARGIN_SYMBOL);
        Call(SCI_SETMARGINWIDTHN, c_marginChanges, 4);
        Call(SCI_SETMARGINLEFT, 0, 2);

        _InicatorsInit();

        Call(SCI_SETWRAPMODE, App.Settings.edit_wrap ? SC_WRAP_WORD : 0);
        Call(SCI_ASSIGNCMDKEY, Math2.MakeLparam(SCK_RETURN, SCMOD_CTRL | SCMOD_SHIFT), SCI_NEWLINE);

        if (_fn.IsCodeFile)
        {
            Call(SCI_SETEXTRADESCENT, 1);             //eg to avoid drawing fold separator lines on text

            Call(SCI_SETCARETLINEFRAME, 1);
            Call(SCI_SETELEMENTCOLOUR, SC_ELEMENT_CARET_LINE_BACK, 0xEEEEEE);
            Call(SCI_SETCARETLINEVISIBLEALWAYS, 1);

            //C# interprets Unicode newline characters NEL, LS and PS as newlines. Visual Studio too.
            //	Scintilla and C++ lexer support it, but by default it is disabled.
            //	If disabled, line numbers in errors/warnings/stacktraces may be incorrect.
            //	Ascii VT and FF are not interpreted as newlines by C# and Scintilla.
            //	Not tested, maybe this must be set for each document in the control.
            //	Scintilla controls without C++ lexer don't support it.
            //		But if we temporarily set C++ lexer for <code>, newlines are displayed in whole text.
            //	Somehow this disables <fold> tag, therefore now not used for output etc.
            Call(SCI_SETLINEENDTYPESALLOWED, 1);

            Call(SCI_SETMOUSEDWELLTIME, 500);

            CiStyling.DocHandleCreated(this);

            //Call(SCI_ASSIGNCMDKEY, 3 << 16 | 'C', SCI_COPY); //Ctrl+Shift+C = raw copy

            //zStyleFont(STYLE_CALLTIP, "Calibri");
            //zStyleBackColor(STYLE_CALLTIP, 0xf8fff0);
            //zStyleForeColor(STYLE_CALLTIP, 0);
            //Call(SCI_CALLTIPUSESTYLE);
        }
        else
        {
            zStyleFont(STYLE_DEFAULT, "Consolas", 9);
            zStyleClearAll();
        }

        zStyleForeColor(STYLE_INDENTGUIDE, 0xcccccc);
        Call(SCI_SETINDENTATIONGUIDES, SC_IV_REAL);

        //Call(SCI_SETXCARETPOLICY, CARET_SLOP | CARET_EVEN, 20); //does not work

        //Call(SCI_SETVIEWWS, 1); Call(SCI_SETWHITESPACEFORE, 1, 0xcccccc);

        _InitDragDrop();

        //base.ZOnHandleCreated();
    }