Esempio n. 1
0
        private void ExportBBCode()
        {
            TextEditor result = new TextEditor();

            result.FastStart = true;
            result.Editor.AutoComplete.List = null;
            result.Editor.Lexing.Lexer      = Lexer.Null;
            result.Editor.Text = "[CODE]\n";

            INativeScintilla NativeInterface = (INativeScintilla)Editor;
            int length = NativeInterface.GetLength();

            bool[] stylesUsed = new bool[(int)StylesCommon.Max + 1];

            for (int i = 0; i < length; i++)
            {
                stylesUsed[Editor.Styles.GetStyleAt(i) & (int)StylesCommon.Max] = true;
            }

            int TabWidth = Editor.Indentation.TabWidth;

            char lc;
            char c         = '\0';
            int  LastStyle = -1;

            for (int i = 0; i < length; i++)
            {
                lc = c;
                c  = NativeInterface.GetCharAt(i);
                int style = Editor.Styles.GetStyleAt(i);
                if (style != LastStyle && c != ' ')
                {
                    if (LastStyle != -1)
                    {
                        result.Append("[/COLOR]");
                    }

                    result.Append("[COLOR=\"{0}\"]", (Editor.Styles[style].ForeColor.Name == "ffc80000" ? "Red" : Editor.Styles[style].ForeColor.Name));
                    LastStyle = style;
                }

                if (c != '\0')
                {
                    result.Append(c);
                }
                else
                {
                    result.Append("\\0");
                }
            }
            if (LastStyle != -1)
            {
                result.Append("[/COLOR]");
            }
            result.AppendLine("[/CODE]");

            result.Show();
            result.filename = null;
        }
Esempio n. 2
0
        public void Invalidate()
        {
            if (Scintilla != null && Start > 0)
            {
                INativeScintilla _ns = Scintilla as INativeScintilla;
                int x = _ns.PointXFromPosition(Start);
                int y = _ns.PointYFromPosition(Start) + _ns.TextHeight(0) - 2;

                //	Invalidate the old Marker Location so that we don't get "Ghosts"
                Scintilla.Invalidate(new Rectangle(x - 2, y, 5, 5));
            }
        }
Esempio n. 3
0
        private void SimpleIndent(char ch)
        {
            if (ch == '\n')
            {
                INativeScintilla ns = m_editor as INativeScintilla;
                //just copy the previous line indentation
                Line currentLine = m_editor.Lines.FromPosition(m_editor.CurrentPos);
                ns.SetLineIndentation(currentLine.Number, ns.GetLineIndentation(currentLine.Number - 1));

                //place the caret at the end of the line
                m_editor.SetCaretAt(ns.GetLineIndentPosition(currentLine.Number));
                ns.ChooseCaretX();
            }
        }
Esempio n. 4
0
        protected internal override void Paint(Graphics g)
        {
            base.Paint(g);

            if (IsDisposed)
            {
                return;
            }

            INativeScintilla _ns = Scintilla as INativeScintilla;

            int x = _ns.PointXFromPosition(Start);
            int y = _ns.PointYFromPosition(Start) + _ns.TextHeight(0) - 2;

            //	Draw a red Triangle with a dark red border at the marker position
            g.FillPolygon(Brushes.Lime, new Point[] { new Point(x - 2, y + 4), new Point(x, y), new Point(x + 2, y + 4) });
            g.DrawPolygon(Pens.Green, new Point[] { new Point(x - 2, y + 4), new Point(x, y), new Point(x + 2, y + 4) });
        }
