internal bool ExpandTo(GLine line, int position, RangeType type) { line.ExpandBuffer(position + 1); _disabledTemporary = false; _state = SelectionState.Expansion; _forwardDestination._line = line.ID; _backwardDestination._line = line.ID; //Debug.WriteLine(String.Format("ExpandTo Line{0} Position{1}", line.ID, position)); switch (type) { case RangeType.Char: _forwardDestination._position = position; _backwardDestination._position = position; break; case RangeType.Word: _forwardDestination._position = line.FindPrevWordBreak(position) + 1; _backwardDestination._position = line.FindNextWordBreak(position); break; case RangeType.Line: _forwardDestination._position = 0; _backwardDestination._position = line.CharLength; break; } return(true); }
internal bool StartSelection(TerminalPane owner, GLine line, int position, RangeType type, int x, int y) { Debug.Assert(owner != null); Debug.Assert(position >= 0); line.ExpandBuffer(position + 1); _disabledTemporary = false; _owner = owner; _pivotType = type; _forwardPivot._line = line.ID; _backwardPivot._line = line.ID; _forwardDestination._line = line.ID; _forwardDestination._position = position; _backwardDestination._line = line.ID; _backwardDestination._position = position; switch (type) { case RangeType.Char: _forwardPivot._position = position; _backwardPivot._position = position; break; case RangeType.Word: _forwardPivot._position = line.FindPrevWordBreak(position) + 1; _backwardPivot._position = line.FindNextWordBreak(position); break; case RangeType.Line: _forwardPivot._position = 0; _backwardPivot._position = line.CharLength; break; } _state = SelectionState.Pivot; _startX = x; _startY = y; return(true); }
internal bool ExpandTo(GLine line, int position, RangeType type) { line.ExpandBuffer(position+1); _disabledTemporary = false; _state = SelectionState.Expansion; _forwardDestination._line = line.ID; _backwardDestination._line = line.ID; //Debug.WriteLine(String.Format("ExpandTo Line{0} Position{1}", line.ID, position)); switch(type) { case RangeType.Char: _forwardDestination._position = position; _backwardDestination._position = position; break; case RangeType.Word: _forwardDestination._position = line.FindPrevWordBreak(position)+1; _backwardDestination._position = line.FindNextWordBreak(position); break; case RangeType.Line: _forwardDestination._position = 0; _backwardDestination._position = line.CharLength; break; } return true; }
internal bool StartSelection(TerminalPane owner, GLine line, int position, RangeType type, int x, int y) { Debug.Assert(owner!=null); Debug.Assert(position>=0); line.ExpandBuffer(position+1); _disabledTemporary = false; _owner = owner; _pivotType = type; _forwardPivot._line = line.ID; _backwardPivot._line = line.ID; _forwardDestination._line = line.ID; _forwardDestination._position = position; _backwardDestination._line = line.ID; _backwardDestination._position = position; switch(type) { case RangeType.Char: _forwardPivot._position = position; _backwardPivot._position = position; break; case RangeType.Word: _forwardPivot._position = line.FindPrevWordBreak(position)+1; _backwardPivot._position = line.FindNextWordBreak(position); break; case RangeType.Line: _forwardPivot._position = 0; _backwardPivot._position = line.CharLength; break; } _state = SelectionState.Pivot; _startX = x; _startY = y; return true; }
public bool ProcessKey(Keys key) { Keys body = key & Keys.KeyCode; bool shift = (key & Keys.Shift) != Keys.None; bool control = (key & Keys.Control) != Keys.None; bool processed = false; //移動先の行と桁の計算 GLine nextLine = _currentLine; _document.InvalidateLine(nextLine.ID); if (body == Keys.Up) { if (_currentLine.PrevLine != null) { nextLine = _currentLine.PrevLine; } _document.InvalidateLine(nextLine.ID); processed = true; } else if (body == Keys.Down) { if (_currentLine.NextLine != null) { nextLine = _currentLine.NextLine; } _document.InvalidateLine(nextLine.ID); processed = true; } else if (body == Keys.PageUp) { int n = _currentLine.ID - _owner.Connection.TerminalHeight; nextLine = n <= _document.FirstLineNumber? _document.FirstLine : _document.FindLine(n); _document.InvalidateAll(); processed = true; } else if (body == Keys.PageDown) { int n = _currentLine.ID + _owner.Connection.TerminalHeight; nextLine = n >= _document.LastLineNumber? _document.LastLine : _document.FindLine(n); _document.InvalidateAll(); processed = true; } int nextPos = _caretPos; if (body == Keys.Home) { nextPos = 0; processed = true; } else if (body == Keys.End) { nextPos = _currentLine.CharLength - 1; processed = true; } else if (body == Keys.Left) { if (nextPos > 0) { if (control) { nextPos = _currentLine.FindPrevWordBreak(nextPos - 1) + 1; } else { nextPos--; } } processed = true; } else if (body == Keys.Right) { if (nextPos < _currentLine.CharLength - 1) { if (control) { nextPos = _currentLine.FindNextWordBreak(nextPos + 1); } else { nextPos++; } } processed = true; } //選択領域の調整 TextSelection sel = GEnv.TextSelection; if (shift && processed) { if (sel.IsEmpty) { sel.StartSelection(_owner, _currentLine, _caretPos, RangeType.Char, -1, -1); } sel.ExpandTo(nextLine, nextPos, RangeType.Char); } else if (processed || body == Keys.Menu || body == Keys.ControlKey || body == Keys.ShiftKey) { if (processed) { sel.Clear(); } processed = true; } else { //一般キーの入力があったら即時選択解除 sel.Clear(); } Debug.Assert(nextLine != null); _currentLine = nextLine; _caretPos = nextPos; return(processed); }