コード例 #1
0
        private void updateSuggestListBox(IntellisenseSuggest suggest, TextInputState source)
        {
            var values = suggest.Values.ToList();

            for (int i = 0; i < values.Count; i++)
            {
                values[i] = values[i].Replace(Environment.NewLine, " ");
            }

            lock (_syncSuggest)
            {
                _suggestSource = source;
                _suggestTypes  = suggest.Types;
                _suggestToken  = suggest.Token;

                _searchBar.SetMenuValues(values);
            }

            if (values.Count == 0)
            {
                continueEditingAfterSuggest();
            }
            else
            {
                updateSuggestLocation();
            }
        }
コード例 #2
0
        private void updateSuggestListBox(IntellisenseSuggest suggest, TextInputState source)
        {
            lock (_syncSuggest)
            {
                _suggestSource = source;
                _suggestTypes  = suggest.Types;
                _suggestToken  = suggest.Token;

                _listBoxSuggest.BeginUpdate();

                var index = _listBoxSuggest.SelectedIndex;

                _listBoxSuggest.Items.Clear();

                foreach (string value in suggest.Values)
                {
                    _listBoxSuggest.Items.Add(value);
                }

                _listBoxSuggest.SelectedIndex = index.WithinRange(-1, suggest.Values.Count - 1);

                _listBoxSuggest.EndUpdate();
            }

            if (suggest.Values.Count == 0)
            {
                _listBoxSuggest.Height = 0;
                continueEditingAfterSuggest();
            }
            else
            {
                _listBoxSuggest.Height = 2 + suggest.Values.Sum(getHeight);
                updateSuggestLocation();
            }
        }
コード例 #3
0
        public IntellisenseSuggest CycleValue(TextInputState input, bool backward, UiModel ui)
        {
            ensureIndexIsUpToDate(ui);

            lock (_sync)
                return(Spellchecker.CycleValue(null, input, backward));
        }
コード例 #4
0
        public IntellisenseSuggest Suggest(TextInputState searchState, UiModel ui)
        {
            ensureIndexIsUpToDate(ui);

            lock (_sync)
                return(Spellchecker.Suggest(language: null, input: searchState));
        }
コード例 #5
0
        private bool suggested(IntellisenseSuggest suggest, TextInputState source)
        {
            if (!_parent.Visible)
            {
                return(false);
            }

            return(_parent.Invoke(delegate { updateSuggestListBox(suggest, source); }));
        }
コード例 #6
0
        private void suggested(IntellisenseSuggest suggest, TextInputState source)
        {
            if (!_parent.Visible)
            {
                return;
            }

            _parent.Invoke(delegate { updateSuggestListBox(suggest, source); });
        }
コード例 #7
0
ファイル: TextInput.cs プロジェクト: MSylvia/DoomEngine
        public TextInput(IReadOnlyList <char> initialText, Action <IReadOnlyList <char> > typed, Action <IReadOnlyList <char> > finished, Action canceled)
        {
            this.text     = initialText.ToList();
            this.typed    = typed;
            this.finished = finished;
            this.canceled = canceled;

            this.state = TextInputState.Typing;
        }
コード例 #8
0
        private void removeQueryFromInput(int queryStartIndex, string query, TextInputState source)
        {
            string sourceText = source.Text;
            int    caret      = source.Caret;

            var(modifiedText, movedCaret) = removeSubstring(sourceText, caret, queryStartIndex, query.Length);
            (modifiedText, movedCaret)    = trimStart(modifiedText, movedCaret);
            (modifiedText, movedCaret)    = removeDuplicateWhitespaces(modifiedText, movedCaret);

            setFindText(modifiedText, movedCaret);
        }
コード例 #9
0
ファイル: IRCChatWindow.cs プロジェクト: timmersuk/ksp_irc
 internal void RestoreInputFocus(TextInputState state)
 {
     if (state.focused)
     {
         GUI.FocusControl(ChannelGUI.INPUT_CONTROL_NAME);
         TextEditor te = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
         if (te != null)
         {
             //these two lines prevent a "select all" effect on the textfield which seems to be the default GUI.FocusControl behavior
             te.cursorIndex = state.lastCursorPos;       //set cursor position
             te.selectIndex = state.lastSelectCursorPos; //set selection cursor position
         }
     }
 }