Esempio n. 5
0
        public void AutoIndent(char ch)
        {
            if (m_editor.Indentation.SmartIndentType == ScintillaNet.SmartIndent.CPP2)
            {
                return;
            }

            int curpos = m_editor.CurrentPos;

            if (IsComment(curpos) && ch == '\n')
            {
                // TODO wanted?  needed?
                //AutoAddComment();
                SimpleIndent(ch);
                return;
            }

            INativeScintilla ns = m_editor.NativeInterface;

            if (IsCommentOrString(curpos))
            {
                SimpleIndent(ch);

                return;
            }

            int line = ns.LineFromPosition(curpos);

            if (ch == '\n')
            {
                int    prevpos  = -1;
                int    foundPos = -1;
                string word;

                char prevChar = m_editor.PreviousChar(curpos, ref prevpos, false);
                word = m_editor.PreviousWord(curpos, ref foundPos);

                // user hit ENTER after 'else'
                if (word == "else")
                {
                    int prevLine   = ns.LineFromPosition(prevpos);
                    int prevIndent = ns.GetLineIndentation(prevLine);
                    ns.SetLineIndentation(line, prevIndent);
                    m_editor.SetCaretAt(ns.GetLineIndentPosition(line));
                    ns.ChooseCaretX();                     // set new column as "current" column
                    return;
                }

                // User typed 'ENTER' immediately after closing brace ')'
                if (prevpos != -1 && ch == ')')
                {
                    int openBracePos           = -1;
                    int posWordBeforeOpenBrace = -1;

                    if (m_editor.MatchBraceBack(')', prevpos, ref openBracePos))
                    {
                        m_editor.PreviousChar(openBracePos, ref posWordBeforeOpenBrace, false);
                        if (posWordBeforeOpenBrace != -1)
                        {
                            word = m_editor.PreviousWord(posWordBeforeOpenBrace, ref foundPos);

                            // c++ expression with single line and should be treated separatly
                            if (word == "if" || word == "while" || word == "for")
                            {
                                int prevLine = ns.LineFromPosition(prevpos);
                                ns.SetLineIndentation(line, ns.GetIndent() + ns.GetLineIndentation(prevLine));
                                m_editor.SetCaretAt(ns.GetLineIndentPosition(line));
                                ns.ChooseCaretX();                                 // set new column as "current" column
                                return;
                            }
                        }
                    }
                }

                // User typed 'ENTER' immediately after colons ':'
                if (prevpos != -1 && ch == ':')
                {
                    int posWordBeforeColons = -1;

                    m_editor.PreviousChar(prevpos, ref posWordBeforeColons, false);
                    if (posWordBeforeColons != -1)
                    {
                        word = m_editor.PreviousWord(posWordBeforeColons, ref foundPos);
                        int prevLine = ns.LineFromPosition(posWordBeforeColons);

                        // If we found one of the following keywords, un-indent their line by (foldLevel - 1)*indentSize
                        if (word == "public" || word == "private" || word == "protected")
                        {
                            SimpleIndent(ch);

                            // Indent this line according to the block indentation level

                            int foldLevel = (int)(ns.GetFoldLevel(prevLine) & (int)FoldLevel.NumberMask) - (int)FoldLevel.Base;
                            if (foldLevel > 0)
                            {
                                ns.SetLineIndentation(prevLine, ((foldLevel - 1) * ns.GetIndent()));
                                ns.ChooseCaretX();
                            }
                            return;
                        }
                    }
                }

                // use the previous line indentation level
                if (prevpos == -1 || ch != '{' || IsCommentOrString(prevpos))
                {
                    SimpleIndent(ch);
                    return;
                }

                // Open brace? increase indent size
                int prevLineNum = ns.LineFromPosition(prevpos);
                int indent2     = ns.GetIndent();
                int lineIndent  = ns.GetLineIndentation(prevLineNum);
                ns.SetLineIndentation(line, indent2 + lineIndent);                //ns.GetIndent() + ns.GetLineIndentation(prevLineNum));
                m_editor.SetCaretAt(ns.GetLineIndentPosition(line));
            }
            else if (ch == '}')
            {
                int matchPos = -1;
                if (!m_editor.MatchBraceBack('}', ns.PositionBefore(curpos), ref matchPos))
                {
                    return;
                }
                int secondLine = ns.LineFromPosition(matchPos);
                if (secondLine == line)
                {
                    return;
                }
                ns.SetLineIndentation(line, ns.GetLineIndentation(secondLine));
            }
            else if (ch == '{')
            {
                string lineString = m_editor.Lines[line].Text;
                lineString.Trim();

                int  matchPos     = -1;
                char previousChar = m_editor.PreviousChar(ns.PositionBefore(curpos), ref matchPos, false);

                if (previousChar != '{' && lineString == "{")
                {
                    // indent this line according to the previous line
                    int currLine = ns.LineFromPosition(m_editor.CurrentPos);
                    ns.SetLineIndentation(line, ns.GetLineIndentation(currLine - 1));
                    ns.ChooseCaretX();
                }
            }

            // set new column as "current" column
            ns.ChooseCaretX();
        }
