Example #1
0
        /// <summary>
        /// Handle selection change events (when the caret changes the position).
        /// </summary>
        /// <param name="s"></param>
        /// <param name="e"></param>
        private void HandleUpdateUI(object s, UpdateUIEventArgs e)
        {
            // handle selection changed events
            switch (e.Change)
            {
            case UpdateChange.Selection:
                // Update indicators only if the editor is in focus. This
                // is necessary, because they are also used by 'Find & Replace'.
                if (Focused)
                {
                    // get whole words from selections and get ranges from these words
                    var ranges = FindWordRanges(GetWordsFromSelections());
                    // highlight all selected words
                    ClearIndicators(HighlightIndicatorIndex);
                    AddIndicators(HighlightIndicatorIndex, ranges);
                }
                break;

            case UpdateChange.HScroll:
            case UpdateChange.VScroll:
                // call mouse scroll events
                MouseScroll?.Invoke(this, e);
                // update code folding
                UpdateCodeFolding(FirstVisibleLine, LastVisibleLine);
                break;
            }
        }
Example #2
0
 private void scintillaControl_UpdateUI(object sender, UpdateUIEventArgs e)
 {
     int caretPosition = _scintillaControl.CurrentPosition;
     if (_lastCaretPosition != caretPosition)
     {
         _lastCaretPosition = caretPosition;
         if (PositionChange != null)
             PositionChange(caretPosition);
     }
     bool overtype = _scintillaControl.Overtype;
     if (_lastOvertype != overtype)
     {
         _lastOvertype = overtype;
         if (OvertypeChange != null)
             OvertypeChange(overtype);
     }
 }
Example #3
0
 private void OnScintillaUpdateUI(object sender, UpdateUIEventArgs eventArgs)
 {
     if (eventArgs.Change == UpdateChange.VScroll) {
         this.UpdateLineNumbers();
     }
 }
Example #4
0
 /// <summary>
 /// Handle selection change events (when the caret changes the position).
 /// </summary>
 /// <param name="s"></param>
 /// <param name="e"></param>
 private void HandleUpdateUI(object s, UpdateUIEventArgs e)
 {
     // handle selection changed events
     switch (e.Change)
     {
         case UpdateChange.Selection:
             // Update indicators only if the editor is in focus. This
             // is necessary, because they are also used by 'Find & Replace'.
             if (Focused)
             {
                 // get whole words from selections and get ranges from these words
                 var ranges = FindWordRanges(GetWordsFromSelections());
                 // highlight all selected words
                 ClearIndicators(HighlightIndicatorIndex);
                 AddIndicators(HighlightIndicatorIndex, ranges);
             }
             break;
         case UpdateChange.HScroll:
         case UpdateChange.VScroll:
             // update code folding
             UpdateCodeFolding(FirstVisibleLine, LastVisibleLine);
             break;
     }
 }
Example #5
0
        private void scintillaControl_UpdateUI(object sender, UpdateUIEventArgs e)
        {
            // Has the caret changed position?
            var caretPosition = _scintillaControl.CurrentPosition;
            if (_lastCaretPosition != caretPosition)
            {
                _lastCaretPosition = caretPosition;
                BraceInfo braceInfo = GetCurrentBraceInfo();

                if (braceInfo != null)
                {
                    int bracePosition2 = _scintillaControl.BraceMatch(braceInfo.Position);
                    if (bracePosition2 == Scintilla.InvalidPosition)
                        _scintillaControl.BraceBadLight(braceInfo.Position);
                    else
                        _scintillaControl.BraceHighlight(braceInfo.Position, bracePosition2);
                }
                else
                    _scintillaControl.BraceHighlight(Scintilla.InvalidPosition, Scintilla.InvalidPosition);
            }
        }
