コード例 #1
0
        public TextArea(TextEditorControl motherTextEditorControl, TextAreaControl motherTextAreaControl)
            : base()
        {
            this.motherTextAreaControl      = motherTextAreaControl;
            this.motherTextEditorControl    = motherTextEditorControl;

            caret            = new Caret(this);
            selectionManager = new SelectionManager(Document);

            this.textAreaClipboardHandler = new TextAreaClipboardHandler(this);

            #if GTK
            // FIXME: GTKize?
            this.DoubleBuffered = false;
            #else
            ResizeRedraw = true;

            SetStyle(ControlStyles.DoubleBuffer, false);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.Opaque, false);
            #endif

            textView = new TextView(this);

            gutterMargin = new GutterMargin(this);
            foldMargin   = new FoldMargin(this);
            iconBarMargin = new IconBarMargin(this);
            leftMargins.AddRange(new AbstractMargin[] { iconBarMargin, gutterMargin, foldMargin });
            OptionsChanged();

            new TextAreaMouseHandler(this).Attach();
            new TextAreaDragDropHandler().Attach(this);

            bracketshemes.Add(new BracketHighlightingSheme('{', '}'));
            bracketshemes.Add(new BracketHighlightingSheme('(', ')'));
            bracketshemes.Add(new BracketHighlightingSheme('[', ']'));

            CanFocus = true;

            caret.PositionChanged += new EventHandler(SearchMatchingBracket);
            Document.TextContentChanged += new EventHandler(TextContentChanged);

            #if GTK
            KeyPressEvent += new GtkSharp.KeyPressEventHandler (OnKeyPress);

            AddEvents ((int) (Gdk.EventMask.ExposureMask |
                      Gdk.EventMask.LeaveNotifyMask |
                      Gdk.EventMask.ButtonPressMask |
                      Gdk.EventMask.ButtonReleaseMask |
                      Gdk.EventMask.PointerMotionMask |
                      Gdk.EventMask.KeyPressMask |
                      Gdk.EventMask.ScrollMask |
                      Gdk.EventMask.KeyReleaseMask));

            ExposeEvent += new GtkSharp.ExposeEventHandler (ExposeHandler);
            #endif
        }
コード例 #2
0
        public MyEditor(Form1 parentForm, bool isReadOnly)
        {
            this.parentForm = parentForm;
            this.IsReadonly = isReadOnly;
            caret = new Caret(this);
            InitializeComponent();

            BackColor = Color.White;

            horizontalScrollBar = new HScrollBar();
            horizontalScrollBar.Dock = DockStyle.Bottom;
            horizontalScrollBar.Value = 0;
            horizontalScrollBar.ValueChanged += scrollBar_ValueChanged;
            horizontalScrollBar.SmallChange = 10;
            horizontalScrollBar.LargeChange = 100;
            horizontalScrollBar.KeyPress += OnKeyPress;
            horizontalScrollBar.KeyDown += OnKeyDown;
            Controls.Add(horizontalScrollBar);
            verticalScrollBar = new VScrollBar();
            verticalScrollBar.Dock = DockStyle.Right;
            verticalScrollBar.Value = 0;
            verticalScrollBar.ValueChanged += scrollBar_ValueChanged;
            verticalScrollBar.SmallChange = 1;
            verticalScrollBar.LargeChange = 10;
            verticalScrollBar.KeyPress += OnKeyPress;
            verticalScrollBar.KeyDown += OnKeyDown;
            Controls.Add(verticalScrollBar);

            caretTimer = new Timer();
            caretTimer.Interval = 500;
            caretTimer.Enabled = true;
            caretTimer.Tick += caretTimer_Tick;

            DoubleBuffered = true;
            ime = new Ime(parentForm.Handle, fonts.Base);
            //SetStyle(ControlStyles.UserPaint /*|
            //         /*ControlStyles.AllPaintingInWmPaint*/, true);

            /*SetStyle(ControlStyles.SupportsTransparentBackColor |
                     ControlStyles.Opaque |
                     ControlStyles.UserPaint |
                     ControlStyles.AllPaintingInWmPaint |
                    ControlStyles.ResizeRedraw, true);*/
        }
コード例 #3
0
        public void ShowFor(TextEditorControl editor, bool replaceMode)
        {
            Editor = editor;

            _search.ClearScanRegion();
            SelectionManager sm = editor.ActiveTextAreaControl.SelectionManager;

            if (sm.HasSomethingSelected && sm.SelectionCollection.Count == 1)
            {
                ISelection sel = sm.SelectionCollection[0];
                if (sel.StartPosition.Line == sel.EndPosition.Line)
                {
                    txtLookFor.Text = sm.SelectedText;
                }
                else
                {
                    _search.SetScanRegion(sel);
                }
            }
            else
            {
                // Get the current word that the caret is on
                Caret caret = editor.ActiveTextAreaControl.Caret;
                int   start = TextUtilities.FindWordStart(editor.Document, caret.Offset);
                int   endAt = TextUtilities.FindWordEnd(editor.Document, caret.Offset);
                txtLookFor.Text = editor.Document.GetText(start, endAt - start);
            }

            ReplaceMode = replaceMode;

            Owner    = (Form)editor.TopLevelControl;
            Location = new Point(Owner.Location.X + 100, Owner.Location.Y + 100);
            Show();

            txtLookFor.SelectAll();
            txtLookFor.Focus();
        }