Esempio n. 6
0
        public Scintilla()
        {
            this._state = new BitVector32(0);
            this._state[_acceptsReturnState] = true;
            this._state[_acceptsTabState] = true;

            _ns = (INativeScintilla)this;

            _caption = GetType().FullName;

            // Set up default encoding to UTF-8 which is the Scintilla's best supported.
            // .NET strings are UTF-16 but should be able to convert without any problems
            this.Encoding = Encoding.UTF8;

            // Ensure all style values have at least defaults
            _ns.StyleClearAll();

            _caret = new CaretInfo(this);
            _lines = new LineCollection(this);
            _selection = new Selection(this);
            _indicators = new IndicatorCollection(this);
            _snippets = new SnippetManager(this);
            _margins = new MarginCollection(this);
            _scrolling = new Scrolling(this);
            _whitespace = new Whitespace(this);
            _endOfLine = new EndOfLine(this);
            _clipboard = new Clipboard(this);
            _undoRedo = new UndoRedo(this);
            _dropMarkers = new DropMarkers(this);
            _hotspotStyle = new HotspotStyle(this);
            _callTip = new CallTip(this);
            _styles = new StyleCollection(this);
            _indentation = new Indentation(this);
            _markers = new MarkerCollection(this);
            _autoComplete = new AutoComplete(this);
            _documentHandler = new DocumentHandler(this);
            _lexing = new Lexing(this);
            _longLines = new LongLines(this);
            _commands = new Commands(this);
            _folding = new Folding(this);
            _configurationManager = new ConfigurationManager(this);
            _printing = new Printing(this);
            _findReplace = new FindReplace(this);
            _documentNavigation = new DocumentNavigation(this);
            _goto = new GoTo(this);

            _helpers.AddRange(new TopLevelHelper[]
            {
                _caret,
                _lines,
                _selection,
                _indicators,
                _snippets,
                _margins,
                _scrolling,
                _whitespace,
                _endOfLine,
                _clipboard,
                _undoRedo,
                _dropMarkers,
                _hotspotStyle,
                _styles,
                _indentation,
                _markers,
                _autoComplete,
                _documentHandler,
                _lexing,
                _longLines,
                _commands,
                _folding,
                _configurationManager,
                _printing,
                _findReplace,
                _documentNavigation,
                _goto
            });

            // Change from Scintilla's default black on white to
            // platform defaults for edit controls.
            base.BackColor = SystemColors.Window;
            base.ForeColor = SystemColors.WindowText;

            Styles[0].Font = Font;
            Styles[0].ForeColor = ForeColor;
            Styles[0].BackColor = BackColor;
            Styles.Default.BackColor = BackColor;
        }
