private void ApplyAutocomplete(AutocompleteItem item, Range fragment) { var newText = item.GetTextForReplace(); //replace text of fragment var index = fragment.Text.IndexOfAny(SpecialSymbols.SuperscriptsWithoutSpace.ToCharArray()); if (index == 0) { newText = SpecialSymbols.AsciiToSuperscript(newText); } else if (index > 0) { newText = fragment.Text.Substring(0, index) + SpecialSymbols.AsciiToSuperscript(newText); } else if (_sharedViewState.IsExponent) { newText = fragment.Text + SpecialSymbols.AsciiToSuperscript(newText); } fragment.Text = newText; fragment.TargetWrapper.TargetControl.Focus(); }
public bool Add(string value, AutocompleteItemCategory category) { AutocompleteItem item = null; switch (category) { case AutocompleteItemCategory.Keyword: item = new AutocompleteItem(value); break; case AutocompleteItemCategory.Method: item = new MethodAutocompleteItem(value); // { ImageIndex = (int)category }; break; default: return(false); } if (item.Text != "") { if (!_suggestions.Exists(x => x.Text == item.Text)) { Suggestions.Add(item); return(true); } } return(false); }
private void SelectAutoCompleteItem(AutocompleteItem item) { if (_autoCompleteMenu != null) { _autoCompleteMenu.Items.FocussedItem = item; _autoCompleteMenu.Items.DoSelectedVisible(); } }
void AddVariableSymbols(String[] symbols) { for (var i = 0; i < symbols.Length; i++) { var message = String.Format(Messages.LocalVariable, symbols[i]); var item = new AutocompleteItem(symbols[i], message, IconFactory.VariableIcon); Items.Add(item); VariableItems.Add(item); } }
/// <summary> /// Сохраняет в базе модель создания элемента. /// </summary> /// <param name="token">Токен безопасности.</param> /// <param name="model">Модель создания сущности для сохранения.</param> /// <param name="result">Результат с ошибками.</param> public override void SaveCreateModel(SecurityToken token, AutocompleteItemCreateModel model, GridSaveModelResult result) { var entity = new AutocompleteItem { AutocompleteItemID = model.AutocompleteItemID, AutocompleteKindID = model.AutocompleteKindID, Title = model.Title, UserDomainID = token.User.UserDomainID }; RemontinkaServer.Instance.EntitiesFacade.SaveAutocompleteItem(token, entity); }
public FunctionOrConstantCommand(AutocompleteItem autocompleteItem, ITextProvider expressionTextProvider, IScriptProvider scriptingTextProvider, IScriptProvider customFunctionsTextProvider, ISharedViewState sharedViewState, IClickedMouseButtonsProvider clickedMouseButtonsProvider, IShowFunctionDetails showFunctionDetails) { this._autocompleteItem = autocompleteItem; //TODO: do we really want to show signature as text and title as tooltip? Text = _autocompleteItem.Details.Signature; ToolTip = _autocompleteItem.Details.Title; _expressionTextProvider = expressionTextProvider; _scriptingTextProvider = scriptingTextProvider; _customFunctionsTextProvider = customFunctionsTextProvider; _sharedViewState = sharedViewState; _clickedMouseButtonsProvider = clickedMouseButtonsProvider; _showFunctionDetails = showFunctionDetails; }
public void AddItem(AutocompleteItem item) { if (sourceItems == null) { sourceItems = new List <AutocompleteItem>(); } if (sourceItems is IList) { (sourceItems as IList).Add(item); } else { throw new Exception("Current autocomplete items does not support adding"); } }
private void initializeMenuWCommands() { AutocompleteItem item; foreach (string command in commands) { item = new AutocompleteItem(command); item.MenuText = command; autocompleteMenu1.AddItem(item); } //item.MenuText = "zahraj(zvuk)"; //autocompleteMenu1.AddItem(item); //item = new AutocompleteItem("povedz"); //item.MenuText = "povedz(text)"; //autocompleteMenu1.AddItem(item); }
/// <summary> /// Сохраняет в базе модель создания элемента. /// </summary> /// <param name="token">Токен безопасности.</param> /// <param name="model">Модель создания сущности для сохранения.</param> /// <param name="result">Результат выполнения..</param> public override AutocompleteItemGridItemModel SaveCreateModel(SecurityToken token, AutocompleteItemCreateModel model, JGridSaveModelResult result) { var entity = new AutocompleteItem { AutocompleteItemID = model.Id, AutocompleteKindID = model.AutocompleteKindID, Title = model.Title, UserDomainID = token.User.UserDomainID }; RemontinkaServer.Instance.EntitiesFacade.SaveAutocompleteItem(token, entity); return(new AutocompleteItemGridItemModel { AutocompleteKindTitle = AutocompleteKindSet.GetKindByID(entity.AutocompleteKindID).Title, Id = entity.AutocompleteItemID, Title = entity.Title }); }
private void AddUnlessDuplicate(AutocompleteItem snip) { //already got this snip if (items.Any(i => i.Text.Equals(snip.Text) && i.MenuText.Equals(snip.MenuText))) { return; } if (_activator == null) { throw new Exception("You cannot add items to AutoCompleteProvider until it has an ItemActivator"); } snip.ToolTipTitle = "Code Snip"; snip.ToolTipText = snip.Text; items.Add(snip); _autocomplete.SetAutocompleteItems(items); }
public void InitAutoMenus() { items.Clear(); foreach (string k in tooltipDic.Keys) { AutocompleteItem item = new AutocompleteItem(k); item.ToolTipTitle = k; item.ToolTipText = tooltipDic[k]; items.Add(item); } foreach (string k in longTooltipDic.Keys) { if (tooltipDic.ContainsKey(k)) { continue; } AutocompleteItem item = new AutocompleteItem(k); item.ToolTipTitle = k; item.ToolTipText = longTooltipDic[k]; items.Add(item); } }
public void ShowToolTip(AutocompleteItem autocompleteItem, Control control = null) { toolTip.Close(); var signature = autocompleteItem.Text; if (!_functionDetails.ContainsKey(signature)) { return; } var functionInfo = _functionDetails[signature]; if (string.IsNullOrWhiteSpace(functionInfo.Description) || string.IsNullOrWhiteSpace(functionInfo.Title) || functionInfo.Description.Contains("here goes description (not done yet)") || functionInfo.Title.Contains("_title_") ) { return; } if (Settings.Default.TooltipType == TooltipType.Default) { toolTip.setFunctionInfo(functionInfo); if (control == null) { control = this; } toolTip.Show(control, Width + 3, 0); } else if (Settings.Default.TooltipType == TooltipType.Form) { formTip.SetFunctionInfo(functionInfo); formTip.Show(); } }
public static CompletionData ToCompletionData(AutocompleteItem autocompleteItem) { return(new CompletionData(autocompleteItem.Text, autocompleteItem.MenuText, autocompleteItem.ImageIndex, autocompleteItem.Details)); }
public static CompletionData ToCompletionData(AutocompleteItem autocompleteItem) { return(new CompletionData(autocompleteItem.Text, autocompleteItem.MenuText, autocompleteItem.Info, autocompleteItem.ImageIndex, autocompleteItem.sharedViewState)); }
static List <AutocompleteItem> parseLine(string line, int ln = -1, string file = "") { List <AutocompleteItem> ret = new List <AutocompleteItem>(); AutocompleteItem item = null; line = line.Trim(); //Remove comment if (line.IndexOf("//") >= 0) { line = line.Substring(0, line.IndexOf("//")); } //Check if commas if (line.IndexOf(",") >= 0) { //Remove comment string tLine = line; //Collapse containers down so they don't interfere with the checking List <string> preStrings = new List <string>(); preStrings.AddRange(parseLine_Collapse(ref tLine, "{", "}", preStrings.Count)); preStrings.AddRange(parseLine_Collapse(ref tLine, "[", "]", preStrings.Count)); preStrings.AddRange(parseLine_Collapse(ref tLine, "(", ")", preStrings.Count)); preStrings.AddRange(parseLine_Collapse(ref tLine, "\"", "\"", preStrings.Count)); if (tLine.IndexOf(",") >= 0) { string[] parts = tLine.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string type = ""; for (int p = 0; p < parts.Length; p++) { string part = parts[p]; if (p != 0) { part = parseLine_Expand(part, preStrings); item = _parseLine(type + " " + part.Trim(), ln, file); if (item != null) { ret.Add(item); } } else { string[] pWords = part.Trim().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); if (part.IndexOf("=") < 0 && part.IndexOf(":") < 0) //everything but last word is the type { type = String.Join(" ", pWords, 0, pWords.Length - 1); } else //account for equal sign { int pInd = 0; while (pInd < pWords.Length && pWords[pInd].IndexOf("=") < 0 && pWords[pInd].IndexOf(":") < 0) { pInd++; } if (pWords[pInd].IndexOf("=") == 0) { pInd--; } if (pWords[pInd].IndexOf(":") == 0) { pInd--; } type = String.Join(" ", pWords, 0, pInd); } part = parseLine_Expand(part, preStrings); item = _parseLine(part, ln, file); if (item != null) { ret.Add(item); } } } } else { tLine = parseLine_Expand(tLine, preStrings); item = _parseLine(tLine, ln, file); if (item != null) { ret.Add(item); } } } else { item = _parseLine(line, ln, file); if (item != null) { ret.Add(item); } } return(ret); }
static AutocompleteItem _parseLine(string line, int ln = -1, string file = "") { AutocompleteItem ret = new AutocompleteItem(); if (line == null || line == "") { return(null); } try { line = line.Trim().Trim(';'); string[] words = line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); //#define VARNAME VALUE if (words[0].ToLower() == "#define") { if (words.Length <= 2) //needs a value { return(null); } ret.MenuText = words[1]; ret.Text = words[1]; ret.ToolTipText = line; ret.ToolTipTitle = words[1]; if (ln >= 0) { ret.ToolTipTitle += " (File:" + file + ",Line:" + ln.ToString() + ")"; } return(ret); } if (words[0].ToLower() == "register") { //Find the = int regIndex = 0; while (regIndex < words.Length && words[regIndex].IndexOf("=") < 0) { regIndex++; } if (regIndex >= words.Length) { return(null); } regIndex -= 2; if (regIndex < 0) { regIndex = 1; } ret.MenuText = words[regIndex]; ret.Text = words[regIndex]; ret.ToolTipText = line; ret.ToolTipTitle = words[regIndex]; if (ln >= 0) { ret.ToolTipTitle += " (File:" + file + ",Line:" + ln.ToString() + ")"; } return(ret); } //Bit definition (part of struct) if (line.IndexOf(" : ") > 0 && !(line.IndexOf(" = ") >= 0 && line.IndexOf(" = ") < line.IndexOf(" : "))) { int colonIndex = 0; while (words[colonIndex] != ":") { colonIndex++; } if (!Globals.CKeywords.Contains(words[colonIndex - 1].ToLower())) //this means its has a name!! { ret.MenuText = words[colonIndex - 1]; ret.Text = words[colonIndex - 1]; ret.ToolTipText = line; ret.ToolTipTitle = words[colonIndex - 1]; if (ln >= 0) { ret.ToolTipTitle += " (File:" + file + ",Line:" + ln.ToString() + ")"; } return(ret); } return(null); } //find name (finds the ; or = to denote variable) int x = 0; for (x = 0; x < words.Length; x++) { if (words[x].IndexOf("(") >= 0) //function? { if (words[x].IndexOf("(") == 0) //go back one for name { x--; words[x] += "()"; break; } else { words[x] = words[x].Split('(')[0] + "()"; break; } } if (words[x].EndsWith(";")) { break; } if (words[x] == "=") { x--; break; } } if (x < words.Length) //found name { words[x] = words[x].Replace("*", ""); ret.MenuText = words[x]; ret.Text = words[x]; ret.ToolTipText = line; ret.ToolTipTitle = words[x]; if (ln >= 0) { ret.ToolTipTitle += " (File:" + file + ",Line:" + ln.ToString() + ")"; } return(ret); } } catch (Exception ee) { return(null); } return(null); }
public void ShowToolTip(AutocompleteItem autocompleteItem, Control control = null) { }
public override void OnAutocomplete(AutocompleteItem item, FastColoredTextBox textBox) { }
private void DoAutocomplete(AutocompleteItem item, Range fragment) { string newText = item.GetTextForReplace(); //replace text of fragment var tb = fragment.tb; tb.BeginAutoUndo(); tb.TextSource.Manager.ExecuteCommand(new SelectCommand(tb.TextSource)); if (tb.Selection.ColumnSelectionMode) { var start = tb.Selection.Start; var end = tb.Selection.End; start.iChar = fragment.Start.iChar; end.iChar = fragment.End.iChar; tb.Selection.Start = start; tb.Selection.End = end; } else { tb.Selection.Start = fragment.Start; tb.Selection.End = fragment.End; } tb.InsertText(newText); tb.TextSource.Manager.ExecuteCommand(new SelectCommand(tb.TextSource)); tb.EndAutoUndo(); tb.Focus(); }
private void SetToolTip(AutocompleteItem autocompleteItem) { var title = autocompleteItem.ToolTipTitle; var text = autocompleteItem.ToolTipText; if (string.IsNullOrEmpty(title)) { toolTip.ToolTipTitle = null; toolTip.SetToolTip(this, null); return; } IWin32Window window = this.Parent ?? this; Point location = new Point((window == this ? Width : Right) + 3, 0); if (string.IsNullOrEmpty(text)) { toolTip.ToolTipTitle = null; toolTip.Show(title, window, location.X, location.Y, ToolTipDuration); } else { toolTip.ToolTipTitle = title; toolTip.Show(text, window, location.X, location.Y, ToolTipDuration); } }
public override void OnAutocomplete(AutocompleteItem item, FastColoredTextBox textBox) { pattern = true; lastLine = 0; }
public abstract void OnAutocomplete(AutocompleteItem item, FastColoredTextBox textBox);
private static int CompareItems(AutocompleteItem x, AutocompleteItem y) { return((x.MenuText ?? x.Text).CompareTo(y.MenuText ?? y.Text)); }
public void ShowTooltipWithLabel(AutocompleteItem item) { ShowTooltipWithLabel(item.ToolTipTitle, item.ToolTipText); }