コード例 #10
0
ファイル: SearchSubsystem.cs プロジェクト: rajeshwarn/Mtgdb
        private void updateSuggestListBox(IntellisenseSuggest suggest, TextInputState source)
        {
            var values = suggest.Values.ToList();

            for (int i = 0; i < values.Count; i++)
            {
                values[i] = values[i].Replace(Environment.NewLine, " ");
            }

            lock (_syncSuggest)
            {
                _suggestSource = source;
                _suggestTypes  = suggest.Types;
                _suggestToken  = suggest.Token;

                _listBoxSuggest.BeginUpdate();

                var index = _listBoxSuggest.SelectedIndex;

                _listBoxSuggest.Items.Clear();

                foreach (string value in values)
                {
                    _listBoxSuggest.Items.Add(value);
                }

                _listBoxSuggest.SelectedIndex = index.WithinRange(-1, values.Count - 1);

                _listBoxSuggest.EndUpdate();
            }

            if (values.Count == 0)
            {
                _listBoxSuggest.Height = 0;
                continueEditingAfterSuggest();
            }
            else
            {
                int contentHeight = values.Sum(getHeight);
                _listBoxSuggest.Height = 2 + contentHeight;
                updateSuggestLocation();
            }
        }
コード例 #11
0
ファイル: TextInput.cs プロジェクト: MSylvia/DoomEngine
        public bool DoEvent(DoomEvent e)
        {
            var ch = e.Key.GetChar();

            if (ch != 0)
            {
                this.text.Add(ch);
                this.typed(this.text);

                return(true);
            }

            if (e.Key == DoomKey.Backspace && e.Type == EventType.KeyDown)
            {
                if (this.text.Count > 0)
                {
                    this.text.RemoveAt(this.text.Count - 1);
                }

                this.typed(this.text);

                return(true);
            }

            if (e.Key == DoomKey.Enter && e.Type == EventType.KeyDown)
            {
                this.finished(this.text);
                this.state = TextInputState.Finished;

                return(true);
            }

            if (e.Key == DoomKey.Escape && e.Type == EventType.KeyDown)
            {
                this.canceled();
                this.state = TextInputState.Canceled;

                return(true);
            }

            return(true);
        }
コード例 #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextViewInputEventArgs"/> class.
        /// </summary>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Specified <paramref name="state"/> does not belong to <see cref="TextInputState"/>.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="text"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Specified <paramref name="text"/> cannot be zero-length if <paramref name="state"/> = <see cref="F:Genetibase.Windows.Controls.Editor.Text.View.TextInputState.Provisional"/>.
        /// </exception>
        public TextViewInputEventArgs(TextInputState state, String text)
        {
            if ((state != TextInputState.Provisional) && (state != TextInputState.Final))
            {
                throw new ArgumentOutOfRangeException("state");
            }

            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            if ((state == TextInputState.Provisional) && (text.Length == 0))
            {
                throw new ArgumentException("Provisional TextInput can not be zero-length.");
            }

            this.State = state;
            this.Text  = text;
        }
コード例 #13
0
		/// <summary>
		/// Initializes a new instance of the <see cref="TextViewInputEventArgs"/> class.
		/// </summary>
		/// <exception cref="ArgumentOutOfRangeException">
		/// Specified <paramref name="state"/> does not belong to <see cref="TextInputState"/>.
		/// </exception>
		/// <exception cref="ArgumentNullException">
		/// <paramref name="text"/> is <see langword="null"/>.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Specified <paramref name="text"/> cannot be zero-length if <paramref name="state"/> = <see cref="F:Genetibase.Windows.Controls.Editor.Text.View.TextInputState.Provisional"/>.
		/// </exception>
		public TextViewInputEventArgs(TextInputState state, String text)
		{
			if ((state != TextInputState.Provisional) && (state != TextInputState.Final))
			{
				throw new ArgumentOutOfRangeException("state");
			}

			if (text == null)
			{
				throw new ArgumentNullException("text");
			}
			
			if ((state == TextInputState.Provisional) && (text.Length == 0))
			{
				throw new ArgumentException("Provisional TextInput can not be zero-length.");
			}
			
			this.State = state;
			this.Text = text;
		}
コード例 #14
0
ファイル: IRCChatWindow.cs プロジェクト: timmersuk/ksp_irc
        public void addToChannel(string handle, string sender, string text, IRCCommand cmd = null)
        {
            TextInputState textInputState = GetInputState();
            ChannelGUI     channelGUI     = getChannelGUI(handle);

            channelGUI.addToBuffer(sender, text, cmd);

            // show this channel if no channel is visible yet
            if (currentChannelGUI == null)
            {
                currentChannelGUI        = channelGUI;
                currentChannelGUI.hidden = false;
            }

            RestoreInputFocus(textInputState);

            if (config.tts)
            {
                speak(handle, sender, text, cmd);
            }
        }