Esempio n. 7
0
        public Scintilla()
        {
            // We don't want .NET to use GetWindowText because we manage ('cache') our own text
            SetStyle(ControlStyles.CacheText, true);

            // Necessary control styles (see TextBoxBase)
            SetStyle(ControlStyles.StandardClick
                   | ControlStyles.StandardDoubleClick
                   | ControlStyles.UseTextForAccessibility
                   | ControlStyles.UserPaint,
                   false);

            // It's critical that we initialize helpers that listen for notifications early and
            // in the correct order. They have to be the first to know when notifications occur.
            _lineStorage = new LineStorage(this);
            _stringAdapter = new StringAdapter(this, _lineStorage);

            _state = new BitVector32(0);
            _state[_acceptsReturnState] = true;
            _state[_acceptsTabState] = true;

            _ns = (INativeScintilla)this;

            _caption = GetType().FullName;

            // Most Windows Forms controls delay-load everything until a handle is created.
            // That's a major pain so we just explicity create a handle right away.
            CreateControl();

            // Set up default encoding to UTF-8 which is the Scintilla's best supported.
            // .NET strings are UTF-16 but should be able to convert without any problems
            this.Encoding = Encoding.UTF8;

            // Ensure all style values have at least defaults
            _ns.StyleClearAll();

            _caret = new CaretInfo(this);
            _lines = new LineCollection(this);
            _selection = new Selection(this);
            _snippets = new SnippetManager(this);
            _margins = new MarginCollection(this);
            _whitespace = new Whitespace(this);
            _endOfLine = new EndOfLine(this);
            _clipboard = new Clipboard(this);
            _undoRedo = new UndoRedo(this);
            _dropMarkers = new DropMarkers(this);
            _hotspotStyle = new HotspotStyle(this);
            _callTip = new CallTip(this);
            _styles = new StyleCollection(this);
            _indentation = new Indentation(this);
            _markers = new MarkerCollection(this);
            _autoComplete = new AutoComplete(this);
            _documentHandler = new DocumentHandler(this);
            _lexing = new Lexing(this);
            _longLines = new LongLines(this);
            _commands = new Commands(this);
            _folding = new Folding(this);
            _configurationManager = new ConfigurationManager(this);
            _printing = new Printing(this);
            _findReplace = CreateFindReplaceInstance();
            _documentNavigation = new DocumentNavigation(this);
            _goto = new GoTo(this);


            _helpers.AddRange(new TopLevelHelper[]
            {
                _caret,
                _lines,
                _selection,
                _snippets,
                _margins,
                _whitespace,
                _endOfLine,
                _clipboard,
                _undoRedo,
                _dropMarkers,
                _hotspotStyle,
                _styles,
                _indentation,
                _markers,
                _autoComplete,
                _documentHandler,
                _lexing,
                _longLines,
                _commands,
                _folding,
                _configurationManager,
                _printing,
                _findReplace,
                _documentNavigation,
                _goto
            });


            // Change from Scintilla's default black on white to
            // platform defaults for edit controls.
            base.BackColor = SystemColors.Window;
            base.ForeColor = SystemColors.WindowText;

            Styles[0].Font = Font;
            Styles[0].ForeColor = ForeColor;
            Styles[0].BackColor = BackColor;
            Styles.Default.BackColor = BackColor;

            // Change scrolling defaults
            DirectMessage(NativeMethods.SCI_SETSCROLLWIDTH, new IntPtr(1), IntPtr.Zero);
            DirectMessage(NativeMethods.SCI_SETSCROLLWIDTHTRACKING, new IntPtr(1), IntPtr.Zero);
        }
Esempio n. 8
0
 protected internal ScintillaHelperBase(Scintilla scintilla)
 {
     _scintilla       = scintilla;
     _nativeScintilla = (INativeScintilla)scintilla;
 }