コード例 #4
0
        public void ShowFor(TextEditorControl editor, bool replaceMode)
        {
            Editor = editor;

            _search.ClearScanRegion();
            var sm = editor.ActiveTextAreaControl.SelectionManager;

            if (sm.HasSomethingSelected && sm.SelectionCollection.Count == 1)
            {
                var sel = sm.SelectionCollection[0];
                if (sel.StartPosition.Line == sel.EndPosition.Line)
                {
                    findWhatTextBox.Text = sm.SelectedText;
                }
                else
                {
                    _search.SetScanRegion(sel);
                }
            }
            else
            {
                // Get the current word that the caret is on
                Caret caret = editor.ActiveTextAreaControl.Caret;
                int   start = TextUtilities.FindWordStart(editor.Document, caret.Offset);
                int   endAt = TextUtilities.FindWordEnd(editor.Document, caret.Offset);
                findWhatTextBox.Text = editor.Document.GetText(start, endAt - start);
            }

            ReplaceMode = replaceMode;

            this.Owner = (Form)editor.TopLevelControl;
            this.Show();
            IsShown = true;

            findWhatTextBox.SelectAll();
            findWhatTextBox.Focus();
        }
コード例 #5
0
        public TextRange FindNext(bool viaF3, bool searchBackward, string messageIfNotFound)
        {
            if (string.IsNullOrEmpty(txtLookFor.Text))
            {
                MessageBox.Show(this, "No string specified to look for!", "Find", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                return(null);
            }
            _lastSearchWasBackward     = searchBackward;
            _search.LookFor            = txtLookFor.Text;
            _search.MatchCase          = chkMatchCase.Checked;
            _search.MatchWholeWordOnly = chkMatchWholeWord.Checked;

            Caret caret = _editor.ActiveTextAreaControl.Caret;

            if (viaF3 && _search.HasScanRegion &&
                !Globals.IsInRange(caret.Offset, _search.BeginOffset, _search.EndOffset))
            {
                // user moved outside of the originally selected region
                _search.ClearScanRegion();
                UpdateTitleBar();
            }

            int       startFrom = caret.Offset - (searchBackward ? 1 : 0);
            TextRange range     = _search.FindNext(startFrom, searchBackward, out _lastSearchLoopedAround);

            if (range != null)
            {
                SelectResult(range);
            }
            else if (messageIfNotFound != null)
            {
                MessageBox.Show(this, messageIfNotFound, " ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(range);
        }
コード例 #6
0
ファイル: Bar.cs プロジェクト: Quantwing/SimpleMahjong
            public static bool Draw(string text, Size size, Caret.CaretType caretType, ColorName barColorName, AnimBool expanded)
            {
                Color initialColor = GUI.color;
                bool  result       = false;

                GUIStyle barStyle   = BarStyle(size, expanded.target);
                var      labelStyle = new GUIStyle(LabelStyle(size, expanded.target))
                {
                    normal = { textColor = Colors.TextColor(barColorName) }
                };

                float barHeight = barStyle.fixedHeight;
                float caretSize = barHeight * CARET_SIZE_RATIO;

                GUILayout.BeginVertical(GUILayout.Height(barHeight));
                {
                    GUI.color = Colors.BarColor(barColorName, expanded.target);
                    if (GUILayout.Button(GUIContent.none, barStyle, GUILayout.ExpandWidth(true)))
                    {
                        expanded.target = !expanded.target;
                        Properties.ResetKeyboardFocus();
                        Event.current.Use();
                        result = true;
                    }

                    GUI.color = initialColor;

                    GUILayout.Space(-barHeight);
                    GUILayout.Label(new GUIContent(text), labelStyle, GUILayout.ExpandWidth(true), GUILayout.Height(barHeight));

                    GUILayout.Space(-barHeight);
                    Caret.Draw(expanded, barColorName, caretType, caretSize);
                }
                GUILayout.EndVertical();
                return(result);
            }
コード例 #7
0
        public async Task <TextRange> FindNext(bool viaF3, bool searchBackward, string messageIfNotFound)
        {
            if (string.IsNullOrEmpty(txtLookFor.Text))
            {
                MessageBox.Show(this, _noSearchString.Text, Text, MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                return(null);
            }
            _lastSearchWasBackward     = searchBackward;
            _search.LookFor            = txtLookFor.Text;
            _search.MatchCase          = chkMatchCase.Checked;
            _search.MatchWholeWordOnly = chkMatchWholeWord.Checked;

            int       startIdx   = -1;
            int       currentIdx = -1;
            TextRange range      = null;

            do
            {
                Caret caret = _editor.ActiveTextAreaControl.Caret;
                if (viaF3 && _search.HasScanRegion &&
                    !Globals.IsInRange(caret.Offset, _search.BeginOffset, _search.EndOffset))
                {
                    // user moved outside of the originally selected region
                    _search.ClearScanRegion();
                    UpdateTitleBar();
                }

                int startFrom = caret.Offset - (searchBackward ? 1 : 0);
                if (startFrom == -1)
                {
                    startFrom = _search.EndOffset;
                }
                range = _search.FindNext(startFrom, searchBackward, out _lastSearchLoopedAround);
                if (range != null && (!_lastSearchLoopedAround || _fileLoader == null))
                {
                    SelectResult(range);
                }
                else if (_fileLoader != null)
                {
                    range = null;
                    if (currentIdx != -1 && startIdx == -1)
                    {
                        startIdx = currentIdx;
                    }
                    if (_fileLoader(searchBackward, true, out var fileIndex, out var loadFileContent))
                    {
                        currentIdx = fileIndex;
                        await loadFileContent;
                    }
                    else
                    {
                        break;
                    }
                }
            } while (range == null && startIdx != currentIdx && currentIdx != -1);
            if (range == null && messageIfNotFound != null)
            {
                MessageBox.Show(this, messageIfNotFound, " ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(range);
        }
コード例 #8
0
		/// <summary>
		/// Sets the caret to be used.
		/// </summary>
		public void setCaret(Caret @c)
		{
		}
コード例 #9
0
        public TextEditor(TextDocument document)
        {
            this.document = document;

            document.TextReplaced += (sender, args) =>
            {
                UpdateContentSize();
            };

            CaretAnimation = new CaretAnimation();
            Caret = new Caret(this);
            Caret.Line = 1;
            Options = new TextEditorOptions();
            Content = textArea = new TextArea(this);

            CaretAnimation.Callback = () =>
            {
                //RedrawLine(Caret.Line);
            };
            CaretAnimation.Start();

            Caret.PositionChanged += (sender, e) =>
            {
                QueueDraw();
            };
            
            KeyPressed += textArea.HandleKeyPressed;
            TextInput += textArea.HandleTextInput;
        }
コード例 #10
0
 public TryInterpretReturnValue(Caret start, ErrorSentence.Kind kind, int subDataIndex = 0) : this(start, (int)kind, subDataIndex, InterpreterStatus.Error)
 {
 }
コード例 #11
0
 private int LocalSelectionIndex(ITextComponentWrapper text)
 {
     // selection index could be out of bounds.
     return(Mathf.Clamp(Caret.GetSelectionIndex() - _drawStart, 0, text.DisplayedTextLength));
 }
コード例 #12
0
 private void MoveCaretWithinBounds(int index, bool withSelection)
 {
     index = Mathf.Clamp(index, 0, TextValue.Length);
     Caret.MoveTo(index, withSelection);
 }
コード例 #13
0
 private static TryInterpretReturnValue Success(this Caret start, byte successSubData, int length) => new TryInterpretReturnValue(new Span(start, length), SuccessSentence.Kind.StructKindInterpretSuccess, successSubData);
コード例 #14
0
ファイル: OneSidedDelete.cs プロジェクト: chrisforbes/corfu
 public OneSidedDelete(ITextBuffer document, bool left)
 {
     point = document.Point;
     this.left = left;
 }
コード例 #15
0
 public void Remove(Caret start, int count)
 {
     String t = Text;
     if(t.Length >= start.Position + count)
         Text = t.Remove(start.Position, count);
 }
コード例 #16
0
 public void Insert(Caret start, String value)
 {
     if (value.Contains('\r') || value.Contains('\n'))
     {
         Text = Text.Insert(start.Position, value.Replace("\r\n", "\n").Replace('\r', '\n'));
     }
     else
     {
         Document.Line line = Lines[start.Row];
         line.Value = line.Value.Insert(start.Column, value);
         CalcLineIndices();
     }
 }
コード例 #17
0
 public void Insert(Caret start, char value)
 {
     Insert(start, "" + value);
 }
コード例 #18
0
ファイル: DiffView.cs プロジェクト: necora/ank_git
        protected override void OnGotFocus(EventArgs e)
        {
            base.OnGotFocus(e);

            Debug.Assert(m_Caret == null);
            m_Caret = new Caret(this, LineHeight);
            UpdateCaret();

            InvalidateSelection();
            InvalidateCaretGutter();
        }
コード例 #19
0
ファイル: DiffView.cs プロジェクト: necora/ank_git
        protected override void OnLostFocus(EventArgs e)
        {
            base.OnLostFocus(e);

            //Sometimes in the debugger, the IDE seems to
            //steal focus, and it seems like this event fires
            //twice without an intermediate OnGotFocus.  So
            //we have to protect against that here and check
            //to see if we still have the caret.
            if (m_Caret != null)
            {
                m_Caret.Dispose();
                m_Caret = null;
            }

            InvalidateSelection();
            InvalidateCaretGutter();
        }
コード例 #20
0
 public Span(Caret start, int length)
 {
     this   = default;
     Start  = start;
     Length = length;
 }
コード例 #21
0
 internal VirtualSnapshotPoint GetVirtualPoint(ITextSnapshot snapshot)
 {
     return(new VirtualSnapshotPoint(Caret.GetPoint(snapshot), VirtualSpaces));
 }
コード例 #22
0
        /// <summary>
        /// Escape characters inside a text literal
        /// </summary>
        private string PELEscape(TextPortion SourcePosition, char EscapeChar)
        {
            StringBuilder sb = new StringBuilder(SourcePosition.Length);

            //Last position in the string
            var old_pos = SourcePosition.Begin;
            //Caret for finding \
            var crt = new Caret();
            crt.Source = SourcePosition.Text;
            string esc_char = EscapeChar.ToString(), esc_chars = esc_char + esc_char;

            for (var pos = SourcePosition.Text.IndexOf('\\', SourcePosition.Begin, SourcePosition.Length); pos >= 0; pos = SourcePosition.Text.IndexOf('\\', pos, SourcePosition.End - pos))
            {
                //Append in-between text
                if (pos != old_pos)
                    sb.Append(SourcePosition.Text.Substring(old_pos, pos - old_pos).Replace(esc_chars, esc_char));

                if (pos == SourcePosition.End)
                {
                    ThrowParseError("Expected a character to escape", new TextPortion(pos, 1));
                    break;
                }

                pos++;

                //End of file
                if (pos >= SourcePosition.End)
                    break;

                switch (SourcePosition.Text[pos])
                {
                case '\\':
                    sb.Append('\\');
                    pos++;
                    break;
                case 'r':
                case 'R':
                    sb.Append('\r');
                    pos++;
                    break;
                case 'n':
                case 'N':
                    sb.Append('\n');
                    pos++;
                    break;
                case 't':
                case 'T':
                    sb.Append('\t');
                    pos++;
                    break;
                case 'x':
                case 'X':
                    pos++;
                    crt.Position = pos;
                    if (!crt.Match(@"(?<cap>([0-9a-fA-F]{2})+)\\"))
                        ThrowParseError(
                            "Expected one or more consecutive 2-digit hexadecimal values, followed by a \\ (eg \\x2A\\, or \\x02A5F2\\)",
                            new TextPortion(pos, 1));
                    else
                    {
                        var cap = crt.LastMatch.Groups["cap"].Value;

                        for (int i = 0; i < cap.Length; i += 2)
                            sb.Append((char) Int16.Parse(cap.Substring(i, 2), NumberStyles.HexNumber));

                        pos = crt.Position;
                    }
                    break;
                case 'u':
                case 'U':
                    pos++;
                    crt.Position = pos;
                    if (!crt.Match(@"(?<cap>([0-9a-fA-F]{4})+)\\"))
                        ThrowParseError(
                            "Expected one or more consecutive 4-digit hexadecimal values, followed by a \\ (eg \\u002A\\, or \\u000200A510F2\\)",
                            new TextPortion(pos, 1));
                    else
                    {
                        var cap = crt.LastMatch.Groups["cap"].Value;

                        for (int i = 0; i < cap.Length; i += 4)
                            sb.Append((char) Int16.Parse(cap.Substring(i, 4), NumberStyles.HexNumber));

                        pos = crt.Position;
                    }
                    break;
                default:
                    ThrowParseError("Unexpected escape character", new TextPortion(pos, 1));
                    break;
                }

                old_pos = pos;
            }

            //Append remaining text
            if (old_pos != SourcePosition.End)
                sb.Append(SourcePosition.Text, old_pos, SourcePosition.End - old_pos);

            return sb.ToString();
        }
コード例 #23
0
ファイル: ContextFrame.cs プロジェクト: Orvid/D_Parser
 public override string ToString()
 {
     return(scopedBlock.ToString() + " // " + Caret.ToString());
 }
コード例 #24
0
        public static TryInterpretReturnValue TryGetFirstStructLocation(ushort *ccp, int lineLength, Caret start, int column)
        {
            switch (*ccp)
            {
            case 'p':     // power
                return(start.PowerDetect(column, lineLength, ccp));

            case 'u':     // unit
                return(start.UnitDetect(column, lineLength, ccp));

            case 'r':     // race
                return(start.RaceDetect(column, lineLength, ccp));

            case 'a':     // attribute
                return(start.AttributeDetect(column, lineLength, ccp));

            case 'f':     // field
                return(start.FieldDetect(column, lineLength, ccp));

            case 'o':     // object
                return(start.ObjectDetect(column, lineLength, ccp));

            case 'm':     // movetype
                return(start.MoveTypeDetect(column, lineLength, ccp));

            case 'e':     // event
                return(start.EventDetect(column, lineLength, ccp));

            case 'd':     // dungeon, detail
                return(start.DungeonOrDetailDetect(column, lineLength, ccp));

            case 'c':     // class, context
                return(start.ClassOrContextDetect(column, lineLength, ccp));

            case 's':     // scenario, skill, skillset, sound, story
                return(start.SDetect(column, lineLength, ccp));

            case 'w':     // workspace
                return(start.WorkspaceDetect(column, lineLength, ccp));

            case 'v':     // voice
                return(start.VoiceDetect(column, lineLength, ccp));

            default:
                return(new TryInterpretReturnValue(start, ErrorSentence.Kind.StructKindNotFoundError));
            }
        }
コード例 #25
0
 private void MoveCaretToVirtualPosition(int pos)
 {
     Caret.MoveTo(new VirtualSnapshotPoint(_snapshotLine, pos));
     Caret.EnsureVisible();
 }
コード例 #26
0
 private int LocalIndex()
 {
     return(Caret.GetIndex() - _drawStart);
 }
コード例 #27
0
        public override int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            if (ConvertTabsToSpaces &&
                TextView.Selection.IsEmpty &&
                pguidCmdGroup == VSConstants.VSStd2K &&
                !IsInAutomationFunction &&
                !DisplayHelper.IsCompletionActive &&
                !DisplayHelper.IsSignatureHelpActive
                )
            {
                switch (nCmdID)
                {
                case ARROW_LEFT:
                case ARROW_RIGHT:
                    if (CaretIsWithinCodeRange)
                    {
                        goto default;
                    }
                    break;

                case ARROW_UP:
                case ARROW_DOWN:
                    Caret.PositionChanged -= CaretOnPositionChanged;
                    if (!_savedCaretColumn.HasValue)
                    {
                        _savedCaretColumn = VirtualCaretColumn;
                    }
                    break;

                default:
                    _savedCaretColumn = null;
                    return(NextTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
                }

                switch (nCmdID)
                {
                case ARROW_LEFT:
                    Caret.MoveToPreviousCaretPosition();
                    if (CaretCharIsASpace)
                    {
                        MoveCaretToPreviousTabStop();
                        return(VSConstants.S_OK);
                    }
                    Caret.MoveToNextCaretPosition();
                    break;

                case ARROW_RIGHT:
                    if (CaretCharIsASpace)
                    {
                        Caret.MoveToNextCaretPosition();
                        MoveCaretToNextTabStop();
                        return(VSConstants.S_OK);
                    }
                    break;

                case ARROW_UP:
                    try
                    {
                        _snapshotLine = TextView.TextSnapshot.GetLineFromPosition(
                            Caret.Position.BufferPosition.Subtract(CaretColumn + 1));
                        MoveCaretToNearestVirtualTabStop();
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                    }
                    Caret.PositionChanged += CaretOnPositionChanged;
                    return(VSConstants.S_OK);

                case ARROW_DOWN:
                    try
                    {
                        _snapshotLine = FindNextLine();
                        MoveCaretToNearestVirtualTabStop();
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                    }
                    Caret.PositionChanged += CaretOnPositionChanged;
                    return(VSConstants.S_OK);
                }
            }

            return(NextTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
        }
コード例 #28
0
 public CaretAdapter(Caret caret)
 {
     this.caret = caret;
 }
コード例 #29
0
        public async Task <TextRange?> FindNextAsync(bool viaF3, bool searchBackward, string?messageIfNotFound)
        {
            if (string.IsNullOrEmpty(txtLookFor.Text))
            {
                MessageBox.Show(this, _noSearchString.Text, Text, MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                return(null);
            }

            Validates.NotNull(_editor);

            _lastSearchWasBackward     = searchBackward;
            _search.LookFor            = txtLookFor.Text;
            _search.MatchCase          = chkMatchCase.Checked;
            _search.MatchWholeWordOnly = chkMatchWholeWord.Checked;

            int       startIdx   = -1;
            int       currentIdx = -1;
            TextRange?range;

            do
            {
                Caret caret = _editor.ActiveTextAreaControl.Caret;
                if (viaF3 && _search.HasScanRegion &&
                    !Globals.IsInRange(caret.Offset, _search.BeginOffset, _search.EndOffset))
                {
                    // user moved outside of the originally selected region
                    _search.ClearScanRegion();
                }

                int startFrom = caret.Offset - (searchBackward ? 1 : 0);
                if (startFrom == -1)
                {
                    startFrom = _search.EndOffset;
                }

                var isMultiFileSearch = _fileLoader is not null && !_search.HasScanRegion;

                range = _search.FindNext(startFrom, searchBackward, out _lastSearchLoopedAround);
                if (range is not null && (!_lastSearchLoopedAround || !isMultiFileSearch))
                {
                    SelectResult(range);
                }
                else if (isMultiFileSearch)
                {
                    range = null;
                    if (currentIdx != -1 && startIdx == -1)
                    {
                        startIdx = currentIdx;
                    }

                    Validates.NotNull(_fileLoader);
                    if (_fileLoader(searchBackward, true, out var fileIndex, out var loadFileContent))
                    {
                        currentIdx = fileIndex;
                        try
                        {
                            await loadFileContent;
                        }
                        catch (OperationCanceledException)
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
コード例 #30
0
 /// <summary>
 /// Function to fill the IntelliSense panel.
 /// </summary>
 /// <param name="document">Related <see cref="TextDocument"/>.</param>
 /// <param name="caret">Related <see cref="Caret"/>.</param>
 public static async Task <IEnumerable <IntelliSenseItem> > GenerateAsync(this IIntelliSenseHost _this, TextDocument document, Caret caret) => await Task.Run(() => _this.Generate(document, caret));
コード例 #31
0
ファイル: Caret.cs プロジェクト: trcclub/OgmaDrive
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Caret obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
コード例 #32
0
ファイル: Form1.cs プロジェクト: gregfrazier/snipman
        /// <summary>
        /// Search for Text
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            string searchAll = "SELECT UID FROM SNIPPETS WHERE DATA like @D";

            if (toolStripComboBox1.Text == string.Empty)
            {
                MessageBox.Show("Please enter search criteria."); return;
            }
            if (_lastCriteria != toolStripComboBox1.Text)
            {
                AddtoComboBox(toolStripComboBox1.Text);
                SqLiteTypes.SqLiteParam u;
                _lastCriteria = toolStripComboBox1.Text;
                u.Param       = "@D"; u.Value = "%" + toolStripComboBox1.Text + "%";
                using (DataTable ans = _db.Db.PreparedQuery(searchAll, u))
                {
                    _findList = new Queue <string>();
                    if (ans == null)
                    {
                        new ErrorHandler("Unable to Query", "SearchSnippets"); return;
                    }
                    foreach (DataRow r in ans.Rows)
                    {
                        _findList.Enqueue(r["UID"].ToString());
                    }
                    if (_findList.Any())
                    {
                        int y = Int32.Parse(_findList.Dequeue());
                        treeView1.SelectedNode = treeView1.Node(y.ToString());
                        //this.richTextBox1.Focus();

                        // Put in seperate function
                        TextEditorSearcher search = new TextEditorSearcher
                        {
                            Document           = textEditorControl1.Document,
                            LookFor            = toolStripComboBox1.Text,
                            MatchCase          = false,
                            MatchWholeWordOnly = false
                        };
                        Caret     caret = textEditorControl1.ActiveTextAreaControl.Caret;
                        bool      lastSearchLoopedAround;
                        int       startFrom = caret.Offset;
                        TextRange range     = search.FindNext(startFrom, false, out lastSearchLoopedAround);
                        if (range != null)
                        {
                            Point h1 = textEditorControl1.Document.OffsetToPosition(range.Offset);
                            Point h2 = textEditorControl1.Document.OffsetToPosition(range.Offset + range.Length);
                            textEditorControl1.ActiveTextAreaControl.SelectionManager.SetSelection(h1, h2);
                            textEditorControl1.ActiveTextAreaControl.Caret.Position = textEditorControl1.Document.OffsetToPosition(range.Offset + range.Length);
                            textEditorControl1.ActiveTextAreaControl.ScrollToCaret();
                            _findLocation = range.Offset + range.Length;
                        }
                        else
                        {
                            _findLocation = 0;
                        }
                        //int er = this.richTextBox1.Find(toolStripComboBox1.Text, RichTextBoxFinds.None);
                        //this.textEditorControl1.
                        //this.richTextBox1.Select(er, this.toolStripComboBox1.Text.Length);
                        //this.richTextBox1.ScrollToCaret();
                        //FindLocation = er + toolStripComboBox1.Text.Length;
                    }
                    else
                    {
                        MessageBox.Show("End of Search");
                        _lastCriteria = string.Empty;
                        _findLocation = 0;
                    }
                }
            }
            else
            {
                // Still in a Find, goto other places or files.
                //this.richTextBox1.Focus();
                //int er = this.richTextBox1.Find(toolStripComboBox1.Text, FindLocation, RichTextBoxFinds.None);
                TextEditorSearcher search = new TextEditorSearcher
                {
                    Document           = textEditorControl1.Document,
                    LookFor            = toolStripComboBox1.Text,
                    MatchCase          = false,
                    MatchWholeWordOnly = false
                };
                Caret     caret     = textEditorControl1.ActiveTextAreaControl.Caret;
                int       startFrom = caret.Offset;
                TextRange range     = search.FindNext(startFrom, false, out var lastSearchLoopedAround);

                if (range != null && !lastSearchLoopedAround)
                {
                    Point h1 = textEditorControl1.Document.OffsetToPosition(range.Offset);
                    Point h2 = textEditorControl1.Document.OffsetToPosition(range.Offset + range.Length);
                    textEditorControl1.ActiveTextAreaControl.SelectionManager.SetSelection(h1, h2);
                    textEditorControl1.ActiveTextAreaControl.Caret.Position = textEditorControl1.Document.OffsetToPosition(range.Offset + range.Length);
                    textEditorControl1.ActiveTextAreaControl.ScrollToCaret();
                    _findLocation = range.Offset + range.Length;
                }
                else
                {
                    if (_findList.Count > 0)
                    {
                        _findLocation = 0;
                        int y = Int32.Parse(_findList.Dequeue());
                        treeView1.SelectedNode = treeView1.Node(y.ToString());
                        ////this.richTextBox1.Focus();
                        //er = this.richTextBox1.Find(toolStripComboBox1.Text, FindLocation, RichTextBoxFinds.None);
                        //this.richTextBox1.Select(er, this.toolStripComboBox1.Text.Length);
                        //this.richTextBox1.ScrollToCaret();
                        //FindLocation = er + toolStripComboBox1.Text.Length;
                        search = new TextEditorSearcher
                        {
                            Document           = textEditorControl1.Document,
                            LookFor            = toolStripComboBox1.Text,
                            MatchCase          = false,
                            MatchWholeWordOnly = false
                        };
                        caret     = textEditorControl1.ActiveTextAreaControl.Caret;
                        startFrom = caret.Offset;
                        range     = search.FindNext(startFrom, false, out lastSearchLoopedAround);
                        if (range != null)
                        {
                            Point h1 = textEditorControl1.Document.OffsetToPosition(range.Offset);
                            Point h2 = textEditorControl1.Document.OffsetToPosition(range.Offset + range.Length);
                            textEditorControl1.ActiveTextAreaControl.SelectionManager.SetSelection(h1, h2);
                            textEditorControl1.ActiveTextAreaControl.Caret.Position = textEditorControl1.Document.OffsetToPosition(range.Offset + range.Length);
                            textEditorControl1.ActiveTextAreaControl.ScrollToCaret();
                            _findLocation = range.Offset + range.Length;
                        }
                        else
                        {
                            _findLocation = 0;
                        }
                    }
                    else
                    {
                        MessageBox.Show("End of Search");
                        _lastCriteria = "";
                        _findLocation = 0;
                    }
                }
            }
        }
コード例 #33
0
 public void UpdateEditorCaretPositions(Caret caret)
 {
     TxtEditorCaret.Text = $"Ln {caret.Line} Col {caret.Column}";
 }
コード例 #34
0
 internal bool Reversing(ITextSnapshot snapshot)
 {
     return(Caret.GetPosition(snapshot) < End?.GetPosition(snapshot));
 }
コード例 #35
0
    private Node sequence(Node end) {
        Node head = null;
        Node tail = null;
        Node node = null;
        for (;;) {
            int ch = peek();
            switch (ch) {
            case '(':
                // Because group handles its own closure,
                // we need to treat it differently
                node = group0();
                // Check for comment or flag group
                if (node == null)
                    continue;
                if (head == null)
                    head = node;
                else
                    tail.next = node;
                // Double return: Tail was returned in root
                tail = root;
                continue;
            case '[':
                node = clazz(true);
                break;
            case '\\':
                ch = nextEscaped();
                if (ch == 'p' || ch == 'P') {
                    boolean oneLetter = true;
                    boolean comp = (ch == 'P');
                    ch = next(); // Consume { if present
                    if (ch != '{') {
                        unread();
                    } else {
                        oneLetter = false;
                    }
                    node = family(oneLetter, comp);
                } else {
                    unread();
                    node = atom();
                }
                break;
            case '^':
                next();
                if (has(MULTILINE)) {
                    if (has(UNIX_LINES))
                        node = new UnixCaret();
                    else
                        node = new Caret();
                } else {
                    node = new Begin();
                }
                break;
            case '$':
                next();
                if (has(UNIX_LINES))
                    node = new UnixDollar(has(MULTILINE));
                else
                    node = new Dollar(has(MULTILINE));
                break;
            case '.':
                next();
                if (has(DOTALL)) {
                    node = new All();
                } else {
                    if (has(UNIX_LINES))
                        node = new UnixDot();
                    else {
                        node = new Dot();
                    }
                }
                break;
            case '|':
            case ')':
                goto end2;
            case ']': // Now interpreting dangling ] and } as literals
            case '}':
                node = atom();
                break;
            case '?':
            case '*':
            case '+':
                next();
                throw error(new String("Dangling meta character '" + ((char)ch) + "'"));
            case 0:
                if (_cursor >= patternLength) {
                    goto end2;
                }
                // Fall through
                node = atom();
                break;
            default:
                node = atom();
                break;
            }
            node = closure(node);
            if (head == null) {
                head = tail = node;
            } else {
                tail.next = node;
                tail = node;
            }
        }
end2:
        if (head == null) {
            return end;
        }
        tail.next = end;
        root = tail;      //double return
        return head;
    }
コード例 #36
0
 /// <summary>
 /// Sets the caret to be used.
 /// </summary>
 public void setCaret(Caret @c)
 {
 }
コード例 #37
0
 private static TryInterpretReturnValue Fail(this Caret start, byte errorSubData) => new TryInterpretReturnValue(start, ErrorSentence.Kind.StructKindInterpretError, errorSubData);
コード例 #38
0
 internal bool IsReversed(ITextSnapshot snapshot)
 {
     return(Caret.GetPosition(snapshot) == Start?.GetPosition(snapshot));
 }
コード例 #39
0
ファイル: HexEditor.cs プロジェクト: GeekGalaxy/QuasarRAT
        public HexEditor(ByteCollection collection)
        {
            //Set String format for the hex values
            _stringFormat = new StringFormat(StringFormat.GenericTypographic);
            _stringFormat.Alignment = StringAlignment.Center;
            _stringFormat.LineAlignment = StringAlignment.Center;

            //Set the provided byte collection
            _hexTable = collection;

            //Set the vertical scrollbar
            _vScrollBar = new VScrollBar();
            _vScrollBar.Scroll += new ScrollEventHandler(OnVScrollBarScroll);

            //Redraw whenever the control is resized
            SetStyle(ControlStyles.ResizeRedraw, true);

            //Enable double buffering
            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);

            //Enable selectable
            SetStyle(ControlStyles.Selectable, true);

            //Handle initialization of Caret
            _caret = new Caret(this);
            _caret.SelectionStartChanged += new EventHandler(CaretSelectionStartChanged);
            _caret.SelectionLengthChanged += new EventHandler(CaretSelectionLengthChanged);

            //Create the needed edit view
            _editView = new EditView(this);
            _handler = _editView;

            //Set defualt cursor
            this.Cursor = Cursors.IBeam;
        }
コード例 #40
0
 private void CaretPositionChanged1(object sender, EventArgs e)
 {
     Caret caret = sender as Caret;
 }
コード例 #41
0
        internal static void CaretPositionChanged(object sender, DocumentLocationEventArgs e)
        {
            Caret caret = (Caret)sender;

            UpdateCaretPosition(caret);
        }
コード例 #42
0
 public CaretAdapter(Caret caret)
 {
     Debug.Assert(caret != null);
     _caret = caret;
 }
コード例 #43
0
        private static TryInterpretReturnValue SDetect(this Caret start, int column, int thisLineLength, ushort *ccp)
        {
            if (column + 3 >= thisLineLength)
            {
                return(start.Fail(20));
            }
            else
            {
                switch (*++ccp)
                {
                case 'k':
                    if (column + 4 < thisLineLength && *++ccp == 'i' && *++ccp == 'l' && *++ccp == 'l')
                    {
                        if (IsNextEndOfLineOrSpace(ccp, column + 4, thisLineLength))
                        {
                            return(TryInterpretReturnValue.CreateSuccessDetectStructType(start, 5, Location.Skill));
                        }
                        else if (*++ccp == 's' && column + 7 < thisLineLength && *++ccp == 'e' && *++ccp == 't' && IsNextEndOfLineOrSpace(ccp, column + 7, thisLineLength))
                        {
                            return(TryInterpretReturnValue.CreateSuccessDetectStructType(start, 8, Location.SkillSet));
                        }
                        else
                        {
                            return(start.Fail(15));
                        }
                    }
                    else
                    {
                        return(start.Fail(16));
                    }

                case 'o':
                    if (column + 4 < thisLineLength && *++ccp == 'u' && *++ccp == 'n' && *++ccp == 'd' && IsNextEndOfLineOrSpaceOrLeftBrace(ccp, column + 4, thisLineLength))
                    {
                        return(TryInterpretReturnValue.CreateSuccessDetectStructType(start, 5, Location.Sound));
                    }
                    else
                    {
                        return(start.Fail(17));
                    }

                case 't':
                    if (column + 4 < thisLineLength && *++ccp == 'o' && *++ccp == 'r' && *++ccp == 'y' && IsNextEndOfLineOrSpace(ccp, column + 4, thisLineLength))
                    {
                        return(TryInterpretReturnValue.CreateSuccessDetectStructType(start, 5, Location.Story));
                    }
                    else
                    {
                        return(start.Fail(18));
                    }

                case 'c':
                    if (column + 7 < thisLineLength && *++ccp == 'e' && *++ccp == 'n' && *++ccp == 'a' && *++ccp == 'r' && *++ccp == 'i' && *++ccp == 'o' && IsNextEndOfLineOrSpace(ccp, column + 7, thisLineLength))
                    {
                        return(TryInterpretReturnValue.CreateSuccessDetectStructType(start, 8, Location.Scenario));
                    }
                    else
                    {
                        return(start.Fail(19));
                    }

                case 'p':
                    if (*++ccp == 'o' && *++ccp == 't' && IsNextEndOfLineOrSpace(ccp, column + 3, thisLineLength))
                    {
                        return(TryInterpretReturnValue.CreateSuccessDetectStructType(start, 4, Location.Spot));
                    }
                    else
                    {
                        return(start.Fail(21));
                    }

                default:
                    return(start.Fail(20));
                }
            }
        }