コード例 #15
0
        public bool DoEvent(DoomEvent e)
        {
            if (DoomKeys.A <= e.Key && e.Key <= DoomKeys.Z && e.Type == EventType.KeyDown)
            {
                text.Add((char)(e.Key - DoomKeys.A + 'A'));
                typed(text);
                return(true);
            }

            if (e.Key == DoomKeys.Backspace &&
                e.Type == EventType.KeyDown)
            {
                if (text.Count > 0)
                {
                    text.RemoveAt(text.Count - 1);
                }
                typed(text);
                return(true);
            }

            if (e.Key == DoomKeys.Enter && e.Type == EventType.KeyDown)
            {
                finished(text);
                state = TextInputState.Finished;
                return(true);
            }

            if (e.Key == DoomKeys.Escape && e.Type == EventType.KeyDown)
            {
                canceled();
                state = TextInputState.Canceled;
                return(true);
            }

            return(true);
        }
コード例 #16
0
 protected abstract IntellisenseSuggest Suggest(TextInputState state);
コード例 #17
0
 protected override IntellisenseSuggest CycleValue(TextInputState currentState, bool backward) =>
 ((DeckSearcher)Searcher).CycleValue(currentState, backward);
コード例 #18
0
 protected override IntellisenseSuggest CycleValue(TextInputState currentState, bool backward) =>
 ((CardSearcher)Searcher).Spellchecker.CycleValue(currentState, backward, ((CardSuggestModel)SuggestModel).Language);
コード例 #19
0
 protected override IntellisenseSuggest Suggest(TextInputState searchState)
 {
     _language = Language;
     return(Searcher.Spellchecker.Suggest(searchState, _language));
 }
コード例 #20
0
 protected override IntellisenseSuggest Suggest(TextInputState searchState) =>
 ((DeckSearcher)Searcher).Suggest(searchState);
コード例 #21
0
        private void pasteText(string value, TokenType type, TextInputState source, Token token, bool positionCaretToNextValue)
        {
            int   left, length;
            Token start, end;

            bool isValuePhrase = value.StartsWith("\"") && value.EndsWith("\"");

            if (token == null || source.SelectionLength > 0 || type == TokenType.None)
            {
                (start, end)   = (null, null);
                (left, length) = (source.Caret, source.SelectionLength);
            }
            else
            {
                if (type == TokenType.FieldValue && token.IsPhrase && !_adapter.IsSuggestAnalyzedIn(token.ParentField, GetLanguage()) || isValuePhrase)
                {
                    (start, end) = (token.PhraseOpen, token.PhraseClose);
                }
                else
                {
                    (start, end) = (token, token);
                }

                (left, length) = (start.Position, end.Position + end.Value.Length - start.Position);
            }

            bool appendSpace  = positionCaretToNextValue && end?.Next?.Type.IsAny(TokenType.AnyClose) != true;
            bool prependSpace = positionCaretToNextValue && start?.Previous?.Type.IsAny(TokenType.AnyOpen) == false;

            string prefix = source.Text.Substring(0, left);
            string suffix = source.Text.Substring(left + length);

            if (prependSpace)
            {
                prefix = prefix.TrimEnd();
                value  = " " + value;
            }

            if (appendSpace)
            {
                suffix = suffix.TrimStart();
                value += " ";
            }

            if (type.IsAny(TokenType.Field) && suffix.StartsWith(":"))
            {
                suffix = suffix.Substring(1);
            }

            var replacement = prefix + value + suffix;
            int caret       = prefix.Length + value.Length;

            if (!positionCaretToNextValue && isValuePhrase && type != TokenType.None)
            {
                caret--;
            }

            setFindText(replacement, caret);
            updateBackColor();

            _highlighter.Highlight();
        }
コード例 #22
0
 protected abstract IntellisenseSuggest CycleValue(TextInputState currentState, bool backward);
コード例 #23
0
ファイル: DeckSearcher.cs プロジェクト: Zelfrom/Mtgdb
 public IntellisenseSuggest Suggest(TextInputState searchState) =>
 ((DeckSpellchecker)Spellchecker).Suggest(searchState, language: null);
コード例 #24
0
ファイル: DeckSearcher.cs プロジェクト: Zelfrom/Mtgdb
 public IntellisenseSuggest CycleValue(TextInputState input, bool backward) =>
 ((DeckSpellchecker)Spellchecker).CycleValue(input, backward, language: null);