public GotoAbbreviationCmd(string text,string description, Bitmap icon, CreateWords createWords) { this.icon = icon; this.value = text; this.cw = createWords; this.description = description; }
void cw_MonitorOnWordsDeactive(CreateWords createWords) { dictAbbreviations = null; MonitorWordsActive = false; currentSci = null; ScintillaControl sci = ASContext.CurSciControl; dictionaryCreateWords.Remove(sci.Handle); createWords.MonitorOnWordsActive -= new OnMonitorActiveEventHanlder(cw_MonitorOnWordsActive); createWords.MonitorOnWordsDeactive -= new OnMonitorActiveEventHanlder(cw_MonitorOnWordsDeactive); createWords.GotFocus -= new GotFocusHandler(createWords_GotFocus); createWords.Dispose(); createWords = null; currentCreateWords = null; }
private bool ProcessAbbrevation(ScintillaControl sci) { //if (_settings.abbrevationDictList == null) //{ // System.Windows.Forms.MessageBox.Show("Insert abbreviations before!!"); // return false; //} int start =0; int end = 0; string left = GetWordFromPosition(sci, ref start, ref end); if (left != null) { String ext = System.IO.Path.GetExtension(ASContext.Context.CurrentFile).ToLower(); ; dictAbbreviations = null; if (!settings.abbrevationDictList.TryGetValue(ext, out dictAbbreviations)) { dictAbbreviations = settings.abbrevationDictList[".other"]; } AbbrevationSnippet abbrevationSnippet; if (dictAbbreviations.TryGetValue(left , out abbrevationSnippet)) { sci.GotoPos(start); sci.BeginUndoAction(); CreateWords cwNew; // c'è una abbreviazione lo creo if (currentCreateWords != null) cw_MonitorOnWordsDeactive(currentCreateWords); cwNew = CreateNewWords(); string elaborateText = cwNew.MakeTextFromSnippet(sci, abbrevationSnippet); sci.SetSel(start, end); sci.ReplaceSel(elaborateText); if (abbrevationSnippet.Arguments == null) { cwNew.MonitorOnWordsActive -= new OnMonitorActiveEventHanlder(cw_MonitorOnWordsActive); cwNew.MonitorOnWordsDeactive -= new OnMonitorActiveEventHanlder(cw_MonitorOnWordsDeactive); sci.EndUndoAction(); return true; } DoBeforeMonitor(); // nessuna activazione quindi nessun monitor if (!currentCreateWords.TryActivateMonitor()) { cwNew.MonitorOnWordsActive -= new OnMonitorActiveEventHanlder(cw_MonitorOnWordsActive); cwNew.MonitorOnWordsDeactive -= new OnMonitorActiveEventHanlder(cw_MonitorOnWordsDeactive); } else { currentCreateWords = cwNew; } sci.EndUndoAction(); return true; } } //non ha trovato nessuna parola if (isCursor) { isCursor = false; ShowListAbbrevations(); return false; } if (MonitorWordsActive && currentSci.Focused) currentCreateWords.MoveNextWord(); else ShowListAbbrevations(); return false; }
void cw_MonitorOnWordsActive(CreateWords createWords) { MonitorWordsActive = true; currentSci = ASContext.CurSciControl; CreateWords cw; if (dictionaryCreateWords.TryGetValue(currentSci.Handle, out cw)) { cw_MonitorOnWordsDeactive(cw); currentSci = ASContext.CurSciControl; } dictionaryCreateWords.Add(currentSci.Handle, createWords); currentCreateWords = createWords; createWords.GotFocus += new GotFocusHandler(createWords_GotFocus); }
void createWords_GotFocus(CreateWords sender, ScintillaControl sci) { currentCreateWords = sender; currentSci = sci; }
private CreateWords CreateNewWords() { currentCreateWords = new CreateWords(settings, vocabularyArguments); currentCreateWords.MonitorOnWordsActive += new OnMonitorActiveEventHanlder(cw_MonitorOnWordsActive); currentCreateWords.MonitorOnWordsDeactive += new OnMonitorActiveEventHanlder(cw_MonitorOnWordsDeactive); return currentCreateWords; }
public void EventKey(PluginCore.KeyEvent k) { if (k.Value == settings.AbbrevationPlusFormatterShortCut) { if (reformatterCode == null) { System.Windows.Forms.MessageBox.Show("Reformat Code must be enable!!!"); return; } if (settings.abbrevationDictList == null) { System.Windows.Forms.MessageBox.Show("Insert abbreviations before!!"); return; } ScintillaControl sci = ASCompletion.Context.ASContext.CurSciControl; if (sci == null) return; if (dictionaryCreateWords.TryGetValue(sci.Handle, out currentCreateWords)) { if (currentCreateWords.IsMonitoring) { ControlCaretPosition(); return; } } int linePos = sci.LineFromPosition(sci.CurrentPos); string lineText = sci.GetLine(linePos); string[] str = reformatterCode.DivideStringCode(lineText); insertOnly = true; // Nothing Divisor ; so do a normal abbrevation if (str == null) { ProcessAbbrevation(sci); return; } bool hasOperator = reformatterCode.SearchForOperators(str[1], true); if (!hasOperator) { ProcessAbbrevation(sci); return; } int startLine = sci.PositionFromLine(linePos); int pos = startLine + str[0].TrimEnd().Length; int start = 0; int end = 0; // sci.CurrentPos = pos; //string word = sci.GetWordFromPosition(pos); string word = GetWordFromPosition(sci, pos, ref start,ref end); // string expandeText = ""; AbbrevationSnippet abbrSnippet = null; if (word !=null ) { String ext = System.IO.Path.GetExtension(ASContext.Context.CurrentFile).ToLower(); ; dictAbbreviations = null; if (!settings.abbrevationDictList.TryGetValue(ext, out dictAbbreviations)) { dictAbbreviations = settings.abbrevationDictList[".other"]; } dictAbbreviations.TryGetValue(word,out abbrSnippet); } if (abbrSnippet != null) { //string reformatterString = reformatterCode.Reformat(abbrSnippet.Snippet); AbbrevationSnippet reformatAbbreviation = new AbbrevationSnippet(reformatterCode.Reformat(abbrSnippet.Snippet)); reformatAbbreviation.Arguments = abbrSnippet.Arguments; reformatAbbreviation.HasAfterCurrentMember = abbrSnippet.HasAfterCurrentMember; reformatAbbreviation.HasEventHandler = abbrSnippet.HasEventHandler; reformatAbbreviation.HasImport = abbrSnippet.HasImport; sci.GotoPos(start); sci.BeginUndoAction(); if (currentCreateWords != null) cw_MonitorOnWordsDeactive(currentCreateWords); CreateWords cwNew = CreateNewWords(); string elaborateText = currentCreateWords.MakeTextFromSnippet(sci, reformatAbbreviation); sci.SetSel(start, end); sci.ReplaceSel( elaborateText); sci.DelLineRight(); if (abbrSnippet.Arguments == null) { sci.EndUndoAction(); return; } DoBeforeMonitor(); if (!currentCreateWords.TryActivateMonitor()) { cwNew.MonitorOnWordsActive -= new OnMonitorActiveEventHanlder(cw_MonitorOnWordsActive); cwNew.MonitorOnWordsDeactive -= new OnMonitorActiveEventHanlder(cw_MonitorOnWordsDeactive); } else { currentCreateWords = cwNew; } sci.EndUndoAction(); return; } else { string newString = reformatterCode.Reformat(str[0] + ";"); sci.GotoPos(startLine); sci.BeginUndoAction(); sci.DelLineRight(); sci.InsertText(sci.CurrentPos, newString); sci.EndUndoAction(); sci.GotoPos(startLine + newString.Length); } } else if (k.Value == settings.AbbrevationShortCut) { ScintillaControl sci = ASCompletion.Context.ASContext.CurSciControl; if (sci == null) return; if (dictionaryCreateWords.TryGetValue(sci.Handle, out currentCreateWords)) { if (currentCreateWords.IsMonitoring) { ControlCaretPosition(); return; } } if (sci != null) if (sci.Focused) ProcessAbbrevation(sci); } else if (k.Value == settings.GotoAbbreviationShortCut) { if (dictionaryCreateWords != null && dictionaryCreateWords.Count>0) { if (dictionaryCreateWords.Count == 1) { Dictionary<IntPtr, CreateWords>.ValueCollection.Enumerator enumerator = dictionaryCreateWords.Values.GetEnumerator(); enumerator.MoveNext(); CreateWords currentCreateWords = enumerator.Current; if (currentCreateWords != null) { currentCreateWords.GoToCurrentWord(); } } else { List<PluginCore.ICompletionListItem> lcomp = new List<PluginCore.ICompletionListItem>(); foreach (KeyValuePair<IntPtr,CreateWords> data in dictionaryCreateWords) { lcomp.Add(new GotoAbbreviationCmd(data.Value.FileName ,data.Value.SciMonitor.FileName, ManagerResources.GoToAbbreviationBitmap, data.Value)); } PluginMain.custCompletion.Show(lcomp, false); } } } else if (k.Value == settings.GenerateSensibleAreaShortCut) { if (PathExplorer.IsWorking) { WaitFinishPathExplorer(); } if (ASContext.Context.CurrentMember != null) { MemberModel currentMember = ASContext.Context.CurrentMember; if (currentMember.Parameters == null || currentMember.Parameters.Count == 0) return; ScintillaControl sci= ASContext.CurSciControl; string declaration = sci.GetLine(currentMember.LineFrom); int startPos = declaration.IndexOf('('); int startLine = sci.PositionFromLine(currentMember.LineFrom); if (currentMember.Parameters.Count == 1) { int index = declaration.IndexOf(currentMember.Parameters[0].Name, startPos); int pos = startPos + startLine +1; sci.SetSel(pos, pos + currentMember.Parameters[0].Name.Length); return; } int j = -1; int[] positionsSensibleArea = new int[currentMember.Parameters.Count * 2]; int length = positionsSensibleArea.Length; for (int i = 0; i < length; i+=2) { j++; int index = declaration.IndexOf(currentMember.Parameters[j].Name, startPos); positionsSensibleArea[i] = index; positionsSensibleArea[i + 1] = index + currentMember.Parameters[j].Name.Length; } CreateWords cw; if (dictionaryCreateWords.TryGetValue(sci.Handle, out cw)) { cw_MonitorOnWordsDeactive(cw); currentSci = ASContext.CurSciControl; } currentCreateWords = CreateNewWords(); currentCreateWords.GenerateSensibleArea(startLine, positionsSensibleArea, sci); } } }
public void CreateParameters(List<MemberModel> list, bool isEventListener, TextParameters textParameters) { ScintillaControl sci = ASContext.CurSciControl; if (!dictionaryCreateWords.TryGetValue(sci.Handle, out currentCreateWords)) { currentCreateWords = CreateNewWords(); currentSci = sci; } currentCreateWords.CreateParameters(list, textParameters); if (isEventListener) { // ScintillaControl sci = ASContext.CurSciControl; sci.ReplaceSel(""); PluginCore.Controls.UITools.CallTip.Hide(); ASComplete.HandleFunctionCompletion(sci, true); currentCreateWords.ActivateList(); } }