Example #6
0
        private void codeBox_UpdateUI(object sender, UpdateUIEventArgs e)
        {
            const string openBraces = "([{";
            const string closeBraces = ")]}";

            var caretPos = _codeBox.CurrentPosition;
            if (caretPos != _lastCaretPos)
            {
                int lastLine = _codeBox.LineFromPosition(_lastCaretPos);
                int currentLine = _codeBox.LineFromPosition(caretPos);
                _codeBox.MarkerDeleteAll(3);
                if (_highlightLine)
                    _codeBox.Lines[currentLine].MarkerAdd(3);
                char charBefore = (char)_codeBox.GetCharAt(caretPos - 1);
                char charAfter = (char)_codeBox.GetCharAt(caretPos);
                int brace1Pos = Scintilla.InvalidPosition;
                if (closeBraces.Contains(charBefore))
                    brace1Pos = caretPos - 1;
                else if (openBraces.Contains(charAfter))
                    brace1Pos = caretPos;
                if (brace1Pos != Scintilla.InvalidPosition)
                {
                    int brace2Pos = _codeBox.BraceMatch(brace1Pos);
                    if (brace2Pos != Scintilla.InvalidPosition)
                        _codeBox.BraceHighlight(brace1Pos, brace2Pos);
                    else
                        _codeBox.BraceBadLight(brace1Pos);
                }
                else
                {
                    _codeBox.BraceHighlight(Scintilla.InvalidPosition, Scintilla.InvalidPosition);
                }
                _lastCaretPos = caretPos;
            }
        }
		/// <summary>
		/// Update the status bar when something has changed.
		/// </summary>
		private void ConfigurationEditor_UpdateUI ( object sender, UpdateUIEventArgs e )
		   {
			UpdateStatusbar ( ) ;
		    }
 private void scintilla1_UpdateUI(object sender, UpdateUIEventArgs e)
 {
     if ((e.Change & UpdateChange.Selection) > 0)
     {
         if (OnSelectionChanged != null)
         {
             OnSelectionChanged(this, e);
         }
     }
 }
Example #9
0
        private void scintilla_UpdateUI(object sender, UpdateUIEventArgs e)
        {
            int i = tabControl1.SelectedIndex;
            if (ismodified[i] == true)
            {
                if (hasstar[i] == false)
                {
                    string s = tabControl1.SelectedTab.Text;
                    s = s.Remove(s.Length - 9);
                    s += " *        X";
                    tabControl1.SelectedTab.Text = s;
                    hasstar[i] = true;
                }
            }

            if (tabControl1.SelectedTab.Controls.ContainsKey("body"))
            {
                Scintilla body = (Scintilla)tabControl1.SelectedTab.Controls["body"];
                //Line number check
                toolStripStatusLabel1.Text = "Line: " + (body.CurrentLine + 1).ToString();
                toolStripStatusLabel2.Text = "Column: " + body.GetColumn(body.CurrentPosition).ToString();

                //Brace highlighting
                // Has the caret changed position?
                var caretPos = body.CurrentPosition;
                if (lastCaretPos != caretPos)
                {
                    lastCaretPos = caretPos;
                    var bracePos1 = -1;
                    var bracePos2 = -1;

                    // Is there a brace to the left or right?
                    if (caretPos > 0 && IsBrace(body.GetCharAt(caretPos - 1)))
                        bracePos1 = (caretPos - 1);
                    else if (IsBrace(body.GetCharAt(caretPos)))
                        bracePos1 = caretPos;

                    if (bracePos1 >= 0)
                    {
                        // Find the matching brace
                        bracePos2 = body.BraceMatch(bracePos1);
                        if (bracePos2 == Scintilla.InvalidPosition)
                        {
                            body.BraceBadLight(bracePos1);
                            body.HighlightGuide = 0;
                        }
                        else
                        {
                            body.BraceHighlight(bracePos1, bracePos2);
                            body.HighlightGuide = body.GetColumn(bracePos1);
                        }
                    }
                    else
                    {
                        // Turn off brace matching
                        body.BraceHighlight(Scintilla.InvalidPosition, Scintilla.InvalidPosition);
                        body.HighlightGuide = 0;
                    }
                }
            }
        }
Example #10
0
        //smart select
        private void scEdit_UpdateUI(object sender, UpdateUIEventArgs e)
        {
            //selection changed - smart highlight
              if ((e.Change & UpdateChange.Selection) > 0) {
            string ss = scEdit.SelectedText;
            if (ss.Length > 3 && ss.IndexOfAny(new char[] { ' ', '(', ')' }) == -1) HighlightText(ss);
            else if(!tbFind.Visible) HighlightText("");
              }
              //caret moved - brace matching
              var caretPos = scEdit.CurrentPosition;
              if (lastCaretPos != caretPos) {
            lastCaretPos = caretPos;
            var bracePos1 = -1;
            var bracePos2 = -1;

            // Is there a brace to the left or right?
            if (caretPos > 0 && IsBrace(scEdit.GetCharAt(caretPos - 1))) bracePos1 = (caretPos - 1);
            else if (IsBrace(scEdit.GetCharAt(caretPos))) bracePos1 = caretPos;

            if (bracePos1 >= 0) {
              // Find the matching brace
              bracePos2 = scEdit.BraceMatch(bracePos1);
              if (bracePos2 == Scintilla.InvalidPosition) {
            scEdit.BraceBadLight(bracePos1);
            scEdit.HighlightGuide = 0;
              }
              else {
            scEdit.BraceHighlight(bracePos1, bracePos2);
            scEdit.HighlightGuide = scEdit.GetColumn(bracePos1);
              }
            }
            else {
              // Turn off brace matching
              scEdit.BraceHighlight(Scintilla.InvalidPosition, Scintilla.InvalidPosition);
              scEdit.HighlightGuide = 0;
            }
              }
        }
