public void Initialize(ScintillaControl editControl) { searchHelper = SearchHelper.Instance(editControl); searchHelper.Criteria.AddFindHistory += new EventHandler(Criteria_AddFindHistory); searchHelper.Criteria.AddReplaceHistory += new EventHandler(Criteria_AddReplaceHistory); BindHistory(); }
public void Configure(ScintillaControl scintilla, string language) { if (language == null || language.Equals("")) return; Language lang = this.GetLanguage(language); if (lang == null) return; scintilla.StyleClearAll(); System.Type enumtype = typeof(Enums.Lexer); try { scintilla.Lexer = (int)Enum.Parse(typeof(Enums.Lexer), lang.lexer.name, true); } catch (Exception) { // try by key instead scintilla.Lexer = lang.lexer.key; } if (lang.lexer.stylebits > 0) scintilla.StyleBits = lang.lexer.stylebits; for (int j = 0; j < lang.usestyles.Length; j++) { UseStyle usestyle = lang.usestyles[j]; if (usestyle.HasForegroundColor) scintilla.StyleSetFore(usestyle.key, usestyle.ForegroundColor); if (usestyle.HasBackgroundColor) scintilla.StyleSetBack(usestyle.key, usestyle.BackgroundColor); if (usestyle.HasFontName) scintilla.StyleSetFont(usestyle.key, usestyle.FontName); if (usestyle.HasFontSize) scintilla.StyleSetSize(usestyle.key, usestyle.FontSize); if (usestyle.HasBold) scintilla.StyleSetBold(usestyle.key, usestyle.IsBold); if (usestyle.HasItalics) scintilla.StyleSetItalic(usestyle.key, usestyle.IsItalics); if (usestyle.HasEolFilled) scintilla.StyleSetEOLFilled(usestyle.key, usestyle.IsEolFilled); } // clear the keywords lists for (int j = 0; j < 9; j++) scintilla.KeyWords(j, ""); for (int j = 0; j < lang.usekeywords.Length; j++) { UseKeyword usekeyword = lang.usekeywords[j]; KeywordClass kc = this.GetKeywordClass(usekeyword.cls); if (kc != null) scintilla.KeyWords(usekeyword.key, kc.val); } }
public static SearchHelper Instance(ScintillaControl editControl) { if (helper.EditControl != editControl) { helper.EditControl = editControl; // Define the Find Marker and set its color helper.EditControl.MarkerDefine(FIND_MARKER, Scintilla.Enums.MarkerSymbol.RoundRectangle); helper.EditControl.MarkerSetBackgroundColor(FIND_MARKER, (255 | (255 << 8) | (0 << 16))); helper.EditControl.MarkerSetForegroundColor(FIND_MARKER, 0); helper.EditControl.SetVisiblePolicy((int)Scintilla.Enums.CaretPolicy.Strict, 0); helper.EditControl.SetXCaretPolicy((int)(Scintilla.Enums.CaretPolicy.Jumps | Scintilla.Enums.CaretPolicy.Even), 0); } return helper; }
public static int Show(ScintillaControl oScintillaControl) { GoToLineDialog oGoToLineDialog; DialogResult oDialogResult; int iLine; iLine = oScintillaControl.LineFromPosition(oScintillaControl.CurrentPos) + 1; oGoToLineDialog = new GoToLineDialog(oScintillaControl.LineCount, iLine); oDialogResult = oGoToLineDialog.ShowDialog(); if (oDialogResult == DialogResult.OK) { iLine = (int) oGoToLineDialog.numericUpDown.Value; oScintillaControl.GotoLine(iLine - 1); } return iLine; }
private void OnUIRefresh(ScintillaControl sci) { if (sci != null && sci.IsFocus) { int position = sci.CurrentPos; if (CompletionList.Active && CompletionList.CheckPosition(position)) { return; } if (callTip.CallTipActive && callTip.CheckPosition(position)) { return; } } callTip.Hide(); CompletionList.Hide(); simpleTip.Hide(); }
public List <Int32> GetMarkers(ScintillaControl sci, int markerNum) { Int32 line = 0; List <Int32> markerLines = new List <Int32>(); while (true) { int i = sci.MarkerNext(line, GetMarkerMask(markerNum)); if ((sci.MarkerNext(line, GetMarkerMask(markerNum)) == -1) || (line > sci.LineCount)) { break; } line = sci.MarkerNext(line, GetMarkerMask(markerNum)); markerLines.Add(line); line++; } return(markerLines); }
/// <summary> /// Applies all shortcuts to the items /// </summary> public static void ApplyAllShortcuts() { ShortcutManager.UpdateAllShortcuts(); foreach (ShortcutItem item in RegistedItems) { if (item.Item != null) { item.Item.ShortcutKeys = Keys.None; item.Item.ShortcutKeys = item.Custom; } else if (item.Default != item.Custom) { ScintillaControl.UpdateShortcut(item.Id, item.Custom); DataEvent de = new DataEvent(EventType.Shortcut, item.Id, item.Custom); EventManager.DispatchEvent(Globals.MainForm, de); } } }
public static int Show(ScintillaControl oScintillaControl) { GoToLineDialog oGoToLineDialog; DialogResult oDialogResult; int iLine; iLine = oScintillaControl.LineFromPosition(oScintillaControl.CurrentPos) + 1; oGoToLineDialog = new GoToLineDialog(oScintillaControl.LineCount, iLine); oDialogResult = oGoToLineDialog.ShowDialog(); if (oDialogResult == DialogResult.OK) { iLine = (int)oGoToLineDialog.numericUpDown.Value; oScintillaControl.GotoLine(iLine - 1); } return(iLine); }
static string Common(ScintillaControl sci, string sourceText, string newName) { SetSrc(sci, sourceText); var waitHandle = new AutoResetEvent(false); CommandFactoryProvider.GetFactory(sci) .CreateRenameCommandAndExecute(RefactoringHelper.GetDefaultRefactorTarget(), false, newName) .OnRefactorComplete += (sender, args) => waitHandle.Set(); var end = DateTime.Now.AddSeconds(2); var result = false; while ((!result) && (DateTime.Now < end)) { context.Send(state => {}, new {}); result = waitHandle.WaitOne(0); } return(sci.Text); }
/// <summary> /// /// </summary> static public void SciControl_MarginClick(ScintillaControl sender, int modifiers, int position, int margin) { if (margin != 0) { return; } //if (PluginMain.debugManager.FlashInterface.isDebuggerStarted && !PluginMain.debugManager.FlashInterface.isDebuggerSuspended) return; int line = sender.LineFromPosition(position); if (IsMarkerSet(sender, markerBPEnabled, line)) { sender.MarkerDelete(line, markerBPEnabled); } else { sender.MarkerAdd(line, markerBPEnabled); } }
/// <summary> /// Scale the control area based on font size and DPI /// </summary> private static Int32 ScaleArea(ScintillaControl sci, Int32 size) { Int32 value = ScaleHelper.Scale(size); Language lang = SciConfig.GetLanguage(sci.ConfigurationLanguage); if (lang != null && lang.usestyles != null && lang.usestyles.Length > 0) { // Only larger fonts need scaling... if (lang.usestyles[0].FontSize < 11) { return(value); } Double multi = lang.usestyles[0].FontSize / 9f; Double adjusted = Convert.ToDouble(value) * (multi < 1 ? 1 : multi); value = Convert.ToInt32(Math.Floor(adjusted)); } return(value); }
/// <summary> /// スタイル情報の初期設定 /// スタイルセットの直前でセットすること /// </summary> /// <param name="sci"></param> private void initStyleSetting(ScintillaControl sci) { if (m_isFirstStyleSetting) { m_isFirstStyleSetting = false; //カラー設定 /* * sci.StyleClearAll(); * sci.StyleResetDefault(); */ /* * string defaultForeColor = "0xDDDDDD"; * string defaultBackColor = "0x222222"; * string defaultFontName = "MS GOTHIC"; * int defaultFontSize = 10; * * setColor(sci, STYLE_COMMENT, "0x64B1FF", defaultBackColor, defaultFontName, defaultFontSize); * setColor(sci, STYLE_LABEL, "0x80FF00", defaultBackColor, defaultFontName, defaultFontSize); * setColor(sci, STYLE_TAG, "0xFF8080", defaultBackColor, defaultFontName, defaultFontSize); * setColor(sci, STYLE_TAG_ATTR, "0xC0C040", defaultBackColor, defaultFontName, defaultFontSize); * setColor(sci, STYLE_TAG_ATTR_VALUE, "0x00A45F", defaultBackColor, defaultFontName, defaultFontSize); * setColor(sci, STYLE_TJS_SCRIPT, "0xDDDDDD", defaultBackColor, defaultFontName, defaultFontSize); */ /* * //デフォルトスタイル * setColor(sci, STYLE_DEFAULT, defaultForeColor, defaultBackColor, defaultFontName, defaultFontSize); * setColor(sci, STYLE_GDEFAULT, defaultForeColor, defaultBackColor, defaultFontName, defaultFontSize); * setColor(sci, STYLE_LINENUMBER, "0x222222", "0xDDDDDD", defaultFontName, defaultFontSize); * setColor(sci, STYLE_BRACELIGHT, "0x0000cc", "0xcdcdff", defaultFontName, defaultFontSize); * setColor(sci, STYLE_BRACEBAD, defaultForeColor, defaultBackColor, defaultFontName, defaultFontSize); * setColor(sci, STYLE_CONTROLCHAR, defaultForeColor, defaultBackColor, defaultFontName, defaultFontSize); * setColor(sci, STYLE_INDENTGUIDE, defaultForeColor, defaultBackColor, defaultFontName, defaultFontSize); * setColor(sci, STYLE_CALLTIP, defaultForeColor, defaultBackColor, defaultFontName, defaultFontSize); * setColor(sci, STYLE_LASTPREDEFINED, defaultForeColor, defaultBackColor, defaultFontName, defaultFontSize); */ } else { //2回目以降のみ PluginMain.ParserSrv.ParseFile(this.CurrentFile, m_sci.Text); } }
/// <summary> /// Gets the next valid match but fixes position with selected text's length /// </summary> public static SearchMatch GetNextDocumentMatch(ScintillaControl sci, List <SearchMatch> matches, Boolean forward, Boolean fixedPosition) { SearchMatch nearestMatch = matches[0]; Int32 currentPosition = sci.MBSafeCharPosition(sci.CurrentPos); if (fixedPosition) { currentPosition -= sci.MBSafeTextLength(sci.SelText); } for (Int32 i = 0; i < matches.Count; i++) { if (forward) { if (currentPosition > matches[matches.Count - 1].Index) { return(matches[0]); } if (matches[i].Index >= currentPosition) { return(matches[i]); } } else { if (sci.SelText.Length > 0 && currentPosition <= matches[0].Index + matches[0].Value.Length) { return(matches[matches.Count - 1]); } if (currentPosition < matches[0].Index + matches[0].Value.Length) { return(matches[matches.Count - 1]); } if (sci.SelText.Length == 0 && currentPosition == matches[i].Index + matches[i].Value.Length) { return(matches[i]); } if (matches[i].Index > nearestMatch.Index && matches[i].Index + matches[i].Value.Length < currentPosition) { nearestMatch = matches[i]; } } } return(nearestMatch); }
/// <summary> /// Moves the cursor to the previous marker /// </summary> public static void PreviousMarker(ScintillaControl sci, Int32 marker, Int32 line) { Int32 prev = 0; Int32 count = 0; Int32 lineMask = sci.MarkerGet(line); if ((lineMask & GetMarkerMask(marker)) != 0) { prev = sci.MarkerPrevious(line - 1, GetMarkerMask(marker)); if (prev != -1) { sci.EnsureVisibleEnforcePolicy(prev); sci.GotoLineIndent(prev); } else { count = sci.LineCount; prev = sci.MarkerPrevious(count, GetMarkerMask(marker)); if (prev != -1) { sci.EnsureVisibleEnforcePolicy(prev); sci.GotoLineIndent(prev); } } } else { prev = sci.MarkerPrevious(line, GetMarkerMask(marker)); if (prev != -1) { sci.EnsureVisibleEnforcePolicy(prev); sci.GotoLineIndent(prev); } else { count = sci.LineCount; prev = sci.MarkerPrevious(count, GetMarkerMask(marker)); if (prev != -1) { sci.EnsureVisibleEnforcePolicy(prev); sci.GotoLineIndent(prev); } } } }
private bool FindAndHighlight(bool dirn) { TextView view = mManager.ActiveView as TextView; if (view == null || comboBoxFindWhat.Text == "") { return(false); } ScintillaControl editControl = view.ScintillaControl; UpdateFindHistory(); mManager.SetStatusMessage(String.Format("Find '{0}'", comboBoxFindWhat.Text), 10.0f); bool found = FindAndHighlight(dirn, 0, editControl.Length); if (!found) { int savedPos = editControl.CurrentPos; editControl.CurrentPos = editControl.SelectionStart = editControl.SelectionEnd = dirn ? 0 : (editControl.Length - 1); found = FindAndHighlight(dirn, 0, editControl.Length); if (!found) { editControl.CurrentPos = editControl.SelectionStart = editControl.SelectionEnd = savedPos; SystemSounds.Exclamation.Play(); mManager.SetStatusMessage(String.Format("Not found '{0}'", comboBoxFindWhat.Text), 10.0f); } else { mManager.SetStatusMessage("Search wrapped at end of document", 10.0f); } } return(found); }
private void FlexShell_SyntaxError(string error) { if (!IsFileValid) { return; } Match m = re_syntaxError.Match(error); if (!m.Success) { return; } ITabbedDocument document = PluginBase.MainForm.CurrentDocument; if (document == null || !document.IsEditable) { return; } ScintillaControl sci = document.SplitSci1; ScintillaControl sci2 = document.SplitSci2; if (m.Groups["filename"].Value != CurrentFile) { return; } try { int line = int.Parse(m.Groups["line"].Value) - 1; if (sci.LineCount < line) { return; } int start = MBSafeColumn(sci, line, int.Parse(m.Groups["col"].Value) - 1); if (line == sci.LineCount && start == 0 && line > 0) { start = -1; } AddSquiggles(sci, line, start, start + 1); AddSquiggles(sci2, line, start, start + 1); } catch { } }
protected virtual void Dispose(bool disposing) { if (!disposed) { if (disposing) { documents.Remove(this); if (command != null) { command.Dispose(); } if (tooltip != null) { tooltip.Dispose(); } if (document != null) { ((Form)document).FormClosed -= Document_FormClosed; } if (sci != null) { sci.DwellStart -= Sci_DwellStart; sci.DwellEnd -= Sci_DwellEnd; } if (contextMenu != null) { contextMenu.Opening -= ContextMenu_Opening; showOnFileHistoryMenuItem.Click -= ShowOnFileHistoryMenuItem_Click; } } command = null; fileName = null; document = null; sci = null; annotations = null; commits = null; tooltip = null; contextMenu = null; showOnFileHistoryMenuItem = null; disposed = true; } }
private void Manager_OnMouseHover(ScintillaControl sci, Int32 position) { DebuggerManager debugManager = PluginMain.debugManager; FlashInterface flashInterface = debugManager.FlashInterface; if (!PluginBase.MainForm.EditorMenu.Visible && flashInterface != null && flashInterface.isDebuggerStarted && flashInterface.isDebuggerSuspended) { if (debugManager.CurrentLocation != null && debugManager.CurrentLocation.getFile() != null) { String localPath = debugManager.GetLocalPath(debugManager.CurrentLocation.getFile()); if (localPath == null || localPath != PluginBase.MainForm.CurrentDocument.FileName) { return; } } else { return; } Point dataTipPoint = Control.MousePosition; Rectangle rect = new Rectangle(m_ToolTip.Location, m_ToolTip.Size); if (m_ToolTip.Visible && rect.Contains(dataTipPoint)) { return; } position = sci.WordEndPosition(position, true); String leftword = GetWordAtPosition(sci, position); if (leftword != String.Empty) { try { IASTBuilder b = new ASTBuilder(false); ValueExp exp = b.parse(new java.io.StringReader(leftword)); var ctx = new ExpressionContext(flashInterface.Session, flashInterface.GetFrames()[debugManager.CurrentFrame]); var obj = exp.evaluate(ctx); if ((Variable)obj != null) { Show(dataTipPoint, (Variable)obj, leftword); } } catch (Exception) {} } } }
internal static string Common(ScintillaControl sci, string sourceText, DocumentationGeneratorJobType job, bool hasGenerator) { SetSrc(sci, sourceText); var options = new List <ICompletionListItem>(); ASContext.Context.DocumentationGenerator.ContextualGenerator(sci, sci.CurrentPos, options); var item = options.Find(it => it is DocumentationGenerator.GeneratorItem && ((DocumentationGenerator.GeneratorItem)it).Job == job); if (hasGenerator) { Assert.NotNull(item); var value = item.Value; } else { Assert.IsNull(item); } return(sci.Text); }
/// <summary> /// 初期設定 /// </summary> /// <param name="scintilla"></param> public void Init(ScintillaControl scintilla) { if (scintilla == null || scintilla.ConfigurationLanguage != "kag") { return; } Debug.WriteLine("KagStyleLexer#Init codePage=" + scintilla.CodePage.ToString()); m_isFirstStyleSetting = true; //KAG用エディタに設定を上書き scintilla.Lexer = 0; scintilla.StyleNeeded -= scintilla_StyleNeeded; scintilla.StyleNeeded += new StyleNeededHandler(scintilla_StyleNeeded); scintilla.WrapStartIndent = 0; //折り返しインデントは強制的にOFFとする initStyleSetting(scintilla); preStartStyle(scintilla); }
private String GetWordAtPosition(ScintillaControl sci, Int32 position) { if (position < 0) { return(null); } string characterClass = ScintillaControl.Configuration.GetLanguage(sci.ConfigurationLanguage).characterclass.Characters; int line = sci.LineFromPosition(position); int seek = sci.MBSafeCharPosition(position) - sci.MBSafeCharPosition(sci.PositionFromLine(line)); string text = sci.GetLine(line); if (seek < 0 || seek >= text.Length) { return(null); } if (!IsIdentifierChar(characterClass, text[seek]) && text[seek] != '.') { return(null); } // Search from the seek point to the left until we hit a non-alphanumeric which isn't a "." // "." must be handled specially so that expressions like player.health are easy to evaluate. int start = seek; while (start > 0 && (IsIdentifierChar(characterClass, text[start - 1]) || text[start - 1] == '.')) { --start; } // Search from the seek point to the right until we hit a non-alphanumeric int end = seek; while (end + 1 < text.Length && IsIdentifierChar(characterClass, text[end + 1])) { ++end; } return(text.Substring(start, end - start + 1)); }
public ScriptDocument NewDocument() { UITabPage page = new UITabPage("untitled.boo*"); ScintillaControl editor = new ScintillaControl(); editor.SmartIndentingEnabled = true; editor.Configuration = config; editor.ConfigurationLanguage = "cpp"; editor.Dock = DockStyle.Fill; ScriptDocument doc = new ScriptDocument(editor); openScripts.Add(doc); page.Controls.Add(editor); uiTab1.TabPages.Add(page); return(doc); }
/// <summary> /// When user stop mouse movement parse again this file /// </summary> private void SciControlDwellStart(ScintillaControl sci, int position) { if (!this.isEnabled) { return; } try { if (this.filesCache.ContainsKey(sci.FileName)) { this.filesCache.Remove(sci.FileName); } this.ParseFile(sci.Text, sci.FileName); } catch (Exception ex) { ErrorManager.ShowError(ex); } }
static public void ReplaceText(ScintillaControl sci, string tail) { if (InfoTip.CallTipActive) { InfoTip.Hide(); return; } if (completionList.SelectedIndex >= 0) { ICompletionListItem item = (ICompletionListItem)completionList.Items[completionList.SelectedIndex]; sci.SetSel(startPos, sci.CurrentPos); string replace = item.Value; if (replace != null) { sci.ReplaceSel(replace + tail); } } Hide(); }
public RunSourceForm_v3() { //this.FormWidth = 1060; //this.FormHeight = 650; this.ClientSize = new Size(1060, 650); CreateMenu(); CreateTopTools(); _source = ScintillaControl.Create(dockStyle: DockStyle.Fill); _editPanel.Controls.Add(_source); _source.SetFont("Consolas", 10); _source.ConfigureLexerCpp(); _source.SetTabIndent(2, 0, false); _source.DisplayLineNumber(4); //_source.SelectionChanged += _source_SelectionChanged; _source.UpdateUI += _source_UpdateUI; Panel panel = AddResultPanel("result 1"); _gridResult1 = XtraGridControl.Create(dockStyle: DockStyle.Fill); panel.Controls.Add(_gridResult1); panel = AddResultPanel("result 2"); _gridResult2 = DataGridViewControl.Create(dockStyle: DockStyle.Fill); panel.Controls.Add(_gridResult2); panel = AddResultPanel("result 3"); _gridResult3 = zForm.CreateDataGrid(dockStyle: DockStyle.Fill); panel.Controls.Add(_gridResult3); panel = AddResultPanel("result 4"); _treeResult = new TreeView(); _treeResult.Dock = DockStyle.Fill; panel.Controls.Add(_treeResult); panel = AddResultPanel("message"); _logTextBox = LogTextBox.Create(dockStyle: DockStyle.Fill); panel.Controls.Add(_logTextBox); //ActiveResultPanel(4); SelectResultTab(4); this.BaseInitialize(); this.Load += RunSourceForm_v3_Load; }
/// <summary> /// Parse again the current file occasionally /// </summary> private void RefreshCurrentFile(ScintillaControl sci) { if (!this.isEnabled) { return; } try { if (this.filesCache.ContainsKey(sci.FileName)) { this.filesCache.Remove(sci.FileName); } this.ParseFile(sci.Text, sci.FileName); } catch (Exception ex) { ErrorManager.ShowError(ex); } }
/// <summary> /// /// </summary> static public bool ReplaceText(ScintillaControl sci, String tail, char trigger) { String triggers = PluginBase.Settings.InsertionTriggers ?? ""; if (triggers.Length > 0 && Regex.Unescape(triggers).IndexOf(trigger) < 0) { return(false); } ICompletionListItem item = null; if (completionList.SelectedIndex >= 0) { item = completionList.Items[completionList.SelectedIndex] as ICompletionListItem; } Hide(); if (item != null) { String replace = item.Value; if (replace != null) { sci.SetSel(startPos, sci.CurrentPos); if (word != null && tail.Length > 0) { if (replace.StartsWith(word, StringComparison.OrdinalIgnoreCase) && replace.IndexOf(tail) >= word.Length) { replace = replace.Substring(0, replace.IndexOf(tail)); } } sci.ReplaceSel(replace); if (OnInsert != null) { OnInsert(sci, startPos, replace, trigger, item); } if (tail.Length > 0) { sci.ReplaceSel(tail); } } return(true); } return(false); }
/// <summary> /// Move the document position /// </summary> private void MoveToPosition(ScintillaControl sci, Int32 position) { try { position = sci.MBSafePosition(position); // scintilla indexes are in 8bits Int32 line = sci.LineFromPosition(position); sci.EnsureVisible(line); sci.GotoPos(position); sci.SetSel(position, sci.LineEndPosition(line)); sci.Focus(); } catch { String message = TextHelper.GetString("Info.InvalidItem"); ErrorManager.ShowInfo(message); this.RemoveInvalidItems(); this.RefreshProject(); } }
/// <summary> /// Loads the custom shorcuts from a file /// </summary> public static void LoadCustomShortcuts() { ScintillaControl.InitShortcuts(); String file = FileNameHelper.ShortcutData; if (File.Exists(file)) { List <Argument> shortcuts = new List <Argument>(); shortcuts = (List <Argument>)ObjectSerializer.Deserialize(file, shortcuts, false); foreach (Argument arg in shortcuts) { ShortcutItem item = GetRegisteredItem(arg.Key); if (item != null) { item.Custom = (Keys)Enum.Parse(typeof(Keys), arg.Value); } } } }
/** * Replaces all results specified by user input */ public void ReplaceAllButtonClick(object sender, System.EventArgs e) { try { ScintillaControl sci = this.mainForm.CurSciControl; int pointX = sci.PointXFromPosition(sci.CurrentPos); int pointY = sci.PointYFromPosition(sci.CurrentPos); sci.Text = Regex.Replace(sci.Text, this.GetFindText(), this.GetReplaceText()); this.ShowMessage("Replace all was completed successfully.", 0); int position = sci.PositionFromPoint(pointX, pointY); string replaceText = this.GetReplaceText(); this.AddToReplaceItems(replaceText); sci.SetSel(position, position); } catch { this.ShowMessage("Error while running replace all.", 2); } }
private void OnMouseHover(ScintillaControl sci, int position) { if (!ASContext.Context.IsFileValid) { return; } lastHoverPosition = position; // get word at mouse position int style = sci.BaseStyleAt(position); if (!ASComplete.IsTextStyle(style)) { return; } position = sci.WordEndPosition(position, true); ASResult result = ASComplete.GetExpressionType(sci, position); // set tooltip if (!result.IsNull()) { if (Control.ModifierKeys == Keys.Control) { var code = ASComplete.GetCodeTipCode(result); if (code == null) { return; } UITools.CodeTip.Show(sci, position - result.Path.Length, code); } else { string text = ASComplete.GetToolTipText(result); if (text == null) { return; } // show tooltip UITools.Tip.ShowAtMouseLocation(text); } } }
void Manager_OnMarkerChanged(ScintillaControl sender, int line) { if (sender == syncMaster.SciControl) { int isMark = syncMaster.SciControl.MarkerGet(line); foreach (ITabbedDocument syncChild in syncChildren) { if (isMark == 1) { syncChild.SciControl.MarkerAdd(line, 0); } else if (isMark == 0) { syncChild.SciControl.MarkerDelete(line, 0); } } } }
void CompletionList_OnInsert(ScintillaControl sender, int position, string text, char trigger, ICompletionListItem item) { if (item.Description == "File") { this.FinishFileCompletion(sender, null); } else if (item.Description == "Current Document") { FileInfo fi = new FileInfo(PluginBase.MainForm.CurrentDocument.FileName); if (!fi.Exists) { this.FinishFileCompletion(sender, null); } else { this.currentFolder = fi.Directory; } } }
/// <summary> /// Finds the next result based on direction /// </summary> public void FindNext(Boolean forward, Boolean update, Boolean simple) { this.currentMatch = null; if (update) { this.UpdateFindText(); } if (Globals.SciControl == null) { return; } ScintillaControl sci = Globals.SciControl; List <SearchMatch> matches = this.GetResults(sci, simple); if (matches != null && matches.Count != 0) { FRDialogGenerics.UpdateComboBoxItems(this.findComboBox); SearchMatch match = FRDialogGenerics.GetNextDocumentMatch(sci, matches, forward, false); if (match != null) { this.currentMatch = match; FRDialogGenerics.SelectMatch(sci, match); this.lookupIsDirty = false; } if (this.Visible) { Int32 index = FRDialogGenerics.GetMatchIndex(match, matches); String message = TextHelper.GetString("Info.ShowingResult"); String formatted = String.Format(message, index, matches.Count); this.ShowMessage(formatted, 0); } } else { if (this.Visible) { String message = TextHelper.GetString("Info.NoMatchesFound"); this.ShowMessage(message, 0); } } this.SelectText(); }
public void Configure(ScintillaControl scintilla, string language) { scintilla.StyleClearAll(); scintilla.DisableMarginClickFold(); IScintillaConfig conf = this; ILanguageConfig lang = conf.Languages[language]; if (lang != null) { lang = lang.CombinedLanguageConfig; if (lang.CodePage.HasValue) scintilla.CodePage = lang.CodePage.Value; if (lang.SelectionAlpha.HasValue) scintilla.SelectionAlpha = lang.SelectionAlpha.Value; if (lang.SelectionBackColor != Color.Empty) scintilla.SetSelectionBackground(true, lang.SelectionBackColor); if (lang.TabSize.HasValue) scintilla.TabWidth = lang.TabSize.Value; if (lang.IndentSize.HasValue) scintilla.Indent = lang.IndentSize.Value; // Enable line numbers scintilla.MarginWidthN(0, 40); bool enableFolding = false; if (lang.Fold.HasValue) enableFolding = lang.Fold.Value; if (enableFolding) { // Lexer specific properties scintilla.Property("fold", "1"); if (lang.FoldAtElse.HasValue) scintilla.Property("fold.at.else", (lang.FoldAtElse.Value ? "1" : "0")); if (lang.FoldCompact.HasValue) scintilla.Property("fold.compact", (lang.FoldCompact.Value ? "1" : "0")); if (lang.FoldComment.HasValue) scintilla.Property("fold.comment", (lang.FoldComment.Value ? "1" : "0")); if (lang.FoldPreprocessor.HasValue) scintilla.Property("fold.preprocessor", (lang.FoldPreprocessor.Value ? "1" : "0")); if (lang.StylingWithinPreprocessor.HasValue) scintilla.Property("styling.within.preprocessor", (lang.PythonFoldQuotes.Value ? "1" : "0")); if (lang.HtmlFold.HasValue) scintilla.Property("fold.html", (lang.HtmlFold.Value ? "1" : "0")); if (lang.HtmlFoldPreprocessor.HasValue) scintilla.Property("fold.html.preprocessor", (lang.HtmlFoldPreprocessor.Value ? "1" : "0")); if (lang.HtmlTagsCaseSensitive.HasValue) scintilla.Property("html.tags.case.sensitive", (lang.HtmlTagsCaseSensitive.Value ? "1" : "0")); if (lang.PythonFoldComment.HasValue) scintilla.Property("fold.comment.python", (lang.PythonFoldComment.Value ? "1" : "0")); if (lang.PythonFoldQuotes.HasValue) scintilla.Property("fold.quotes.python", (lang.PythonFoldQuotes.Value ? "1" : "0")); if (lang.PythonWhingeLevel.HasValue) scintilla.Property("tab.timmy.whinge.level", lang.PythonWhingeLevel.Value.ToString()); if (lang.SqlBackslashEscapes.HasValue) scintilla.Property("sql.backslash.escapes", (lang.SqlBackslashEscapes.Value ? "1" : "0")); if (lang.SqlBackticksIdentifier.HasValue) scintilla.Property("lexer.sql.backticks.identifier", (lang.SqlBackticksIdentifier.Value ? "1" : "0")); if (lang.SqlFoldOnlyBegin.HasValue) scintilla.Property("fold.sql.only.begin", (lang.SqlFoldOnlyBegin.Value ? "1" : "0")); if (lang.PerlFoldPod.HasValue) scintilla.Property("fold.perl.pod", (lang.PerlFoldPod.Value ? "1" : "0")); if (lang.PerlFoldPackage.HasValue) scintilla.Property("fold.perl.package", (lang.PerlFoldPackage.Value ? "1" : "0")); if (lang.NsisIgnoreCase.HasValue) scintilla.Property("nsis.ignorecase", (lang.NsisIgnoreCase.Value ? "1" : "0")); if (lang.NsisUserVars.HasValue) scintilla.Property("nsis.uservars", (lang.NsisUserVars.Value ? "1" : "0")); if (lang.NsisFoldUtilCommand.HasValue) scintilla.Property("nsis.foldutilcmd", (lang.NsisFoldUtilCommand.Value ? "1" : "0")); if (lang.CppAllowDollars.HasValue) scintilla.Property("lexer.cpp.allow.dollars", (lang.CppAllowDollars.Value ? "1" : "0")); //for HTML lexer: "asp.default.language" //enum script_type { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML, eScriptSGML, eScriptSGMLblock }; scintilla.MarginWidthN(1, 0); scintilla.MarginTypeN(1, MarginType.Symbol); scintilla.MarginMaskN(1, unchecked((int)0xFE000000)); scintilla.MarginSensitiveN(1, true); if (lang.FoldMarginWidth.HasValue) scintilla.MarginWidthN(1, lang.FoldMarginWidth.Value); else scintilla.MarginWidthN(1, 20); if (lang.FoldMarginColor != Color.Empty) scintilla.SetFoldMarginColor(true, lang.FoldMarginColor); if (lang.FoldMarginHighlightColor != Color.Empty) scintilla.SetFoldMarginHiColor(true, lang.FoldMarginHighlightColor); if (lang.FoldFlags.HasValue) scintilla.SetFoldFlags(lang.FoldFlags.Value); scintilla.MarkerDefine(MarkerOutline.Folder, MarkerSymbol.Plus); scintilla.MarkerDefine(MarkerOutline.FolderOpen, MarkerSymbol.Minus); scintilla.MarkerDefine(MarkerOutline.FolderEnd, MarkerSymbol.Empty); scintilla.MarkerDefine(MarkerOutline.FolderMidTail, MarkerSymbol.Empty); scintilla.MarkerDefine(MarkerOutline.FolderOpenMid, MarkerSymbol.Minus); scintilla.MarkerDefine(MarkerOutline.FolderSub, MarkerSymbol.Empty); scintilla.MarkerDefine(MarkerOutline.FolderTail, MarkerSymbol.Empty); scintilla.EnableMarginClickFold(); } if (!string.IsNullOrEmpty(lang.WhitespaceCharacters)) scintilla.WhitespaceChars(lang.WhitespaceCharacters); if (!string.IsNullOrEmpty(lang.WordCharacters)) scintilla.WordChars(lang.WordCharacters); ILexerConfig lexer = lang.Lexer; if (lexer != null) { scintilla.Lexer = lexer.LexerID; //scintilla.LexerLanguage(lang.Name); } SortedDictionary<int, ILexerStyle> styles = lang.Styles; foreach (ILexerStyle style in styles.Values) { if (style.ForeColor != Color.Empty) scintilla.StyleSetFore(style.StyleIndex, style.ForeColor); if (style.BackColor != Color.Empty) scintilla.StyleSetBack(style.StyleIndex, style.BackColor); if (!string.IsNullOrEmpty(style.FontName)) scintilla.StyleSetFont(style.StyleIndex, style.FontName); if (style.FontSize.HasValue) scintilla.StyleSetSize(style.StyleIndex, style.FontSize.Value); if (style.Bold.HasValue) scintilla.StyleSetBold(style.StyleIndex, style.Bold.Value); if (style.Italics.HasValue) scintilla.StyleSetItalic(style.StyleIndex, style.Italics.Value); if (style.EOLFilled.HasValue) scintilla.StyleSetEOLFilled(style.StyleIndex, style.EOLFilled.Value); scintilla.StyleSetCase(style.StyleIndex, style.CaseVisibility); } scintilla.StyleBits = scintilla.StyleBitsNeeded; for (int j = 0; j < 9; j++) { if (lang.KeywordLists.ContainsKey(j)) scintilla.KeyWords(j, lang.KeywordLists[j]); else scintilla.KeyWords(j, string.Empty); } } scintilla.Colorize(0, scintilla.Length); }
public ScintillaPrintDocument(ScintillaControl sci, string documentTitle) { this.sci = sci; DocumentName = documentTitle; DefaultPageSettings = new ScintillaPageSettings(); }
private String GetWordAtPosition(ScintillaControl sci, Int32 position) { Char c; System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (Int32 startPosition = position - 1; startPosition >= 0; startPosition--) { c = (Char)sci.CharAt(startPosition); if (!(Char.IsLetterOrDigit(c) || c == '_' || c == '$' || c == '.')) { break; } sb.Insert(0, c); } return sb.ToString(); }
private void Manager_OnMouseHover(ScintillaControl sci, Int32 position) { DebuggerManager debugManager = PluginMain.debugManager; FlashInterface flashInterface = debugManager.FlashInterface; if (!PluginBase.MainForm.EditorMenu.Visible && flashInterface != null && flashInterface.isDebuggerStarted && flashInterface.isDebuggerSuspended) { if (debugManager.CurrentLocation != null && debugManager.CurrentLocation.getFile() != null) { String localPath = debugManager.GetLocalPath(debugManager.CurrentLocation.getFile()); if (localPath == null || localPath != PluginBase.MainForm.CurrentDocument.FileName) { return; } } else return; Point dataTipPoint = Control.MousePosition; Rectangle rect = new Rectangle(m_ToolTip.Location, m_ToolTip.Size); if (m_ToolTip.Visible && rect.Contains(dataTipPoint)) { return; } position = sci.WordEndPosition(position, true); String leftword = GetWordAtPosition(sci, position); if (leftword != String.Empty) { try { IASTBuilder b = new ASTBuilder(false); ValueExp exp = b.parse(new java.io.StringReader(leftword)); var ctx = new ExpressionContext(flashInterface.Session, flashInterface.GetFrames()[debugManager.CurrentFrame]); var obj = exp.evaluate(ctx); if ((Variable)obj != null) { Show(dataTipPoint, (Variable)obj, leftword); } } catch (Exception){} } } }
private String GetWordAtPosition(ScintillaControl sci, Int32 position) { int insideBrackets = 0; Char c; StringBuilder sb = new StringBuilder(); for (Int32 startPosition = position - 1; startPosition >= 0; startPosition--) { c = (Char)sci.CharAt(startPosition); if (c == ')') { insideBrackets++; } else if (c == '(' && insideBrackets > 0) { insideBrackets--; } else if (!(Char.IsLetterOrDigit(c) || c == '_' || c == '$' || c == '.') && insideBrackets == 0) { break; } sb.Insert(0, c); } return sb.ToString(); }
/// <summary> /// Default Constructor /// </summary> /// <param name="oScintillaControl">Scintilla control being printed</param> public PrintDocument(ScintillaControl oScintillaControl) { m_oScintillaControl = oScintillaControl; }