internal bool HandleViewCommand(Command command) { bool flag = false; bool flag2 = false; bool isSelecting = false; bool flag4 = false; if (command.CommandGroup == typeof(TextBufferCommands)) { int num3; int lineIndex; TextBufferLocation location; int num5; switch (command.CommandID) { case 30: if (this._location.ColumnIndex >= this._location.Line.Length) { if (this._location.LineIndex < (this._buffer.LineCount - 1)) { this._location.MoveDown(1); this._location.ColumnIndex = 0; flag = true; isSelecting = ((TextBufferCommand) command).IsSelecting; this.SetSmartCursorIndex(); } else if (!((TextBufferCommand) command).IsSelecting) { flag2 = true; } } else { this._location.ColumnIndex++; flag = true; isSelecting = ((TextBufferCommand) command).IsSelecting; this.SetSmartCursorIndex(); } flag4 = true; goto Label_0C3E; case 0x1f: if (this._location.ColumnIndex <= 0) { if (this._location.LineIndex > 0) { this._location.MoveUp(1); this._location.ColumnIndex = this._location.Line.Length; flag = true; isSelecting = ((TextBufferCommand) command).IsSelecting; this.SetSmartCursorIndex(); } else if (!((TextBufferCommand) command).IsSelecting) { flag2 = true; } } else { this._location.ColumnIndex--; flag = true; isSelecting = ((TextBufferCommand) command).IsSelecting; this.SetSmartCursorIndex(); } flag4 = true; goto Label_0C3E; case 0x20: { isSelecting = ((TextBufferCommand) command).IsSelecting; TextBufferLocation location2 = this._location.Clone(); TextBufferSpan wordSpan = null; try { wordSpan = this.TextLanguage.GetWordSpan(location2, WordType.Next); if (wordSpan != null) { this._location.MoveTo(wordSpan.Start); flag = true; this.SetSmartCursorIndex(); } } finally { location2.Dispose(); if (wordSpan != null) { wordSpan.Dispose(); } } flag4 = true; goto Label_0C3E; } case 0x21: { isSelecting = ((TextBufferCommand) command).IsSelecting; TextBufferLocation location3 = this._location.Clone(); TextBufferSpan span2 = null; try { span2 = this.TextLanguage.GetWordSpan(location3, WordType.Previous); if (span2 != null) { this._location.MoveTo(span2.Start); flag = true; this.SetSmartCursorIndex(); } } finally { location3.Dispose(); if (span2 != null) { span2.Dispose(); } } flag4 = true; goto Label_0C3E; } case 0x22: { int columnIndex = this._location.ColumnIndex; if (this.MoveToFirstCharIndex(this._location) == columnIndex) { this._location.ColumnIndex = 0; } if (columnIndex != this._location.ColumnIndex) { flag = true; isSelecting = ((TextBufferCommand) command).IsSelecting; this.SetSmartCursorIndex(); } else { if (!((TextBufferCommand) command).IsSelecting) { flag2 = true; } this.SetSmartCursorIndex(); } flag4 = true; goto Label_0C3E; } case 0x23: { int length = this._location.Line.Length; if (this._location.ColumnIndex == length) { if (!((TextBufferCommand) command).IsSelecting) { flag2 = true; } this.SetSmartCursorIndex(); } else { this._location.ColumnIndex = this._location.Line.Length; flag = true; isSelecting = ((TextBufferCommand) command).IsSelecting; this.SetSmartCursorIndex(); } flag4 = true; goto Label_0C3E; } case 0x24: if (this._location.LineIndex >= this._buffer.LineCount) { if (!((TextBufferCommand) command).IsSelecting) { flag2 = true; } } else { this._location.MoveDown(1); flag = true; isSelecting = ((TextBufferCommand) command).IsSelecting; this.DoSmartCursorMovement(); } flag4 = true; goto Label_0C3E; case 0x25: if (this._location.LineIndex <= 0) { if (!((TextBufferCommand) command).IsSelecting) { flag2 = true; } } else { this._location.MoveUp(1); flag = true; isSelecting = ((TextBufferCommand) command).IsSelecting; this.DoSmartCursorMovement(); } flag4 = true; goto Label_0C3E; case 0x26: num3 = 0; lineIndex = this._location.LineIndex; if ((lineIndex < this.ViewTopLineNumber) || (lineIndex > (this.ViewTopLineNumber + this.VisibleLines))) { num3 = this.VisibleLines / 2; } else { num3 = this._location.LineIndex - this.ViewTopLineNumber; } if (this._location.MoveDown(this._visibleLines) != 0) { flag = true; isSelecting = ((TextBufferCommand) command).IsSelecting; this.DoSmartCursorMovement(); this.ViewTopLineNumber = Math.Max(Math.Min((int) (this._location.LineIndex - num3), (int) (this._buffer.LineCount - this._visibleLines)), 0); } flag4 = true; goto Label_0C3E; case 0x27: lineIndex = this._location.LineIndex; if ((lineIndex < this.ViewTopLineNumber) || (lineIndex > (this.ViewTopLineNumber + this.VisibleLines))) { num3 = this.VisibleLines / 2; } else { num3 = Math.Min((int) (this.VisibleLines - 1), (int) (this._location.LineIndex - this.ViewTopLineNumber)); } if (this._location.MoveUp(this._visibleLines) != 0) { flag = true; isSelecting = ((TextBufferCommand) command).IsSelecting; this.DoSmartCursorMovement(); this.ViewTopLineNumber = Math.Max(this._location.LineIndex - num3, 0); } flag4 = true; goto Label_0C3E; case 40: this._location.MoveTo(this._buffer.Last); flag = true; isSelecting = ((TextBufferCommand) command).IsSelecting; this.SetSmartCursorIndex(); flag4 = true; goto Label_0C3E; case 0x29: this._location.MoveTo(this._buffer.First); flag = true; isSelecting = ((TextBufferCommand) command).IsSelecting; this.SetSmartCursorIndex(); flag4 = true; goto Label_0C3E; case 0x2a: { isSelecting = ((TextBufferCommand) command).IsSelecting; Point commandPosition = ((TextBufferCommand) command).CommandPosition; this._location.GotoLineColumn(commandPosition.X, commandPosition.Y); flag = true; this.SetSmartCursorIndex(); flag4 = true; goto Label_0C3E; } case 0x2b: this._location.GotoLine((int) ((TextBufferCommand) command).Data); this.ViewTopLineNumber = Math.Min(this._buffer.LineCount - this.VisibleLines, Math.Max(0, this._location.LineIndex - (this.VisibleLines / 2))); flag = true; flag4 = true; goto Label_0C3E; case 0x2c: case 0x2d: case 0x2e: case 0x2f: case 0x30: case 0x31: case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: case 0x3a: case 0x3b: case 0x44: case 0x45: case 70: case 0x47: case 0x4a: case 0x4b: case 0x4c: case 0x4d: case 0x4e: case 0x4f: case 0x5c: case 0x5d: goto Label_0C3E; case 50: this.ViewTopLineNumber = ((TextBufferCommand) command).CommandValue; flag4 = true; goto Label_0C3E; case 0x33: this.ViewLeftIndex = ((TextBufferCommand) command).CommandValue; flag4 = true; goto Label_0C3E; case 0x34: this.ViewTopLineNumber = Math.Min(this._buffer.LineCount - this.VisibleLines, Math.Max(0, this._location.LineIndex - (this.VisibleLines / 2))); flag4 = true; goto Label_0C3E; case 60: this.ResetSelection(); flag4 = true; goto Label_0C3E; case 0x3d: this.UpdateSelection(); flag4 = true; goto Label_0C3E; case 0x3e: this.DeleteSelection(); this.SetSmartCursorIndex(); flag4 = true; goto Label_0C3E; case 0x3f: this.CutInternal(); this.SetSmartCursorIndex(); flag4 = true; goto Label_0C3E; case 0x40: this.CopyInternal(); this.SetSmartCursorIndex(); flag4 = true; goto Label_0C3E; case 0x41: this.PasteInternal(); this.SetSmartCursorIndex(); flag4 = true; goto Label_0C3E; case 0x42: this.FreezePaint(); try { this._location.MoveTo(this._buffer.First); this.ResetSelection(); this._location.MoveTo(this._buffer.Last); this.UpdateSelection(); } finally { this.UnfreezePaint(); } flag4 = true; goto Label_0C3E; case 0x43: { TextBufferLocation location4 = this._location.Clone(); TextBufferSpan span3 = null; try { span3 = this.TextLanguage.GetWordSpan(location4, WordType.Current); if (span3 != null) { isSelecting = true; this._location.MoveTo(span3.Start); this.ResetSelection(); this._location.MoveTo(span3.End); flag = true; } } finally { location4.Dispose(); if (span3 != null) { span3.Dispose(); } } flag4 = true; goto Label_0C3E; } case 0x48: location = this._buffer.CreateTextBufferLocation(this._selection.Start); num5 = this._selection.End.LineIndex; if (this._selection.End.ColumnIndex == 0) { num5--; } this._buffer.BeginBatchUndo(); while (location.LineIndex <= num5) { if (!location.Line.IsEmpty) { this.MoveToFirstCharIndex(location); TextBufferCommand command2 = new TextBufferCommand(70, location); this.HandleCommand(command2); } if (location.MoveDown(1) == 0) { break; } } location.Dispose(); this._buffer.EndBatchUndo(); this._selection.Start.ColumnIndex = 0; if (this._selection.End.ColumnIndex != 0) { this._selection.End.ColumnIndex = this._selection.End.Line.Length; } this.SetSmartCursorIndex(); flag4 = true; goto Label_0C3E; case 0x49: location = this._buffer.CreateTextBufferLocation(this._selection.Start); num5 = this._selection.End.LineIndex; if (this._selection.End.ColumnIndex == 0) { num5--; } this._buffer.BeginBatchUndo(); while (location.LineIndex <= num5) { this.MoveToFirstCharIndex(location); TextBufferCommand command3 = new TextBufferCommand(0x47, location); this.HandleCommand(command3); if (location.MoveDown(1) == 0) { break; } } location.Dispose(); this._buffer.EndBatchUndo(); this._selection.Start.ColumnIndex = 0; if (this._selection.End.ColumnIndex != 0) { this._selection.End.ColumnIndex = this._selection.End.Line.Length; } this.SetSmartCursorIndex(); flag4 = true; goto Label_0C3E; case 80: flag4 = this.OnKeyDownCommand(((TextBufferCommand) command).CommandValue); goto Label_0C3E; case 0x51: this.OnKeyPressedCommand(((TextBufferCommand) command).CommandValue); flag4 = true; goto Label_0C3E; case 90: { using (TextBufferLocation location6 = this._location.Clone()) { TextBufferSpan span5 = null; try { //NOTE: 手动修改 span5 = this.TextLanguage.GetWordSpan(location6, WordType.Current); if (span5 != null) { span5.End.MoveTo(this._location); } if ((span5 == null) || span5.IsEmpty) { span5 = this.TextLanguage.GetWordSpan(location6, WordType.Previous); } if ((span5 != null) && !span5.IsEmpty) { span5.End.MoveTo(this._location); this.HandleCommand(new TextBufferCommand(3, span5.Start, span5.End)); this._location.MoveTo(span5.Start); this.SetSmartCursorIndex(); } } catch (Exception ex) { } finally { span5.Dispose(); span5 = null; } //using (TextBufferSpan span5 = null) //{ // span5 = this.TextLanguage.GetWordSpan(location6, WordType.Current); // if (span5 != null) // { // span5.End.MoveTo(this._location); // } // if ((span5 == null) || span5.IsEmpty) // { // span5 = this.TextLanguage.GetWordSpan(location6, WordType.Previous); // } // if ((span5 != null) && !span5.IsEmpty) // { // span5.End.MoveTo(this._location); // this.HandleCommand(new TextBufferCommand(3, span5.Start, span5.End)); // this._location.MoveTo(span5.Start); // this.SetSmartCursorIndex(); // } //} goto Label_0C3E; } } case 0x5b: { using (TextBufferLocation location5 = this._location.Clone()) { //NOTE: 手动修改 //using (TextBufferSpan span4 = null) //{ // span4 = this.TextLanguage.GetWordSpan(location5, WordType.Current); // if (span4 != null) // { // span4.Start.MoveTo(this._location); // } // if ((span4 == null) || span4.IsEmpty) // { // span4 = this.TextLanguage.GetWordSpan(location5, WordType.Next); // } // if ((span4 != null) && !span4.IsEmpty) // { // span4.Start.MoveTo(this._location); // this.HandleCommand(new TextBufferCommand(3, span4.Start, span4.End)); // this.SetSmartCursorIndex(); // } //} TextBufferSpan span4 = null; try { span4 = this.TextLanguage.GetWordSpan(location5, WordType.Current); if (span4 != null) { span4.Start.MoveTo(this._location); } if ((span4 == null) || span4.IsEmpty) { span4 = this.TextLanguage.GetWordSpan(location5, WordType.Next); } if ((span4 != null) && !span4.IsEmpty) { span4.Start.MoveTo(this._location); this.HandleCommand(new TextBufferCommand(3, span4.Start, span4.End)); this.SetSmartCursorIndex(); } } catch (Exception ex) { } finally { span4.Dispose(); span4 = null; } goto Label_0C3E; } } case 0x5e: if (this._owner.HelpEnabled) { if (this._selectionExists) { this.TextLanguage.ShowHelp(this.ServiceProvider, this._selection.Start); } else { this.TextLanguage.ShowHelp(this.ServiceProvider, this._location); } } goto Label_0C3E; } } Label_0C3E: if (flag) { if (isSelecting) { this.UpdateSelection(); return flag4; } this.ResetSelection(); return flag4; } if (flag2 && !isSelecting) { this.ResetSelection(); } return flag4; }
protected override bool UpdateCommand(Command command) { bool flag = false; if (command.CommandGroup != typeof(GlobalCommands)) { if (command.CommandGroup == typeof(TextBufferCommands)) { flag = base.UpdateCommand(command); } return flag; } int commandID = command.CommandID; if (commandID <= 120) { switch (commandID) { case 100: command.Enabled = base.CanUndo; return true; case 0x65: command.Enabled = base.CanRedo; return true; case 0x66: case 0x67: command.Enabled = base.CanCopy; return true; case 0x68: command.Enabled = base.CanPaste; return true; case 0x69: return flag; case 0x6a: command.Enabled = true; return true; case 0x6b: command.Enabled = true; return true; case 120: command.Enabled = (SnippetToolboxSection.Snippets != null) && base.CanCopy; return true; } return flag; } switch (commandID) { case 0x8d: { TextBufferCommand command2 = new TextBufferCommand(0x5c); ((ICommandHandler) this).UpdateCommand(command2); command.Enabled = command2.Enabled && base.SelectionExists; return true; } case 0x8e: { TextBufferCommand command3 = new TextBufferCommand(0x5d); ((ICommandHandler) this).UpdateCommand(command3); command.Enabled = command3.Enabled && base.SelectionExists; return true; } case 600: command.Enabled = true; return true; case 0x3e9: ((EditorStatusBarPanelCommand) command).Line = base.CaretLineIndex + 1; ((EditorStatusBarPanelCommand) command).Column = base.TabbedColumnIndex + 1; return true; case 0x3ea: if (base.InsertMode) { command.Text = "INS"; break; } command.Text = "OVR"; break; default: return flag; } return true; }