Esempio n. 9
0
        public Scintilla()
        {
            if (IntPtr.Size == 4)
                _sciLexerDllName = "DbDiff.SciLexer32.dll";
            else
                _sciLexerDllName = "DbDiff.SciLexer64.dll";
            _ns = (INativeScintilla)this;

            // Set up default encoding
            _encoding = Encoding.GetEncoding(NativeInterface.GetCodePage());

            //	Ensure all style values have at least defaults
            _ns.StyleClearAll();

            _caret					= new CaretInfo(this);
            _lines					= new LinesCollection(this);
            _selection				= new Selection(this);
            _indicators				= new IndicatorCollection(this);
            _margins				= new MarginCollection(this);
            _scrolling				= new Scrolling(this);
            _whiteSpace				= new WhiteSpace(this);
            _endOfLine				= new EndOfLine(this);
            _clipboard				= new Clipboard(this);
            _undoRedo				= new UndoRedo(this);
            _dropMarkers			= new DropMarkers(this);
            _hotspotStyle			= new HotspotStyle(this);
            _callTip				= new CallTip(this);
            _styles					= new StyleCollection(this);
            _indentation			= new Indentation(this);
            _documentHandler		= new DocumentHandler(this);
            _lineWrap				= new LineWrap(this);
            _lexing					= new Lexing(this);
            _longLines				= new LongLines(this);
            _commands				= new Commands(this);
            _configurationManager	= new ConfigurationManager(this);
            _printing				= new Printing(this);
            _documentNavigation		= new DocumentNavigation(this);
            _goto					= new GoTo(this);

            _helpers.AddRange(new ScintillaHelperBase[]
            {
                _caret,
                _lines,
                _selection,
                _indicators,
                _margins,
                _scrolling,
                _whiteSpace,
                _endOfLine,
                _clipboard,
                _undoRedo,
                _dropMarkers,
                _hotspotStyle,
                _styles,
                _indentation,
                _documentHandler,
                _lineWrap,
                _lexing,
                _longLines,
                _commands,
                _configurationManager,
                _printing,
                _documentNavigation,
                _goto
            });

            //	Changing the Default values from Scintilla's default Black on White
            //	to platform defaults for Edits
            BackColor = SystemColors.Window;
            ForeColor = SystemColors.WindowText;
        }
