public void Init(AbstractTerminal terminal, IShellScheme scheme, string[] current_input, IntelliSenseMode mode, char append_char) { _ownerControl = terminal.TerminalHost.TerminalControl; Debug.Assert(_ownerControl != null); TerminalDocument doc = terminal.GetDocument(); _commandStartPoint = new Point(doc.CaretColumn + (append_char == '\0' ? 0 : 1), doc.CurrentLineNumber - doc.TopLineNumber); Debug.WriteLineIf(DebugOpt.IntelliSense, String.Format("IS CtxInit M={0} CaretC={1}", mode.ToString(), doc.CaretColumn)); _scheme = scheme; _currentInput = current_input; _intelliSenseMode = mode; Debug.Assert(_currentInput != null); _charQueue.LockedInit(append_char); _buffer.Remove(0, _buffer.Length); if (_intelliSenseMode == IntelliSenseMode.CharComplement) { string last_arg = current_input[current_input.Length - 1]; _buffer.Append(last_arg); _commandStartPoint.X -= last_arg.Length; } BuildCandidates(); }
//append_charは、インテリセンス起動元が文字入力であるときその文字、Ctrl+.などの直接起動であるとき\0 private void PopupMain(char append_char) { IShellScheme ss = GetTerminalSettings().ShellScheme; StringBuilder buf = new StringBuilder(); buf.Append(_currentCommand); if (append_char != '\0') { buf.Append(append_char); } string line = buf.ToString(); string[] args = ss.ParseCommandInput(line); //(一旦廃止)日本語が入っているとCaretColumnで探すとアウトになる。根本的に直すにはコマンドパーサがGLineの内部を知っていないといけない //int cc = _terminal.GetDocument().CaretColumn; IntelliSenseMode mode = line.Length == 0 || ss.IsDelimiter(line[line.Length - 1]) ? IntelliSenseMode.ArgComplement : IntelliSenseMode.CharComplement; _context.Init(_terminal, ss, args, mode, append_char); if (!_context.IsEmpty) { if (_intelliSenseWindow == null) { _intelliSenseWindow = new IntelliSenseWindow(); //遅延作成 } _intelliSenseWindow.Popup(_context); } }
public void Complement(string complement) { _buffer.Remove(0, _buffer.Length); if (_intelliSenseMode == IntelliSenseMode.CharComplement) { _currentInput[_currentInput.Length - 1] = complement; } else { //append string[] t = new string[_currentInput.Length + 1]; Array.Copy(_currentInput, 0, t, 0, _currentInput.Length); t[t.Length - 1] = complement; _currentInput = t; } _intelliSenseMode = IntelliSenseMode.ArgComplement; BuildCandidates(); }