public PositionNode ViPositionNext() { PositionNode node = null; if (_nextCount > 1) { ++_prevCount; --_nextCount; node = positionHistory[(_offset + _prevCount) % _maxViPositions]; } return(node); }
public PositionNode ViPositionPrev() { PositionNode node = null; if (_prevCount > 0) { node = positionHistory[(_offset + _prevCount - 1) % _maxViPositions]; --_prevCount; ++_nextCount; } return(node); }
public void ViPositionSet(int position) { if (_nextCount > 0) { PositionNode node = positionHistory[(_offset + _prevCount) % _maxViPositions]; if (node.file == currentFile && _lastFile == currentFile) { _lastPosition = position; node.position = position; if (_nextCount > 0) { for (int i = 1; i < _nextCount; ++i) { positionHistory[(_offset + _prevCount + i) % _maxViPositions] = null; } _nextCount = 1; } return; } } ViPositionAdd(position); }
public override void InsertText(int index, string text) { PositionFile currentFile = _controller.macrosExecutor.currentFile; PositionNode[] positionHistory = _controller.macrosExecutor.positionHistory; for (int i = 0; i < positionHistory.Length; ++i) { PositionNode node = positionHistory[i]; if (node != null && node.file == currentFile && node.position > index) { node.position += text.Length; } } int pcIndex = _controller.macrosExecutor.bookmarkFiles.IndexOf(currentFile); if (pcIndex != -1) { List <PositionChar> pcs = _controller.macrosExecutor.bookmarks[pcIndex]; for (int i = pcs.Count; i-- > 0;) { PositionChar pc = pcs[i]; if (pc.position > pcIndex) { pc.position += text.Length; pcs[i] = pc; } } } for (int i = _controller.bookmarks.Count; i-- > 0;) { int position = _controller.bookmarks[i]; if (position != -1 && position > index) { _controller.bookmarks[i] = position + text.Length; } } }
public void ViPositionAdd(int position) { if (currentFile != null && (_lastFile != currentFile || _lastPosition != position)) { _lastFile = currentFile; _lastPosition = position; if (_nextCount > 0) { ++_prevCount; for (int i = 0; i < _nextCount - 1; ++i) { positionHistory[(_offset + _prevCount + i) % _maxViPositions] = null; } _nextCount = 0; } positionHistory[(_offset + _prevCount) % _maxViPositions] = new PositionNode(currentFile, position); ++_nextCount; if (_prevCount + _nextCount > _maxViPositions) { _offset = (_offset + 1) % _maxViPositions; --_prevCount; } } }
public MacrosExecutor(Getter <MulticaretTextBox> getTextBox, int maxViPositions) { this.getTextBox = getTextBox; _maxViPositions = maxViPositions; positionHistory = new PositionNode[_maxViPositions]; }
public override void RemoveText(int index, int count) { PositionFile currentFile = _controller.macrosExecutor.currentFile; PositionNode[] positionHistory = _controller.macrosExecutor.positionHistory; for (int i = 0; i < positionHistory.Length; ++i) { PositionNode node = positionHistory[i]; if (node != null && node.file == currentFile && node.position > index) { node.position -= count; if (node.position < index) { node.position = index; } } } int pcIndex = _controller.macrosExecutor.bookmarkFiles.IndexOf(currentFile); if (pcIndex != -1) { List <PositionChar> pcs = _controller.macrosExecutor.bookmarks[pcIndex]; for (int i = pcs.Count; i-- > 0;) { PositionChar pc = pcs[i]; if (pc.position > pcIndex) { pc.position -= count; if (pc.position < pcIndex) { pcs.RemoveAt(i); if (pcs.Count == 0) { _controller.bookmarks.RemoveAt(pcIndex); break; } } else { pcs[i] = pc; } } } } for (int i = _controller.bookmarks.Count; i-- > 0;) { int position = _controller.bookmarks[i]; if (position != -1 && position > index) { position -= count; if (position < index) { _controller.bookmarkNames.RemoveAt(i); _controller.bookmarks.RemoveAt(i); } else { _controller.bookmarks[i] = position; } } } }