Esempio n. 10
0
        public LuaScriptEditPane(LuaForAGSEditorComponent parentComponent, IAGSEditor owningEditor, LuaScriptFileInfo scriptInfo)
        {
            this.parentComponent = parentComponent;
            ScriptInfo = scriptInfo;
            InitializeComponent();
            editor = owningEditor;
            textBox1.Select(0, 0);
            textBox1.Hide();

            scintillaWrapper = new Scintilla();
            scintilla = scintillaWrapper.NativeInterface;

            scintillaWrapper.Parent = this;
            scintillaWrapper.Location = textBox1.Location;
            scintillaWrapper.Size = textBox1.Size;
            scintillaWrapper.Anchor = textBox1.Anchor;

            scintilla.RegisterImage(1, ResourceManager.GetResourceAsString("table.xpm"));

            scintilla.SetMarginWidthN(0, 32);
            scintilla.SetMarginTypeN(0, (int)MarginType.Number);

            scintillaWrapper.Folding.Flags = FoldFlag.LineAfterContracted;
            scintilla.SetMarginWidthN(2, 16);
            scintilla.SetMarginTypeN(2, (int)MarginType.Symbol);
            scintilla.MarkerDefine((int)MarkerOutline.FolderOpen, (int)MarkerSymbol.BoxMinus);
            scintilla.MarkerDefine((int)MarkerOutline.Folder, (int)MarkerSymbol.BoxPlus);
            scintilla.MarkerDefine((int)MarkerOutline.FolderSub, (int)MarkerSymbol.VLine);
            scintilla.MarkerDefine((int)MarkerOutline.FolderTail, (int)MarkerSymbol.LCorner);
            scintilla.MarkerDefine((int)MarkerOutline.FolderEnd, (int)MarkerSymbol.BoxPlusConnected);
            scintilla.MarkerDefine((int)MarkerOutline.FolderOpenMid, (int)MarkerSymbol.BoxMinusConnected);
            scintilla.MarkerDefine((int)MarkerOutline.FolderMidTail, (int)MarkerSymbol.TCorner);
            scintilla.SetMarginSensitiveN(2, true);

            /*
            scintillaWrapper.Folding.Flags = FoldFlag.LineBeforeContracted | FoldFlag.LineAfterExpanded;

            scintilla.SetMarginWidthN(2, 16);
            scintilla.SetMarginTypeN(2, (int)MarginType.Symbol);
            scintilla.MarkerDefine((int)MarkerOutline.FolderOpen, (int)MarkerSymbol.BoxMinus);
            scintilla.MarkerDefine((int)MarkerOutline.Folder, (int)MarkerSymbol.BoxPlus);
            scintilla.MarkerDefine((int)MarkerOutline.FolderSub, (int)MarkerSymbol.VLine);
            scintilla.MarkerDefine((int)MarkerOutline.FolderTail, (int)MarkerSymbol.LCorner);
            scintilla.MarkerDefine((int)MarkerOutline.FolderEnd, (int)MarkerSymbol.BoxPlusConnected);
            scintilla.MarkerDefine((int)MarkerOutline.FolderOpenMid, (int)MarkerSymbol.BoxMinusConnected);
            scintilla.MarkerDefine((int)MarkerOutline.FolderMidTail, (int)MarkerSymbol.TCorner);
            scintilla.SetMarginSensitiveN(2, true);
             */

            scintillaWrapper.Font = codeFont;
            for (int i = 0; i <= 32; i++)
            {
                scintillaWrapper.Styles[i].Font = codeFont;
            }
            scintillaWrapper.Lexing.Lexer = Lexer.Lua;
            scintillaWrapper.Styles[0].ForeColor = Color.FromArgb(0, 0, 0);
            scintillaWrapper.Styles[1].ForeColor = Color.FromArgb(0, 127, 0);
            scintillaWrapper.Styles[2].ForeColor = Color.FromArgb(0, 127, 0);
            scintillaWrapper.Styles[3].ForeColor = Color.FromArgb(127, 127, 127);
            scintillaWrapper.Styles[4].ForeColor = Color.FromArgb(0, 150, 175);
            scintillaWrapper.Styles[5].ForeColor = Color.FromArgb(0, 0, 127);
            scintillaWrapper.Styles[5].Bold = true;
            scintillaWrapper.Styles[6].ForeColor = Color.FromArgb(170, 0, 170);
            scintillaWrapper.Styles[7].ForeColor = Color.FromArgb(170, 0, 170);
            scintillaWrapper.Styles[8].ForeColor = Color.FromArgb(170, 0, 170);
            scintillaWrapper.Styles[9].ForeColor = Color.FromArgb(0, 0, 0);

            // Standard library keywords
            scintillaWrapper.Styles[12].ForeColor = Color.FromArgb(0, 0, 0);
            scintillaWrapper.Styles[12].BackColor = Color.FromArgb(224, 192, 224);
            scintillaWrapper.Styles[12].Bold = true;
            scintillaWrapper.Styles[12].IsSelectionEolFilled = true;

            // Brace match
            scintillaWrapper.Styles[34].ForeColor = Color.FromArgb(47, 47, 255);
            scintillaWrapper.Styles[34].Bold = true;
            // Brace mismatch
            scintillaWrapper.Styles[35].ForeColor = Color.FromArgb(255, 47, 47);
            scintillaWrapper.Styles[35].Bold = true;

            scintillaWrapper.Styles[13].ForeColor = Color.FromArgb(120, 156, 124);
            scintillaWrapper.Styles[13].Bold = true;
            scintillaWrapper.Styles[13].IsSelectionEolFilled = true;

            scintilla.UpdateUI += Scintilla_UpdateUI;

            scintillaWrapper.AutoComplete.CancelAtStart = false;
            scintillaWrapper.AutoComplete.AutoHide = false;
            scintillaWrapper.AutoComplete.MaxHeight = 8;
            scintillaWrapper.AutoComplete.MaxWidth = 100;
            scintillaWrapper.AutoComplete.StopCharacters = ")}; ";

            scintillaWrapper.Indentation.UseTabs = false;
            scintillaWrapper.Indentation.TabWidth = 2;
            scintillaWrapper.Indentation.IndentWidth = 2;
            scintillaWrapper.Caret.HighlightCurrentLine = true;
            scintillaWrapper.Caret.CurrentLineBackgroundColor = Color.FromArgb(232, 232, 255);
            scintillaWrapper.Lexing.SetKeywords(0, @"
                and break do else elseif end false for function if in local
                nil not or repeat return then true until while");
            scintillaWrapper.Lexing.SetKeywords(1, @"
                _G _VERSION assert collectgarbage dofile error getfenv getmetatable
                ipairs load loadfile loadstring module next pairs pcall print rawequal
                rawget rawset require select setfenv setmetatable tonumber tostring type
                unpack xpcall
                coroutine.create coroutine.resume coroutine.running coroutine.status coroutine.wrap
                coroutine.yield

                debug.debug debug.getfenv debug.gethook debug.getinfo debug.getlocal debug.getmetatable
                debug.getregistry debug.getupvalue debug.setfenv debug.sethook debug.setlocal
                debug.setmetatable debug.setupvalue debug.traceback

                io.close io.flush io.input io.lines io.open io.output io.popen io.read io.stderr io.stdin
                io.stdout io.tmpfile io.type io.write

                math.abs math.acos math.asin math.atan math.atan2 math.ceil math.cos math.cosh math.deg
                math.exp math.floor math.fmod math.frexp math.huge math.ldexp math.log math.log10 math.max
                math.min math.modf math.pi math.pow math.rad math.random math.randomseed math.sin
                math.sinh math.sqrt math.tan math.tanh

                os.clock os.date os.difftime os.execute os.exit os.getenv os.remove os.rename os.setlocale
                os.time os.tmpname

                package.cpath package.loaded package.loaders package.loadlib package.path package.preload
                package.seeall

                string.byte string.char string.dump string.find string.format string.gmatch string.gsub
                string.len string.lower string.match string.rep string.reverse string.sub string.upper

                table.concat table.insert table.maxn table.remove table.sort");
            scintillaWrapper.CharAdded += Scintilla_CharAdded;
            scintillaWrapper.Scrolling.HorizontalWidth = 80;

            SetText(File.ReadAllText(path));
            scintilla.SetSavePoint();
            scintillaWrapper.UndoRedo.EmptyUndoBuffer();
        }
Esempio n. 11
0
 protected internal ScintillaHelperBase(Scintilla scintilla)
 {
     _scintilla = scintilla;
     _nativeScintilla = (INativeScintilla)scintilla;
 }
 protected internal ScintillaHelperBase(Scintilla scintilla)
 {
     this._scintilla = scintilla;
     this._nativeScintilla = scintilla;
 }
Esempio n. 13
0
        private void CodeConvertPane_Load(object sender, EventArgs e)
        {
            agsEditWrapper = new Scintilla();
            agsEdit = agsEditWrapper.NativeInterface;
            luaOutputWrapper = new Scintilla();
            luaOutput = luaOutputWrapper.NativeInterface;

            agsCodeEntry.Hide();
            agsEditWrapper.Parent = agsCodeEntry.Parent;
            agsEditWrapper.Location = agsCodeEntry.Location;
            agsEditWrapper.Size = agsCodeEntry.Size;
            agsEditWrapper.Anchor = agsCodeEntry.Anchor;
            agsEditWrapper.Font = codeFont;
            agsEditWrapper.Lexing.Lexer = Lexer.Cpp;
            agsEditWrapper.Text = "// AGS Code Entry";
            agsEditWrapper.UndoRedo.EmptyUndoBuffer();

            luaCodeOutput.Hide();
            luaOutputWrapper.Parent = luaCodeOutput.Parent;
            luaOutputWrapper.Location = luaCodeOutput.Location;
            luaOutputWrapper.Size = luaCodeOutput.Size;
            luaOutputWrapper.Anchor = luaCodeOutput.Anchor;
            luaOutputWrapper.Font = codeFont;
            luaOutputWrapper.Lexing.Lexer = Lexer.Lua;
            luaOutputWrapper.Text = "-- Converted Lua Code Output";
            luaOutputWrapper.IsReadOnly = true;

            agsEditWrapper.Styles[0].ForeColor = Color.FromArgb(0, 0, 0);
            agsEditWrapper.Styles[1].ForeColor = Color.FromArgb(0, 127, 0);
            agsEditWrapper.Styles[2].ForeColor = Color.FromArgb(0, 127, 0);
            agsEditWrapper.Styles[3].ForeColor = Color.FromArgb(127, 127, 127);
            agsEditWrapper.Styles[4].ForeColor = Color.FromArgb(0, 150, 175);
            agsEditWrapper.Styles[5].ForeColor = Color.FromArgb(0, 0, 127);
            agsEditWrapper.Styles[5].Bold = true;
            agsEditWrapper.Styles[6].ForeColor = Color.FromArgb(170, 0, 170);
            agsEditWrapper.Styles[7].ForeColor = Color.FromArgb(170, 0, 170);
            agsEditWrapper.Styles[8].ForeColor = Color.FromArgb(170, 0, 170);
            agsEditWrapper.Styles[9].ForeColor = Color.FromArgb(0, 0, 0);
            agsEditWrapper.Styles[13].ForeColor = Color.FromArgb(120, 156, 124);
            agsEditWrapper.Styles[13].Bold = true;
            agsEditWrapper.Styles[13].IsSelectionEolFilled = true;
            agsEditWrapper.Lexing.SetKeywords(0, @"
                if while int float bool char true false short else return this noloopcheck new null");

            // Standard library keywords
            agsEditWrapper.Styles[12].ForeColor = Color.FromArgb(0, 0, 0);
            agsEditWrapper.Styles[12].BackColor = Color.FromArgb(224, 192, 224);
            agsEditWrapper.Styles[12].Bold = true;
            agsEditWrapper.Styles[12].IsSelectionEolFilled = true;

            luaOutputWrapper.Styles[0].ForeColor = Color.FromArgb(0, 0, 0);
            luaOutputWrapper.Styles[1].ForeColor = Color.FromArgb(0, 127, 0);
            luaOutputWrapper.Styles[2].ForeColor = Color.FromArgb(0, 127, 0);
            luaOutputWrapper.Styles[3].ForeColor = Color.FromArgb(127, 127, 127);
            luaOutputWrapper.Styles[4].ForeColor = Color.FromArgb(0, 150, 175);
            luaOutputWrapper.Styles[5].ForeColor = Color.FromArgb(0, 0, 127);
            luaOutputWrapper.Styles[5].Bold = true;
            luaOutputWrapper.Styles[6].ForeColor = Color.FromArgb(170, 0, 170);
            luaOutputWrapper.Styles[7].ForeColor = Color.FromArgb(170, 0, 170);
            luaOutputWrapper.Styles[8].ForeColor = Color.FromArgb(170, 0, 170);
            luaOutputWrapper.Styles[9].ForeColor = Color.FromArgb(0, 0, 0);
            luaOutputWrapper.Styles[13].ForeColor = Color.FromArgb(120, 156, 124);
            luaOutputWrapper.Styles[13].Bold = true;
            luaOutputWrapper.Styles[13].IsSelectionEolFilled = true;

            // Standard library keywords
            luaOutputWrapper.Styles[12].ForeColor = Color.FromArgb(0, 0, 0);
            luaOutputWrapper.Styles[12].BackColor = Color.FromArgb(224, 192, 224);
            luaOutputWrapper.Styles[12].Bold = true;
            luaOutputWrapper.Styles[12].IsSelectionEolFilled = true;

            for (int i = 0; i < luaOutputWrapper.Margins.Count; i++)
            {
                luaOutputWrapper.Margins[i].Width = 0;
            }

            for (int i = 0; i < agsEditWrapper.Margins.Count; i++)
            {
                agsEditWrapper.Margins[i].Width = 0;
            }

            luaOutputWrapper.Indentation.UseTabs = false;
            luaOutputWrapper.Indentation.TabWidth = 2;
            luaOutputWrapper.Indentation.IndentWidth = 2;
            luaOutputWrapper.Lexing.SetKeywords(0, @"
                and break do else elseif end false for function if in local
                nil not or repeat return then true until while");

            for (int i = 0; i <= 32; i++)
            {
                agsEditWrapper.Styles[i].Font = codeFont;
                luaOutputWrapper.Styles[i].Font = codeFont;
            }
        }