/// <summary> /// Checks if a file has been changed outside /// </summary> private static void CheckFileChange(ITabbedDocument document) { TabbedDocument casted = document as TabbedDocument; if (casted.IsEditable && casted.CheckFileChange()) { if (Globals.Settings.AutoReloadModifiedFiles) { casted.RefreshFileInfo(); casted.Reload(false); } else { if (YesToAll) { casted.RefreshFileInfo(); casted.Reload(false); return; } String dlgTitle = TextHelper.GetString("Title.InfoDialog"); String dlgMessage = TextHelper.GetString("Info.FileIsModifiedOutside"); String formatted = String.Format(dlgMessage, "\n", casted.FileName); MessageBoxManager.Cancel = TextHelper.GetString("Label.YesToAll"); MessageBoxManager.Register(); // Use custom labels... DialogResult result = MessageBox.Show(Globals.MainForm, formatted, " " + dlgTitle, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information); casted.RefreshFileInfo(); // User may have waited before responding, save info now if (result == DialogResult.Yes) casted.Reload(false); else if (result == DialogResult.Cancel) { casted.Reload(false); YesToAll = true; } MessageBoxManager.Unregister(); } } }
/// <summary> /// Processes the specified document /// </summary> private void DoProcess(ITabbedDocument document) { switch (this.operationComboBox.SelectedIndex) { case 0: // Format Code { DataEvent de = new DataEvent(EventType.Command, "CodeFormatter.FormatDocument", document); EventManager.DispatchEvent(this, de); break; } case 1: // Organize Imports { OrganizeImports command = new OrganizeImports(); command.SciControl = document.SciControl; command.Execute(); break; } case 2: // Truncate Imports { OrganizeImports command = new OrganizeImports(); command.SciControl = document.SciControl; command.TruncateImports = true; command.Execute(); break; } case 3: // Consistent EOLs { document.SciControl.ConvertEOLs(document.SciControl.EOLMode); break; } } }
public void FixtureTearDown() { settings = null; doc = null; mainForm.Dispose(); mainForm = null; }
/// <summary> /// Create a new ListViewGroup and assign to the current listview /// </summary> /// <param name="doc"></param> public void CreateDocument( ITabbedDocument doc ) { ListViewGroup group = new ListViewGroup(); Hashtable table = new Hashtable(); table["FileName"] = doc.FileName; table["Document"] = doc; table["Markers"] = new List<int>(); table["Parsed"] = false; group.Header = Path.GetFileName(doc.FileName); group.Tag = table; group.Name = doc.FileName; this.listView1.BeginUpdate(); this.listView1.Groups.Add(group); this.listView1.EndUpdate(); TagTimer timer = new TagTimer(); timer.AutoReset = true; timer.SynchronizingObject = this; timer.Interval = 200; timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); timer.Tag = group; timer.Start(); }
public MiniMapPanel(ITabbedDocument document, ScintillaControl sci, Settings settings) { this.Document = document; this.ScintillaControl = sci; this.Settings = settings; InitializeControl(); RefreshSettings(); HookEvents(); }
static public void HideBar(ITabbedDocument target) { foreach (Control ctrl in target.Controls) { if (ctrl is MessageBar) { (ctrl as MessageBar).MessageBarClick(null, null); return; } } }
/// <summary> /// Sets an index of the current document /// </summary> public static void UpdateSequentialIndex(ITabbedDocument document) { Int32 count = Globals.MainForm.Documents.Length; for (Int32 i = 0; i < count; i++) { if (document == Globals.MainForm.Documents[i]) { SequentialIndex = i; return; } } }
/// <summary> /// Gets the active encoding name from the current codepage /// </summary> public static String GetActiveEncodingName() { ITabbedDocument document = Globals.CurrentDocument; if (document != null && document.IsEditable) { Int32 codepage = document.SciControl.Encoding.CodePage; EncodingFileInfo info = FileHelper.GetEncodingFileInfo(document.FileName); if (codepage == info.CodePage) { if (ScintillaManager.IsUnicode(info.CodePage)) { String name = "Unicode (" + info.Charset + ")"; return(info.ContainsBOM ? name + " (BOM)" : name); } else { String name = TextHelper.GetStringWithoutMnemonics("Label.8Bits"); return(name + " (" + info.Charset + ")"); } } else // Opened in different encoding... { Boolean hasBOM = document.SciControl.SaveBOM; if (codepage == Encoding.UTF8.CodePage) { return(GetLabelAsPlainText("Label.UTF8", true, hasBOM)); } else if (codepage == Encoding.UTF7.CodePage) { return(GetLabelAsPlainText("Label.UTF7", true, hasBOM)); } else if (codepage == Encoding.BigEndianUnicode.CodePage) { return(GetLabelAsPlainText("Label.BigEndian", true, hasBOM)); } else if (codepage == Encoding.Unicode.CodePage) { return(GetLabelAsPlainText("Label.LittleEndian", true, hasBOM)); } else { return(GetLabelAsPlainText("Label.8Bits", false, false)); } } } else { return(TextHelper.GetString("Info.Unknown")); } }
public void CloneCurrentDocument() { if (documentList == null) { setup(); } ITabbedDocument currentDocument = Globals.CurrentDocument; if (!documentList.Contains(currentDocument)) { register(currentDocument); } DockContent clonedDocument = Globals.MainForm.CreateEditableDocument(currentDocument.SciControl.FileName, currentDocument.SciControl.Text, currentDocument.SciControl.CodePage); ITabbedDocument clonedoc = (TabbedDocument)clonedDocument; register(clonedoc); for (int i = 0; i < currentDocument.SciControl.LineCount; i++) { if (currentDocument.SciControl.MarkerGet(i) == 1) { clonedoc.SciControl.MarkerAdd(i, 0); } //currentDocument //currentDocument.SciControl.FoldParent(i + 1); Int32 foldParentLine = currentDocument.SciControl.FoldParent(i + 1); if (foldParentLine == i) { Boolean isExpanded = currentDocument.SciControl.FoldExpanded(foldParentLine); if (!isExpanded) { clonedoc.SciControl.ToggleFold(i); } } } clonedoc.IsModified = currentDocument.IsModified; clonedoc.SciControl.SelectionMode = currentDocument.SciControl.SelectionMode; clonedoc.SciControl.SelectionStart = currentDocument.SciControl.SelectionStart; clonedoc.SciControl.SelectionEnd = currentDocument.SciControl.SelectionEnd; clonedDocument.DockTo(((DockContent)currentDocument).Pane, settingObject.DockStyle, 0); DockPanel_ActiveDocumentChanged(); syncMaster.Activate(); }
/// <summary> /// Gets if the language is valid for refactoring /// </summary> private Boolean GetLanguageIsValid() { ITabbedDocument document = PluginBase.MainForm.CurrentDocument; if (document != null && document.IsEditable) { String lang = document.SciControl.ConfigurationLanguage; return(lang == "as2" || lang == "as3" || lang == "haxe" || lang == "loom"); // TODO look for /Snippets/Generators } else { return(false); } }
/// <summary> /// Finds the document by the ScintillaControl /// </summary> public static ITabbedDocument FindDocument(ScintillaControl sci) { Int32 count = PluginBase.MainForm.Documents.Length; for (Int32 i = 0; i < count; i++) { ITabbedDocument current = PluginBase.MainForm.Documents[i]; if (current.IsEditable && current.SciControl == sci) { return(current); } } return(null); }
/// <summary> /// Gets if the language is valid for refactoring /// </summary> private Boolean GetLanguageIsValid() { ITabbedDocument document = PluginBase.MainForm.CurrentDocument; if (document != null && document.IsEditable) { String extension = document.FileName.ToLower(); return(extension.EndsWith(".as") || extension.EndsWith(".hx")); } else { return(false); } }
/// <summary> /// Finds the document by the file name /// </summary> public static ITabbedDocument FindDocument(String filename) { Int32 count = PluginBase.MainForm.Documents.Length; for (Int32 i = 0; i < count; i++) { ITabbedDocument current = PluginBase.MainForm.Documents[i]; if (current.FileName == filename) { return(current); } } return(null); }
/// <summary> /// /// </summary> static private void CLDoubleClick(Object sender, System.EventArgs e) { ITabbedDocument doc = PluginBase.MainForm.CurrentDocument; if (!doc.IsEditable) { Hide(); return; } ScintillaControl sci = doc.SciControl; sci.Focus(); ReplaceText(sci, '\0'); }
public static void Execute() { if (Globals.SciControl == null) { return; } ScintillaControl sci = Globals.SciControl; //Project project = (Project) PluginBase.CurrentProject; //if (project == null) return; MainForm mainForm = (MainForm)Globals.MainForm; ITabbedDocument document = mainForm.CurrentDocument; String dir = Path.GetDirectoryName(document.FileName); Hashtable details = ASComplete.ResolveElement(sci, null); IASContext context = ASContext.Context; ClassModel cClass = context.CurrentClass; string package = context.CurrentModel.Package; sci.BeginUndoAction(); if (sci.SelText == "") { sci.SelectionStart = sci.PositionFromLine(cClass.LineFrom); sci.SelectionEnd = sci.PositionFromLine(cClass.LineTo + 1); } String content = Regex.Replace( sci.SelText, @"^", "\t", RegexOptions.Multiline); String contents = "package " + package + " {\n" + content + "\n}"; TraceManager.Add(contents); //TraceManager.Add(cClass.LineTo.ToString()); Encoding encoding = sci.Encoding; String file = dir + "\\" + cClass.Name + ".as"; FileHelper.WriteFile(file, contents, encoding); sci.Clear(); sci.EndUndoAction(); }
/// <summary> /// Gets if the language is valid for debugging /// </summary> private Boolean GetLanguageIsValid() { ITabbedDocument document = PluginBase.MainForm.CurrentDocument; if (document != null && document.IsEditable) { String ext = Path.GetExtension(document.FileName); String lang = document.SciControl.ConfigurationLanguage; return(lang == "as3" || lang == "haxe" || ext == ".mxml"); } else { return(false); } }
/// <summary> /// /// </summary> static public void SelectWordInList(String tail) { ITabbedDocument doc = PluginBase.MainForm.CurrentDocument; if (!doc.IsEditable) { Hide(); return; } ScintillaControl sci = doc.SciControl; currentWord = tail; currentPos += tail.Length; sci.SetSel(currentPos, currentPos); }
/// <summary> /// Double click on an item in the list view /// </summary> private void ListViewDoubleClick(Object sender, EventArgs e) { if (this.listView.SelectedItems.Count > 0) { ListViewItem item = this.listView.SelectedItems[0]; String filename = item.Group.Name; Int32 line = (Int32)item.Tag; ITabbedDocument document = DocumentManager.FindDocument(filename); if (document != null && document.IsEditable) { document.Activate(); document.SciControl.GotoLineIndent(line); } } }
private AnnotatedDocument(IBlameCommand cmd, string file, ITabbedDocument doc) { documents.Add(this); command = cmd; fileName = file; document = doc; sci = document.SciControl; annotations = null; commits = new Dictionary <string, AnnotationData>(); tooltip = new ToolTip(); contextMenu = new ContextMenuStrip(); InitializeContextMenu(); AddEventHandlers(); }
/// <summary> /// /// </summary> static public void SciControl_MarkerChanged(ScintillaControl sender, Int32 line) { if (line < 0) { return; } ITabbedDocument document = DocumentManager.FindDocument(sender); if (document == null || !document.IsEditable) { return; } ApplyHighlights(document.SplitSci1, line); ApplyHighlights(document.SplitSci2, line); }
/// <summary> /// Generate surround main menu and context menu items /// </summary> private void GenerateSurroundMenuItems() { ITabbedDocument document = PluginBase.MainForm.CurrentDocument; if (document != null && document.IsEditable && RefactoringHelper.GetLanguageIsValid()) { this.surroundContextMenu.GenerateSnippets(document.SciControl); this.refactorMainMenu.SurroundMenu.GenerateSnippets(document.SciControl); } else { this.surroundContextMenu.Clear(); this.refactorMainMenu.SurroundMenu.Clear(); } }
protected override Boolean ProcessDialogKey(Keys keyData) { if (this.AutoKeyHandling && this.ContainsFocus) { if (keyData == Keys.Escape) { ITabbedDocument doc = PluginBase.MainForm.CurrentDocument; if (doc != null && doc.IsEditable) { doc.SciControl.Focus(); return(true); } } } return(base.ProcessDialogKey(keyData)); }
/// <summary> /// Cancel completion list with event /// </summary> static public void Hide(char trigger) { if (completionList != null && isActive) { Hide(); if (OnCancel != null) { ITabbedDocument doc = PluginBase.MainForm.CurrentDocument; if (!doc.IsEditable) { return; } OnCancel(doc.SciControl, currentPos, currentWord, trigger, null); } } }
public void FixtureSetUp() { mainForm = new MainForm(); settings = Substitute.For <ISettings>(); settings.UseTabs = true; settings.IndentSize = 4; settings.SmartIndentType = SmartIndent.CPP; settings.TabIndents = true; settings.TabWidth = 4; doc = Substitute.For <ITabbedDocument>(); mainForm.Settings = settings; mainForm.CurrentDocument = doc; mainForm.StandaloneMode = false; PluginBase.Initialize(mainForm); FlashDevelop.Managers.ScintillaManager.LoadConfiguration(); }
public void FixtureSetUp() { mainForm = new MainForm(); settings = Substitute.For<ISettings>(); settings.UseTabs = true; settings.IndentSize = 4; settings.SmartIndentType = SmartIndent.CPP; settings.TabIndents = true; settings.TabWidth = 4; doc = Substitute.For<ITabbedDocument>(); mainForm.Settings = settings; mainForm.CurrentDocument = doc; mainForm.StandaloneMode = false; PluginBase.Initialize(mainForm); FlashDevelop.Managers.ScintillaManager.LoadConfiguration(); }
/// <summary> /// Adds the document's dock state to the session /// </summary> public static void AddDocumentDock(ITabbedDocument document, Session session) { try { DockContent content = document as DockContent; double prop = content.Pane.NestedDockingStatus.Proportion; DockAlignment align = content.Pane.NestedDockingStatus.Alignment; Int32 paneIndex = content.DockPanel.Panes.IndexOf(content.Pane); Int32 nestIndex = content.DockPanel.Panes.IndexOf(content.Pane.NestedDockingStatus.PreviousPane); if (nestIndex > -1) { NestedDock dock = new NestedDock(document.FileName, nestIndex, paneIndex, align, prop); session.Nested.Add(dock); } } catch { /* No errors please... */ } }
void restoreDesigner_Tick(object sender, EventArgs e) { ITabbedDocument[] documents = FlashDevelop.Globals.MainForm.Documents; ITabbedDocument current = FlashDevelop.Globals.MainForm.CurrentDocument; Char[] splitter = new Char[] { '.' }; foreach (ITabbedDocument doc in documents) { if (doc.FileName.Split(splitter)[0] == this.lastDesignerFileName) { // We are still open this.lastDesignerFileName = ""; doc.Reload(false); } } this.restoreDesigner.Enabled = false; }
/// <summary> /// Saves the file state to a binary file /// </summary> public static void SaveFileState(ITabbedDocument document) { try { if (!document.IsEditable) return; String fileStateDir = FileNameHelper.FileStateDir; if (!Directory.Exists(fileStateDir)) Directory.CreateDirectory(fileStateDir); StateObject so = GetStateObject(document.SciControl); String fileName = ConvertToFileName(document.FileName); String stateFile = Path.Combine(fileStateDir, fileName + ".fdb"); ObjectSerializer.Serialize(stateFile, so); } catch (Exception ex) { ErrorManager.ShowError(ex); } }
public NavigationBar(ITabbedDocument document, Settings settings) { _document = document; _settings = settings; SearchHelper.Settings = settings; DropDownBuilder.Settings = settings; InitializeComponent(); Renderer = new DockPanelStripRenderer(false); BackColor = PluginBase.MainForm.GetThemeColor("ToolStripComboBoxControl.BorderColor"); RefreshSettings(); HookEvents(); updateTimer.Start(); }
/// <summary> /// Remove the group and all associated subitems /// </summary> /// <param name="doc"></param> public void CloseDocument( ITabbedDocument doc ) { doc.SciControl.DwellStart -= new ScintillaNet.DwellStartHandler(SciControl_DwellStart); this.listView1.BeginUpdate(); foreach (ListViewGroup group in this.listView1.Groups) { if (((Hashtable)group.Tag)["Document"] == doc) { this.listView1.Groups.Remove(group); foreach (ListViewItem item in group.Items) { item.Remove(); } break; } } this.listView1.EndUpdate(); }
/// <summary> /// Shows the completion list /// </summary> static public void Show(List <ICompletionListItem> itemList, Boolean autoHide, String select) { if (select.Length > 0) { ITabbedDocument doc = PluginBase.MainForm.CurrentDocument; if (!doc.IsEditable) { return; } ScintillaControl sci = doc.SciControl; currentWord = select; } else { currentWord = null; } Show(itemList, autoHide); }
/// <summary> /// Checks if a file has been changed outside /// </summary> private static void CheckFileChange(ITabbedDocument document) { TabbedDocument casted = document as TabbedDocument; if (casted.IsEditable && casted.CheckFileChange()) { if (Globals.Settings.AutoReloadModifiedFiles) casted.Reload(false); else { String dlgTitle = TextHelper.GetString("Title.InfoDialog"); String dlgMessage = TextHelper.GetString("Info.FileIsModifiedOutside"); String formatted = String.Format(dlgMessage, "\n", casted.FileName); if (MessageBox.Show(Globals.MainForm, formatted, " " + dlgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { casted.Reload(false); } } } }
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; } ScintillaNet.ScintillaControl sci = document.SplitSci1; ScintillaNet.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 { } }
/// <summary> /// /// </summary> private void ProcessButtonClick(Object sender, EventArgs e) { switch (this.targetComboBox.SelectedIndex) { case 0: // Open Files { foreach (ITabbedDocument document in PluginBase.MainForm.Documents) { if (document.IsEditable && !document.IsUntitled) { this.DoProcess(document); } } break; } case 1: // Project Sources { IProject project = PluginBase.CurrentProject; if (project != null) { List <String> files = new List <String>(); String[] filters = project.DefaultSearchFilter.Split(';'); foreach (String path in project.SourcePaths) { foreach (String filter in filters) { files.AddRange(Directory.GetFiles(project.GetAbsolutePath(path), filter, SearchOption.AllDirectories)); } } foreach (String file in files) { if (File.Exists(file)) { ITabbedDocument document = PluginBase.MainForm.OpenEditableDocument(file) as ITabbedDocument; this.DoProcess(document); } } } break; } } this.Close(); }
/// <summary> /// Handles the incoming events /// </summary> public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority) { switch (e.Type) { case EventType.SyntaxDetect: // detect Actionscript language version ITabbedDocument doc = PluginBase.MainForm.CurrentDocument; if (doc == null || !doc.IsEditable) { return; } if (doc.FileName.ToLower().EndsWith(".js")) { if (IsUnityProject(doc.FileName)) { (e as TextEvent).Value = "unityscript"; e.Handled = true; } } break; case EventType.Completion: ITabbedDocument doc2 = PluginBase.MainForm.CurrentDocument; if (doc2 == null || !doc2.IsEditable) { return; } if (doc2.FileName.ToLower().EndsWith(".js")) { if (IsUnityProject(doc2.FileName)) { e.Handled = true; } } break; case EventType.UIStarted: contextInstance = new Context(settingObject); ValidateSettings(); // Associate this context with UnityScript language ASCompletion.Context.ASContext.RegisterLanguage(contextInstance, "UnityScript"); break; } }
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 alwaysCompile(Object sender, EventArgs e) { Project project = (Project)PluginBase.CurrentProject; ITabbedDocument nowDoc = PluginBase.MainForm.CurrentDocument; string path = nowDoc.FileName; if (path.StartsWith(project.Directory)) { if (path.EndsWith(".as") || path.EndsWith(".mxml")) { project.SetCompileTarget(path, true); if (project.MaxTargetsCount > 0) { while (project.CompileTargets.Count > project.MaxTargetsCount) { string relPath = project.CompileTargets[0]; string path2 = project.GetAbsolutePath(relPath); project.SetCompileTarget(path2, false); } } project.Save(); ProjectTreeView.Instance.RefreshTree(); string str = path; if (alwaysCompileReg.IsMatch(str)) { Match match = alwaysCompileReg.Match(str); str = match.Groups["filename"].Value; } if (settingObj.AlwaysCompileAfterCompile) { PluginBase.MainForm.CallCommand("PluginCommand", ProjectManagerCommands.TestMovie); } TraceManager.Add("Always Compile: " + str, -2); } else { ErrorManager.ShowWarning(path + "は AS, MXML ファイルではありません。", null); } } else { ErrorManager.ShowWarning(path + "は、現在の Project のファイルではありません。", null); } }
/// <summary> /// Renames the found documents based on the specified path /// NOTE: Directory paths should be without the last separator /// </summary> public static void MoveDocuments(String oldPath, String newPath) { Boolean reactivate = false; oldPath = Path.GetFullPath(oldPath); newPath = Path.GetFullPath(newPath); ITabbedDocument current = PluginBase.MainForm.CurrentDocument; foreach (ITabbedDocument document in PluginBase.MainForm.Documents) { /* We need to check for virtual models, another more generic option would be * Path.GetFileName(document.FileName).IndexOfAny(Path.GetInvalidFileNameChars()) == -1 * But this one is used in more places */ if (document.IsEditable && !document.Text.StartsWith("[model] ")) { String filename = Path.GetFullPath(document.FileName); if (filename.StartsWith(oldPath)) { TextEvent ce = new TextEvent(EventType.FileClose, document.FileName); EventManager.DispatchEvent(PluginBase.MainForm, ce); document.SciControl.FileName = filename.Replace(oldPath, newPath); TextEvent oe = new TextEvent(EventType.FileOpen, document.FileName); EventManager.DispatchEvent(PluginBase.MainForm, oe); if (current != document) { document.Activate(); reactivate = true; } else { TextEvent se = new TextEvent(EventType.FileSwitch, document.FileName); EventManager.DispatchEvent(PluginBase.MainForm, se); } } PluginBase.MainForm.ClearTemporaryFiles(filename); document.RefreshTexts(); } } PluginBase.MainForm.RefreshUI(); if (reactivate) { current.Activate(); } }
/// <summary> /// Updates the file extension and the initial directory /// </summary> private void UpdateDialogArguments() { IProject project = PluginBase.CurrentProject; ITabbedDocument document = Globals.CurrentDocument; Boolean doRefresh = lastProject != null && lastProject != project; if (project != null) { String path = Path.GetDirectoryName(project.ProjectPath); if (String.IsNullOrEmpty(this.folderComboBox.Text) || doRefresh) { this.folderComboBox.Text = path; } } else if (String.IsNullOrEmpty(this.folderComboBox.Text) || doRefresh) { this.folderComboBox.Text = Globals.MainForm.WorkingDirectory; } this.folderComboBox.SelectionStart = this.folderComboBox.Text.Length; this.redirectCheckBox.CheckedChanged -= new EventHandler(this.RedirectCheckBoxCheckChanged); this.redirectCheckBox.Checked = Globals.Settings.RedirectFilesResults; this.redirectCheckBox.CheckedChanged += new EventHandler(this.RedirectCheckBoxCheckChanged); if (!this.IsValidFileMask(this.extensionComboBox.Text) || doRefresh) { if (project != null) { String filter = project.DefaultSearchFilter; this.extensionComboBox.Text = filter; } else { String def = Globals.Settings.DefaultFileExtension; this.extensionComboBox.Text = "*." + def; } } if (document.IsEditable && document.SciControl.SelText.Length > 0) { this.findComboBox.Text = document.SciControl.SelText; } if (project != null) { lastProject = project; } }
/// <summary> /// After an interval check if the files have changed /// </summary> private static void FilePollTimerTick(Object sender, EventArgs e) { try { FilePollTimer.Enabled = false; ITabbedDocument[] documents = Globals.MainForm.Documents; ITabbedDocument current = Globals.MainForm.CurrentDocument; CheckFileChange(current); // Check the current first.. foreach (ITabbedDocument document in documents) { if (document != current) { CheckFileChange(document); } } FilePollTimer.Enabled = true; } catch { /* No errors shown here.. */ } }
void dgv_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex < 0 || e.RowIndex >= dgv.Rows.Count) { return; } if (dgv.Rows[e.RowIndex].Cells["Enable"].ColumnIndex == e.ColumnIndex) { Boolean enable = !(Boolean)dgv.Rows[e.RowIndex].Cells["Enable"].Value; string filefullpath = (string)dgv.Rows[e.RowIndex].Cells["FilePath"].Value; int line = int.Parse((string)dgv.Rows[e.RowIndex].Cells["Line"].Value); ITabbedDocument doc = ScintillaHelper.GetDocument(filefullpath); if (doc != null) { // This logic should be handled by BPMAnager, wo we'll just work arround bad BPs and ignore them if (line < 1 || (doc.SciControl != null && line > doc.SciControl.LineCount)) { return; } Boolean m = ScintillaHelper.IsMarkerSet(doc.SciControl, ScintillaHelper.markerBPDisabled, line - 1); if (m) { doc.SciControl.MarkerAdd(line - 1, ScintillaHelper.markerBPEnabled); doc.SciControl.MarkerDelete(line - 1, ScintillaHelper.markerBPDisabled); } else { doc.SciControl.MarkerAdd(line - 1, ScintillaHelper.markerBPDisabled); doc.SciControl.MarkerDelete(line - 1, ScintillaHelper.markerBPEnabled); } if (e.RowIndex >= 0 && e.RowIndex < dgv.Rows.Count) // list can have been updated in the meantime { if ((Boolean)dgv.Rows[e.RowIndex].Cells["Enable"].Value != m) { dgv.Rows[e.RowIndex].Cells["Enable"].Value = m; } } dgv.RefreshEdit(); } } }
/// <summary> /// Applies the file state to a scintilla control /// </summary> public static void ApplyFileState(ITabbedDocument document, Boolean restorePosition) { try { if (!document.IsEditable) return; String fileStateDir = FileNameHelper.FileStateDir; String fileName = ConvertToFileName(document.FileName); String stateFile = Path.Combine(fileStateDir, fileName + ".fdb"); if (File.Exists(stateFile)) { StateObject so = new StateObject(); so = (StateObject)ObjectSerializer.Deserialize(stateFile, so); ApplyStateObject(document.SciControl, so, restorePosition); } } catch (Exception ex) { ErrorManager.ShowError(ex); } }
/// <summary> /// Updates color of a document tab /// </summary> private static void UpdateTabColor(ITabbedDocument doc, List<String> paths, ProjectManagerSettings settings) { Boolean isMatch = false; foreach (String path in paths) { if (doc.FileName.StartsWith(path, StringComparison.OrdinalIgnoreCase)) { isMatch = true; break; } } DockContent tab = doc as DockContent; if (!isMatch && settings.TabHighlightType == HighlightType.ExternalFiles) { if (tab.TabColor != TabHighlightColor) tab.TabColor = TabHighlightColor; } else if (isMatch && settings.TabHighlightType == HighlightType.ProjectFiles) { if (tab.TabColor != TabHighlightColor) tab.TabColor = TabHighlightColor; } else if (tab.TabColor != Color.Transparent) tab.TabColor = Color.Transparent; }
static private MessageBar CreateBar(ITabbedDocument target, String message) { MessageBar bar; foreach (Control ctrl in target.Controls) { if (ctrl is MessageBar) { bar = (ctrl as MessageBar); bar.Update(message); bar.Visible = true; return bar; } } bar = new MessageBar(); bar.Visible = false; target.Controls.Add(bar); bar.Dock = DockStyle.Top; bar.Update(message); bar.SendToBack(); bar.Visible = true; return bar; }
private bool IsHaxeUILayout(ITabbedDocument tdoc) { if (tdoc == null || tdoc.SciControl == null) { return false; } try { string content = tdoc.SciControl.Text.ToLower(); XmlDocument document = new XmlDocument(); document.LoadXml(content); foreach (string c in HAXEUI_COMPONENTS) { // TODO: probably not the best way to do this if (document.SelectNodes("//" + c.ToLower()).Count > 0) { return true; } } } catch { return false; } return false; }
/// <summary> /// Formats the specified document /// </summary> private void DoFormat(ITabbedDocument doc) { if (doc.IsEditable) { doc.SciControl.BeginUndoAction(); Int32 oldPos = CurrentPos; String source = doc.SciControl.Text; try { switch (DocumentType) { case TYPE_AS3: ASPrettyPrinter asPrinter = new ASPrettyPrinter(true, source); FormatUtility.configureASPrinter(asPrinter, this.settingObject); String asResultData = asPrinter.print(0); if (asResultData == null) { TraceManager.Add(TextHelper.GetString("Info.CouldNotFormat"), -3); PluginBase.MainForm.CallCommand("PluginCommand", "ResultsPanel.ShowResults"); } else { doc.SciControl.Text = asResultData; doc.SciControl.ConvertEOLs(doc.SciControl.EOLMode); } break; case TYPE_MXML: case TYPE_XML: MXMLPrettyPrinter mxmlPrinter = new MXMLPrettyPrinter(source); FormatUtility.configureMXMLPrinter(mxmlPrinter, this.settingObject); String mxmlResultData = mxmlPrinter.print(0); if (mxmlResultData == null) { TraceManager.Add(TextHelper.GetString("Info.CouldNotFormat"), -3); PluginBase.MainForm.CallCommand("PluginCommand", "ResultsPanel.ShowResults"); } else { doc.SciControl.Text = mxmlResultData; doc.SciControl.ConvertEOLs(doc.SciControl.EOLMode); } break; case TYPE_CPP: AStyleInterface asi = new AStyleInterface(); String optionData = this.GetOptionData(doc.SciControl.ConfigurationLanguage.ToLower()); String resultData = asi.FormatSource(source, optionData); if (String.IsNullOrEmpty(resultData)) { TraceManager.Add(TextHelper.GetString("Info.CouldNotFormat"), -3); PluginBase.MainForm.CallCommand("PluginCommand", "ResultsPanel.ShowResults"); } else { // Remove all empty lines if not specified for astyle if (!optionData.Contains("--delete-empty-lines")) { resultData = Regex.Replace(resultData, @"^\s+$[\r\n]*", Environment.NewLine, RegexOptions.Multiline); } doc.SciControl.Text = resultData; doc.SciControl.ConvertEOLs(doc.SciControl.EOLMode); } break; } } catch (Exception) { TraceManager.Add(TextHelper.GetString("Info.CouldNotFormat"), -3); PluginBase.MainForm.CallCommand("PluginCommand", "ResultsPanel.ShowResults"); } CurrentPos = oldPos; doc.SciControl.EndUndoAction(); } }
/// <summary> /// Formats the specified document /// </summary> private void DoFormat(ITabbedDocument doc) { if (doc.IsEditable) { doc.SciControl.BeginUndoAction(); Int32 oldPos = CurrentPos; String source = doc.SciControl.Text; try { switch (DocumentType) { case TYPE_AS3: ASPrettyPrinter asPrinter = new ASPrettyPrinter(true, source); FormatUtility.configureASPrinter(asPrinter, this.settingObject, PluginBase.Settings.TabWidth); String asResultData = asPrinter.print(0); if (asResultData == null) { TraceManager.Add(TextHelper.GetString("Info.CouldNotFormat"), -3); PluginBase.MainForm.CallCommand("PluginCommand", "ResultsPanel.ShowResults"); } else { doc.SciControl.Text = asResultData; doc.SciControl.ConvertEOLs(doc.SciControl.EOLMode); } break; case TYPE_MXML: case TYPE_XML: MXMLPrettyPrinter mxmlPrinter = new MXMLPrettyPrinter(source); FormatUtility.configureMXMLPrinter(mxmlPrinter, this.settingObject, PluginBase.Settings.TabWidth); String mxmlResultData = mxmlPrinter.print(0); if (mxmlResultData == null) { TraceManager.Add(TextHelper.GetString("Info.CouldNotFormat"), -3); PluginBase.MainForm.CallCommand("PluginCommand", "ResultsPanel.ShowResults"); } else { doc.SciControl.Text = mxmlResultData; doc.SciControl.ConvertEOLs(doc.SciControl.EOLMode); } break; } } catch (Exception) { TraceManager.Add(TextHelper.GetString("Info.CouldNotFormat"), -3); PluginBase.MainForm.CallCommand("PluginCommand", "ResultsPanel.ShowResults"); } CurrentPos = oldPos; doc.SciControl.EndUndoAction(); } }
/// <summary> /// Sets the tab text if needed /// </summary> public static void SetTabText(ITabbedDocument doc, String text) { if (doc.Text != text) doc.Text = text; }
/// <summary> /// Notifies the plugins for the FileSave event /// </summary> public void OnFileSave(ITabbedDocument document, String oldFile) { if (oldFile != null) { String args = document.FileName + ";" + oldFile; TextEvent rename = new TextEvent(EventType.FileRename, args); EventManager.DispatchEvent(this, rename); TextEvent open = new TextEvent(EventType.FileOpen, document.FileName); EventManager.DispatchEvent(this, open); } this.OnUpdateMainFormDialogTitle(); if (document.IsEditable) document.SciControl.MarkerDeleteAll(2); TextEvent save = new TextEvent(EventType.FileSave, document.FileName); EventManager.DispatchEvent(this, save); ButtonManager.UpdateFlaggedButtons(); TabTextManager.UpdateTabTexts(); }
private TabDetails GetTabDetails(ITabbedDocument tdoc) { TabDetails details = null; if (tabDetails.ContainsKey(tdoc) == true) { details = tabDetails[tdoc]; } else { details = CreateTabDetails(tdoc); } return details; }
private void SetDocumentIcon(ITabbedDocument doc) { Bitmap bitmap = null; // try to open with the same icon that the treeview is using if (doc.FileName != null) { if (Tree.NodeMap.ContainsKey(doc.FileName)) bitmap = Tree.ImageList.Images[Tree.NodeMap[doc.FileName].ImageIndex] as Bitmap; else bitmap = Icons.GetImageForFile(doc.FileName).Img as Bitmap; } if (bitmap != null) { doc.UseCustomIcon = true; doc.Icon = Icon.FromHandle(bitmap.GetHicon()); } }
/// <summary> /// Notifies the plugins for the FileSave event /// </summary> public void OnFileSave(ITabbedDocument document, Boolean newFile) { if (newFile) { TextEvent te1 = new TextEvent(EventType.FileOpen, document.FileName); EventManager.DispatchEvent(this, te1); } this.OnUpdateMainFormDialogTitle(); if (document.IsEditable) document.SciControl.MarkerDeleteAll(2); TextEvent te2 = new TextEvent(EventType.FileSave, document.FileName); EventManager.DispatchEvent(this, te2); ButtonManager.UpdateFlaggedButtons(); }
/// <summary> /// Sets the current document modified /// </summary> public void OnDocumentModify(ITabbedDocument document) { if (document.IsEditable && !document.IsModified && !this.reloadingDocument && !this.processingContents) { document.IsModified = true; TextEvent te = new TextEvent(EventType.FileModify, document.FileName); EventManager.DispatchEvent(this, te); } }
/// <summary> /// Sets the current document unmodified and updates it /// </summary> public void OnDocumentReload(ITabbedDocument document) { document.IsModified = false; this.reloadingDocument = false; this.OnUpdateMainFormDialogTitle(); if (document.IsEditable) document.SciControl.MarkerDeleteAll(2); ButtonManager.UpdateFlaggedButtons(); }
/// <summary> /// Checks if the language should use basic completion /// </summary> public Boolean IsSupported(ITabbedDocument document) { string lang = document.SciControl.ConfigurationLanguage; return lang == "css"; }
/// <summary> /// AS2/AS3 detection /// </summary> /// <param name="doc">Document to check</param> /// <returns>Detected language</returns> private string DetectActionscriptVersion(ITabbedDocument doc) { ASFileParser parser = new ASFileParser(); FileModel model = new FileModel(doc.FileName); parser.ParseSrc(model, doc.SciControl.Text); if (model.Version == 1 && PluginBase.CurrentProject != null) { String lang = PluginBase.CurrentProject.Language; if (lang == "*") return "as2"; else return lang; } else if (model.Version > 2) return "as3"; else if (model.Version > 1) return "as2"; else if (settingObject.LastASVersion != null && settingObject.LastASVersion.StartsWithOrdinal("as")) { return settingObject.LastASVersion; } else return "as2"; }
/// <summary> /// Currently edited document /// </summary> static internal void SetCurrentFile(ITabbedDocument doc, bool shouldIgnore) { // reset previous contexts if (validContexts.Count > 0) { foreach (IASContext oldcontext in validContexts) oldcontext.CurrentFile = null; } validContexts = new List<IASContext>(); context = defaultContext; context.CurrentFile = null; // check document string filename = ""; if (doc != null && doc.FileName != null) { filename = doc.FileName; if (doPathNormalization) filename = filename.Replace(dirAltSeparator, dirSeparator); } else shouldIgnore = true; FileModel.Ignore.FileName = filename ?? ""; // find the doc context(s) if (!shouldIgnore) { string lang = doc.SciControl.ConfigurationLanguage.ToLower(); string ext = Path.GetExtension(filename); if (!string.IsNullOrEmpty(ext) && lang == "xml") lang = ext.Substring(1).ToLower(); foreach (RegisteredContext reg in allContexts) { if (reg.Language == lang) { validContexts.Add(reg.Context); reg.Context.CurrentFile = filename; } } currentLine = -1; SetCurrentLine(doc.SciControl.CurrentLine); } // no context if (context == defaultContext) Panel.UpdateView(FileModel.Ignore); else Context.CheckModel(true); }
/// <summary> /// Find a group from a given ITabbledDicument /// </summary> /// <param name="doc"></param> /// <returns></returns> public ListViewGroup FindGroup( ITabbedDocument doc ) { foreach (ListViewGroup group in this.listView1.Groups) { if (((Hashtable)group.Tag)["Document"] == doc) { return group; } } return null; }