Example #11
0
 /// <summary>
 /// Invokes ContainerLexer in Visible mode
 /// </summary>
 /// <param name="e"></param>
 protected override void OnUpdateUI(UpdateUIEventArgs e) {
     if (Lexer == Lexer.Container && ContainerLexerMode == ContainerLexerModes.Visible)
         ApplyContainerLexer();
     base.OnUpdateUI(e);
 }
Example #12
0
 private void STextBox_UpdateUI(object sender, ScintillaNET.UpdateUIEventArgs e)
 {
     UpdateUI?.Invoke(this, e);
 }
Example #13
0
        /// <summary>
        /// Handles the Update UI event of the <see cref="Scintilla"/> edit <see cref="Control"/>.
        /// </summary>
        private void ScintillaUpdateUi(object sender, UpdateUIEventArgs e)
        {
            // Has the caret changed position?
              int caretPos = scintilla.CurrentPosition;

              if (mLastCaretPos != caretPos)
              {
            mLastCaretPos = caretPos;
            int bracePos1 = -1;

            // Is there a brace to the left or right?
            if (caretPos > 0 && IsBrace(scintilla.GetCharAt(caretPos - 1)))
            {
              bracePos1 = (caretPos - 1);
            }
            else if (IsBrace(scintilla.GetCharAt(caretPos)))
            {
              bracePos1 = caretPos;
            }

            if (bracePos1 >= 0)
            {
              // Find the matching brace.
              int bracePos2 = scintilla.BraceMatch(bracePos1);

              if (bracePos2 == Scintilla.InvalidPosition)
              {
            scintilla.BraceBadLight(bracePos1);
              }
              else
              {
            scintilla.BraceHighlight(
                bracePos1
              , bracePos2);
              }
            }
            else
            {
              // Turn off brace matching
              scintilla.BraceHighlight(
              Scintilla.InvalidPosition
            , Scintilla.InvalidPosition);
            }
              }

              bool textSelected  = !string.IsNullOrEmpty(scintilla.SelectedText);
              bool textAvailable = !string.IsNullOrEmpty(scintilla.Text) && !mLuaScriptRunning;

              tsbUndo.Enabled       = !mLuaScriptRunning && scintilla.CanUndo;
              tsbRedo.Enabled       = !mLuaScriptRunning && scintilla.CanRedo;
              tsbLoadScript.Enabled = !mLuaScriptRunning;
              tsbSaveScript.Enabled = textAvailable;
              tsbCut.Enabled        = textSelected && !mLuaScriptRunning;
              tsbCopy.Enabled       = textSelected;
              tsbPaste.Enabled      = Clipboard.ContainsText() && scintilla.Focused && !scintilla.ReadOnly && !mLuaScriptRunning;
              tsbStart.Enabled      = textAvailable;
              tsbStop.Enabled       = mLuaScriptRunning;
        }
Example #14
0
 /// <summary>
 /// Raises the <see cref="UpdateUI" /> event.
 /// </summary>
 /// <param name="e">An <see cref="UpdateUIEventArgs" /> that contains the event data.</param>
 protected virtual void OnUpdateUI(UpdateUIEventArgs e)
 {
     EventHandler<UpdateUIEventArgs> handler = Events[updateUIEventKey] as EventHandler<UpdateUIEventArgs>;
     if (handler != null)
         handler(this, e);
 }
Example #15
0
 private void OnScintillaUpdateUI(object sender, UpdateUIEventArgs eventArgs)
 {
     // ユーザーが手動で選択範囲を変更した場合
     if (Form.ActiveForm == this.mMainForm && eventArgs.Change == UpdateChange.Selection) {
         this.mSearchTargetStart = FindReplace.InvalidPosition;
         this.mLastFound = false;
     }
 }
Example #16
0
        /// <summary>
        /// When the selection (caret) changed update the debug tab.
        /// </summary>
        /// <param name="s"></param>
        /// <param name="e"></param>
        private void editor_UpdateUI(object s, UpdateUIEventArgs e)
        {
            // get class references
            var editor = s as CodeEditor;

            // handle selection changed event, but only
            // update debug information for the compiled editor
            if (e.Change == UpdateChange.Selection && CompiledEditor == editor)
                UpdateDebugListView(editor);
        }
Example #17
0
 private void TxtFileViewer_UpdateUI(object sender, ScintillaNET.UpdateUIEventArgs e)
 {
     UpdateStats();
 }