Пример #1
0
 public void Dispose()
 {
     NextWord = null;
 }
Пример #2
0
        public void GenerateSensibleArea(int startPos,int[] positions, ScintillaControl sci)
        {
            if (isMonitoring)
                DeactiveMonitorWords();

            //if (sci.CodePage == 65001 && startPos!=0)
            //{

            //    int strLen = Encoding.UTF8.GetByteCount(
            //        sci.Text.Substring(0,startPos)
            //        );
            //    startPos = strLen;
            //}

             //startPos = sci.MBSafePosition(startPos);
             WordRegionBase last=null;
               WordRegionBase wr=null;
            for (int i = 0; i < positions.Length; i+=2)
            {

                if (i == positions.Length-2)
                {
                    wr = new LastWordRegion();
                }
                else
                {
                    wr = new WordRegion();
                }

                wr.type = WordRegionBase.kind.place;

                wr.startWord = startPos + positions[i];
                wr.endWord = startPos + positions[i + 1];

                if (last != null)
                {
                    last.NextWord = wr;
                }

                last = wr;
                Words.Add(wr);
            }

            firstWord = Words[0];

            lastWord = wr;
            fileName = ASContext.Context.CurrentClass.Name;

            if (MonitorOnWordsActive != null)
                MonitorOnWordsActive(this);

            ActiveMonitorWords();

            MoveNextWord();
        }
Пример #3
0
        public string MakeTextFromSnippet(ScintillaControl sci, AbbrevationSnippet abbrSnippet)
        {
            StringBuilder sbSnippet = new StringBuilder(abbrSnippet.Snippet);

            if (isMonitoring)
                DeactiveMonitorWords();

            if(abbrSnippet.HasImport)
            imports = new List<string>();
            if (abbrSnippet.HasEventHandler)
            eventsHandler = new List<int>();
            if (abbrSnippet.HasAfterCurrentMember)
            AfterCurrentMember = new List<string>();

            _dictCustomList = _setting.customList;

            int pos = sci.CurrentPos;
            int CodePage = sci.CodePage;

            string nl = ASCompletion.Completion.ASComplete.GetNewLineMarker(sci.EOLMode);
            int curLine = sci.LineFromPosition(pos);
            int startLine = sci.PositionFromLine(curLine);

            char ch = (char) sci.CharAt(startLine);
            string tabString = String.Empty;
            while ( Char.IsWhiteSpace( ch))
            {
                if(ch=='\n' || ch=='\r') break;
                tabString += ch;

                ch = (char)sci.CharAt(++startLine);
            }

             sbSnippet.Replace("\r","");
             sbSnippet.Replace("\n", nl + tabString);

             if (abbrSnippet.Arguments == null) return sbSnippet.ToString();

                previousLenPlace = 0;
                indexArgument = 0;
                numCursors = 0;

             MatchCollection mtc = _vocabularyArgument.regArguments.Matches(sbSnippet.ToString());
             int lenght = mtc.Count;
             Match m =null;
             Match var;

             string textClipBoard = "";
             int valueTextClipBoard = 0;

             char[] chars = null;
             int previousPos=0;
             for (int i = 0; i < lenght; i++)
             {
                  m = mtc[i];

                  /// if CodePage is 65001... pos= is position in scintilla text
                  /// and previousLen is position on abbrSnippet
                  if (indexArgument == abbrSnippet.Arguments.Length)
                  {
                      indexArgument = 0;

                          lsVar.Clear();

                  }

                  switch (abbrSnippet.Arguments[indexArgument])
                  {
                      #region Place
                      case WordTypes.place:
                          var = _vocabularyArgument.regPlace.Match(m.Value);
                          if (var.Success)
                          {
                              WordRegion wr = new WordRegion();

                              int correctPosString = m.Index - previousLenPlace;

                              int count = correctPosString - previousPos;
                              chars = new char[count];

                              sbSnippet.CopyTo(previousPos, chars, 0, count);
                              previousLenPlace += m.Length - var.Length;
                              sbSnippet.Remove(correctPosString, m.Length);
                              sbSnippet.Insert(correctPosString, var.Value);

                              previousPos = correctPosString + var.Length;

                              if (CodePage != 65001)
                              {
                                  wr.startWord = pos + chars.Length;
                                  wr.endWord = wr.startWord + var.Length;
                                  pos += chars.Length + var.Length;
                              }
                              else
                              {

                                  int strLen = Encoding.UTF8.GetByteCount(
                                      chars
                                      );
                                  int valueLen = Encoding.UTF8.GetByteCount(var.Value);
                                  wr.startWord = pos + strLen;
                                  wr.endWord = wr.startWord + valueLen;
                                  pos += strLen + valueLen;
                              }

                              wr.type = WordRegion.kind.place;

                              if (curWord != null)
                              {
                                  curWord.NextWord = wr;
                                  secondLastWord = curWord;
                              }

                              Words.Add(wr);

                              curWord = wr;
                              curIndWord++;
                              numCursors++;
                              indexArgument++;

                            //  sb.Append(var.Value);
                          }
                          break;
                      #endregion
                      #region cursor
                      case WordTypes.SafeZone:

                          if (m.Value == VocabularyArgument.SafeZone)
                          {
                              WordRegion wr = new WordRegion();
                              wr.type = WordRegionBase.kind.cursor;

                              //string previousTest = textSnippet.Substring(previousLenPlace, m.Index - previousLenPlace);
                              //sb.Append(previousTest);

                              int correctPosString = m.Index - previousLenPlace;

                              int count = correctPosString - previousPos;
                              chars = new char[count];

                              sbSnippet.CopyTo(previousPos, chars, 0, count);
                              previousLenPlace += m.Length;
                              sbSnippet.Remove(correctPosString, m.Length);

                              previousPos = correctPosString;

                              if (CodePage != 65001)
                              {
                                  wr.startWord = pos + chars.Length;
                                  wr.endWord = wr.startWord;
                                  pos += chars.Length;
                              }
                              else
                              {

                                  int strLen = Encoding.UTF8.GetByteCount(
                                      chars
                                      );
                                 // int valueLen = Encoding.UTF8.GetByteCount(var.Value);
                                  wr.startWord = pos + strLen;
                                  wr.endWord = wr.startWord ;
                                  pos += strLen ;
                              }

                              if (curWord != null)
                              {
                                  curWord.NextWord = wr;
                                  secondLastWord = curWord;
                              }

                              Words.Add(wr);
                              curWord = wr;
                              curIndWord++;
                              numCursors++;
                              indexArgument++;

                          }

                          break;
                      #endregion
                      #region createParameters
                      case WordTypes.createParameters:

                          if (m.Value == VocabularyArgument.CREATEPARAMATERS)
                          {
                              WordRegion wr = new WordRegion();
                              wr.type = WordRegionBase.kind.createParameters;

                              int correctPosString = m.Index - previousLenPlace;

                              int count = correctPosString - previousPos;
                              chars = new char[count];

                              sbSnippet.CopyTo(previousPos, chars, 0, count);
                              previousLenPlace += m.Length;
                              sbSnippet.Remove(correctPosString, m.Length);

                              previousPos = correctPosString;

                              if (CodePage != 65001)
                              {
                                  wr.startWord = pos + chars.Length;
                                  wr.endWord = wr.startWord;
                                  pos += chars.Length;
                              }
                              else
                              {

                                  int strLen = Encoding.UTF8.GetByteCount(
                                      chars
                                      );
                                  wr.startWord = pos + strLen;
                                  wr.endWord = wr.startWord;
                                  pos += strLen;
                              }

                              if (curWord != null)
                              {
                                  curWord.NextWord = wr;
                                  secondLastWord = curWord;
                              }

                              Words.Add(wr);
                              curWord = wr;
                              curIndWord++;
                              numCursors++;
                              indexArgument++;

                          }

                          break;
                      #endregion
                      #region clipboard
                      case WordTypes.Clipboard:
                          if (m.Value == VocabularyArgument.CLIPBOARD)
                          {

                              if (textClipBoard.Length==0)
                              {
                                  textClipBoard = System.Windows.Forms.Clipboard.GetText().Trim();
                                  valueTextClipBoard = Encoding.UTF8.GetByteCount(textClipBoard);
                              }

                              int correctPosString = m.Index - previousLenPlace;

                              previousLenPlace += m.Length - textClipBoard.Length;
                              sbSnippet.Remove(correctPosString, m.Length);
                              sbSnippet.Insert(correctPosString, textClipBoard);

                              if (CodePage != 65001)
                              {
                                  pos += chars.Length + textClipBoard.Length;
                              }
                              else
                              {

                                  int count = correctPosString - previousPos;
                                  chars = new char[count];
                                  sbSnippet.CopyTo(previousPos, chars, 0, count);
                                  int strLen = Encoding.UTF8.GetByteCount(
                                      chars
                                      );

                                  pos += strLen + valueTextClipBoard;
                              }

                              previousPos = correctPosString + textClipBoard.Length;

                              indexArgument++;

                          }

                          break;
                      #endregion
                      #region showcomp
                      case WordTypes.cmp:

                          var = _vocabularyArgument.regCompType.Match(m.Value);

                          //if (var.Value.Length!=0)
                          if(var.Success)
                          {
                              WordRegion wr = new WordRegion();
                              wr.type = WordRegion.kind.showCompType;

                              int correctPosString = m.Index - previousLenPlace;

                              int count = correctPosString - previousPos;
                              chars = new char[count];

                              sbSnippet.CopyTo(previousPos, chars, 0, count);
                              previousLenPlace += m.Length - var.Length;
                              sbSnippet.Remove(correctPosString, m.Length);
                              sbSnippet.Insert(correctPosString, var.Value);

                              previousPos = correctPosString + var.Length;

                              if (CodePage != 65001)
                              {
                                  wr.startWord = pos + chars.Length;
                                  wr.endWord = wr.startWord + var.Length;
                                  pos += chars.Length + var.Length;
                              }
                              else
                              {

                                  int strLen = Encoding.UTF8.GetByteCount(
                                      chars
                                      );
                                  int valueLen = Encoding.UTF8.GetByteCount(var.Value);
                                  wr.startWord = pos + strLen;
                                  wr.endWord = wr.startWord + valueLen;
                                  pos += strLen + valueLen;
                              }

                              if (curWord != null)
                              {
                                  curWord.NextWord = wr;
                                  secondLastWord = curWord;
                              }

                              Words.Add(wr);
                              curWord = wr;

                              curIndWord++;
                              numCursors++;
                              indexArgument++;

                          }

                          break;
                      #endregion
                      #region variable link
                      case WordTypes.var:

                          var = _vocabularyArgument.regVar.Match(m.Value);

                          if (var.Value.Length!=0)
                          {
                              VarWordRegion varRootWR = null;
                              VarDuplicateWordRegion vdwr = null;
                              VarWordRegion vwr = null;
                              WordRegionBase wr;

                              // there is a root?
                              if (lsVar.TryGetValue(var.Value, out varRootWR))
                              {
                                  vdwr = new VarDuplicateWordRegion();
                                  wr = vdwr;
                                  vdwr.type = WordRegionBase.kind.VarLink;
                              }
                              else
                              {

                                  vwr = new VarWordRegion();
                                  vwr.ValueVar = var.Value;
                                  curIndWord++;

                                  string option = m.Value.Substring(var.Index + var.Length);
                                  Match mc = _vocabularyArgument.regList.Match(option);

                                  if (mc.Value.Length!=0)
                                  {
                                      vwr.indList = mc.Value;
                                      vwr.type = WordRegionBase.kind.customList;
                                  }
                                  else if (option.IndexOf("showCmp") != -1)
                                      vwr.type = WordRegion.kind.VarLinkAndComp;
                                  else
                                      vwr.type = WordRegionBase.kind.VarLink;

                                  wr = vwr;

                                  vwr.ChangeVarWord += new VarWordRegion.ChangeVarEventHandler(vwr_ChangeVarWord);
                              }

                              //string previousTest = textSnippet.Substring(previousLenPlace, m.Index - previousLenPlace);
                              //sb.Append(previousTest);

                              // questo serve per cancellare index
                              int correctPosString = m.Index - previousLenPlace;

                              int count = correctPosString - previousPos;
                              chars = new char[count];

                              sbSnippet.CopyTo(previousPos, chars, 0, count);
                              previousLenPlace += m.Length - var.Length;
                              sbSnippet.Remove(correctPosString, m.Length);
                              sbSnippet.Insert(correctPosString, var.Value);

                              previousPos = correctPosString +  var.Length;

                              if (CodePage != 65001)
                              {
                                  wr.startWord = pos + chars.Length;
                                  wr.endWord = wr.startWord + var.Length;
                                  pos += chars.Length + var.Length;
                              }
                              else
                              {

                                  int strLen = Encoding.UTF8.GetByteCount(
                                      chars
                                      );
                                  int valueLen = Encoding.UTF8.GetByteCount(var.Value);
                                  wr.startWord = pos + strLen;
                                  wr.endWord = wr.startWord + valueLen;
                                  pos += strLen + valueLen;
                              }

                              if (curWord != null)
                              {
                                  curWord.NextWord = wr;
                                  secondLastWord = curWord;
                              }

                              curWord = wr;

                              if (varRootWR != null)
                              {
                                  varRootWR.InsertVarDuplicate(vdwr);
                                  //varRootWR.lstWords.Add(vdwr);
                              }
                              else
                              {
                                  lsVar.Add(var.Value, vwr);
                                  Words.Add(wr);
                              }
                              indexArgument++;

                              numCursors++;

                           //   sb.Append(var.Value);
                          }

                          break;
                      #endregion
                      #region mbrname
                      case WordTypes.mbrname:
                          if (m.Value == VocabularyArgument.MbrName)
                          {

                              string strMbrName = "";

                              if (ASContext.Context.CurrentMember != null)
                              {
                                  strMbrName = ASContext.Context.CurrentMember.Name;
                              }

                              int correctPosString = m.Index - previousLenPlace;

                              previousLenPlace += m.Length - strMbrName.Length;
                              sbSnippet.Remove(correctPosString, m.Length);
                              sbSnippet.Insert(correctPosString, strMbrName);

                              if (CodePage != 65001)
                              {
                                  pos += chars.Length + strMbrName.Length;
                              }
                              else
                              {

                                  int count = correctPosString - previousPos;
                                  chars = new char[count];
                                  sbSnippet.CopyTo(previousPos, chars, 0, count);
                                  int strLen = Encoding.UTF8.GetByteCount(
                                      chars
                                      );

                                  pos += strLen + strMbrName.Length;
                              }

                              previousPos = correctPosString + strMbrName.Length;

                              indexArgument++;
                          }
                          break;
                      #endregion
                      #region "Browser"
                      case WordTypes.browser:
                          // --------------  browser
                          if (m.Value == VocabularyArgument.BROWSER)
                          {
                              WordRegion wr = new WordRegion();
                              wr.type = WordRegion.kind.browser;

                              int correctPosString = m.Index - previousLenPlace;

                              int count = correctPosString - previousPos;
                              chars = new char[count];

                              sbSnippet.CopyTo(previousPos, chars, 0, count);
                              previousLenPlace += m.Length;
                              sbSnippet.Remove(correctPosString, m.Length);

                              previousPos = correctPosString;

                              if (CodePage != 65001)
                              {
                                  wr.startWord = pos + chars.Length;
                                  wr.endWord = wr.startWord;
                                  pos += chars.Length;
                              }
                              else
                              {

                                  int strLen = Encoding.UTF8.GetByteCount(
                                      chars
                                      );
                                  wr.startWord = pos + strLen;
                                  wr.endWord = wr.startWord;
                                  pos += strLen ;
                              }

                              //  wr.lineNumber = lineNumber;

                              if (curWord != null)
                              {
                                  curWord.NextWord = wr;
                                  secondLastWord = curWord;
                              }

                              Words.Add(wr);
                              curWord = wr;
                              curIndWord++;
                              //  wr.index = curIndWord;
                              numCursors++;
                              indexArgument++;

                          }
                          break;
                      #endregion
                      #region AfterCurrentMember
                      case WordTypes.AfterCurrentMember:

                          var = _vocabularyArgument.regAfterCurrentMember.Match(m.Value);
                          if (var.Value.Length!=0)
                          {

                              if (ASContext.Context.CurrentMember != null)
                              {
                                  if (!AfterCurrentMember.Contains(var.Value))
                                  {
                                      AfterCurrentMember.Add(var.Value);
                                      dontCreateLastWord = true;
                                  }
                                  //strMbrName = ASContext.Context.CurrentMember.Name;
                              }

                              int correctPosString = m.Index - previousLenPlace;

                              int count = correctPosString - previousPos;
                              chars = new char[count];

                              sbSnippet.CopyTo(previousPos, chars, 0, count);
                              previousLenPlace += m.Length;
                              sbSnippet.Remove(correctPosString, m.Length);

                              previousPos = correctPosString;

                              if (CodePage != 65001)
                              {

                                  pos += chars.Length;
                              }
                              else
                              {
                                  int strLen = Encoding.UTF8.GetByteCount(
                                      chars
                                      );

                                  pos += strLen;
                              }

                              indexArgument++;

                          }
                          break;
                      #endregion
                      #region Custom list
                      case WordTypes.list:
                          //-------- CUSTOM LIST COMPLETITION

                          var = _vocabularyArgument.regList.Match(m.Value);

                          if (var.Value.Length!=0)
                          {
                              WordCustomList wr = new WordCustomList();
                              wr.type = WordRegion.kind.customList;
                              string value = "";
                              List<string> ls;
                              if (_dictCustomList.TryGetValue(var.Value, out ls))
                              {

                                  if(ls.Count>0)
                                  value = ls[0];
                              }

                              int correctPosString = m.Index - previousLenPlace;

                              int count = correctPosString - previousPos;
                              chars = new char[count];

                              sbSnippet.CopyTo(previousPos, chars, 0, count);
                              previousLenPlace += m.Length - value.Length;
                              sbSnippet.Remove(correctPosString, m.Length);
                              sbSnippet.Insert(correctPosString, value);

                              previousPos = correctPosString + value.Length;

                              if (CodePage != 65001)
                              {
                                  wr.startWord = pos + chars.Length;
                                  wr.endWord = wr.startWord + value.Length;
                                  pos += chars.Length + value.Length;
                              }
                              else
                              {

                                  int strLen = Encoding.UTF8.GetByteCount(
                                      chars
                                      );
                                  int valueLen = Encoding.UTF8.GetByteCount(value);
                                  wr.startWord = pos + strLen;
                                  wr.endWord = wr.startWord + valueLen;
                                  pos += strLen + valueLen;
                              }

                              //  wr.lineNumber = lineNumber;
                              wr.indList = var.Value;
                              if (curWord != null)
                              {
                                  curWord.NextWord = wr;
                                  secondLastWord = curWord;
                              }

                              Words.Add(wr);
                              curWord = wr;
                              curIndWord++;
                              //   wr.index = curIndWord;
                              numCursors++;
                              indexArgument++;

                          }

                          break;
                      #endregion
                      #region import
                      case WordTypes.import:
                          var = _vocabularyArgument.regImport.Match(m.Value);

                          if (var.Value.Length!=0)
                          {

                              int correctPosString = m.Index - previousLenPlace;

                              previousLenPlace += m.Length - var.Length;
                              sbSnippet.Remove(correctPosString, m.Length);
                              sbSnippet.Insert(correctPosString, var.Value);

                              if (CodePage != 65001)
                              {
                                  pos += chars.Length + var.Length;
                              }
                              else
                              {

                                  int count = correctPosString - previousPos + var.Value.Length;
                                  chars = new char[count];
                                  sbSnippet.CopyTo(previousPos, chars, 0, count);
                                  int strLen = Encoding.UTF8.GetByteCount(
                                      chars
                                      );

                                  pos += strLen ;
                              }

                              previousPos = correctPosString + var.Length;

                              if (!imports.Contains(var.Value))
                                  imports.Add(var.Value);

                              indexArgument++;

                          }
                          break;
                      #endregion
                      #region EventHandler
                      case WordTypes.EventHandler:
                          var = _vocabularyArgument.regEventHandler.Match(m.Value);

                          if (var.Value.Length!=0)
                          {

                              int correctPosString = m.Index - previousLenPlace;

                              previousLenPlace += m.Length - var.Length;
                              sbSnippet.Remove(correctPosString, m.Length);
                              sbSnippet.Insert(correctPosString, var.Value);

                              if (CodePage != 65001)
                              {
                                  pos += chars.Length + var.Length;
                              }
                              else
                              {

                                  int count = correctPosString - previousPos + var.Value.Length;
                                  chars = new char[count];
                                  sbSnippet.CopyTo(previousPos, chars, 0, count);
                                  int strLen = Encoding.UTF8.GetByteCount(
                                      chars
                                      );

                                  pos += strLen;

                              }
                              eventsHandler.Add(pos);
                              previousPos = correctPosString + var.Length;

                              indexArgument++;

                          }
                          break;
                      #endregion
                  }

             }

            if (!dontCreateLastWord)
            ConvertLastWord();

            return sbSnippet.ToString();
        }
Пример #4
0
        public void CreateParameters(List<ASCompletion.Model.MemberModel> parameters, TextParameters textParameters)
        {
            WordRegionBase previous = null;
            WordRegionBase nextWord = null;
            StringBuilder sb = new StringBuilder(10);
            int actpos = ASContext.CurSciControl.CurrentPos;
            int varpos = actpos;
            int index =0;
            WordRegionBase wrCurrent = null;
            if (!isMonitoring)
            {
                Words = new List<WordRegionBase>();
                curIndWord = index;

            }
            else
            {
               // if (curIndWord == Words.Count) curIndWord--;
                if (highlightWord != null)
                    highlightWord.Stop();

                 wrCurrent = firstWord;
                int position = sciMonitor.CurrentPos;

                TestInRegion(position);

                // La parola nella quale viene inserito/rimosso il carattere
                while (wrCurrent != null)
                {

                    if (position <= wrCurrent.endWord)
                    {
                        if ((wrCurrent.startWord <= position))
                        {

                            break;
                        }

                    }

                    previous = wrCurrent;
                    wrCurrent = wrCurrent.NextWord;

                }

                nextWord = wrCurrent.NextWord;

                sciMonitor.TextInserted -= new TextInsertedHandler(sciMonitor_TextInserted);
                index = curIndWord;
                Words.RemoveAt(curIndWord);

            }

            int startToolTip = textParameters.text.IndexOf("(") +1;
            textParameters.posParameters = actpos - startToolTip + 1;
              //  int indexToolTip = 0;

            WordRegionParameter wordParamater=null;
            WordRegionBase realPrevious = null;
            foreach (ASCompletion.Model.MemberModel mm in parameters)
            {
                if (mm.Value != null || mm.Name == "...rest") break;

                wordParamater = new WordRegionParameter();
                wordParamater.startWord = varpos;
                wordParamater.endWord = varpos + mm.Name.Length;
                wordParamater.type = WordRegionBase.kind.Parameter;
                wordParamater.textParameters = textParameters;
                wordParamater.startToolTip = startToolTip;
                //es              ( X              :    number)

                int typeLength = (mm.Type != null) ? mm.Type.Length : 0;

                wordParamater.endToolTip = startToolTip + mm.Name.Length + 1 + typeLength;
                // (, )
                startToolTip = wordParamater.endToolTip + 2;
                //indexToolTip++;

                //wr.indexToolTip = indexToolTip;
                sb.Append(mm.Name);
                sb.Append(", ");
                varpos = actpos + sb.Length;

                if (textParameters.comments != null)
                {

                    Match mParam = Regex.Match(textParameters.comments, "@param\\s+" + Regex.Escape(mm.Name) + "[ \t:]+(?<desc>[^\r\n]*)");

                    if (mParam.Success)
                    {
                        wordParamater.textParameter = "\n[B]" + mm.Name + ":[/B] " + mParam.Groups["desc"].Value.Trim();
                    }

                }

                Words.Insert(index, wordParamater);
                index++;
                if (previous == null)
                {
                    previous = wordParamater;
                }
                else
                {
                    previous.NextWord = wordParamater;
                    realPrevious = previous;
                    previous = wordParamater;
                }

            }

            sb.Remove(sb.Length - 2, 2);

            ASContext.CurSciControl.InsertText(actpos, sb.ToString());

            if (Words.Count > 1)
            {
                numCursors = 2;

                // last word
                if (nextWord == null)
                {
                    index--;
                   // WordRegionBase wb = Words[index];
                   // LastWordRegionParameter lw = (LastWordRegionParameter)wb.getLastWord();
                    WordRegionBase lw = wordParamater.getLastWord();
                   // Words[index - 1].NextWord = lw;
                    if (realPrevious != null)
                    {
                        realPrevious.NextWord = lw;
                    }

                    Words[index] = lw;
                    lastWord = lw;
                }
                else
                {
                    previous.NextWord = nextWord;
                }

                firstWord = Words[0];

                if (!isMonitoring)
                {
                    curIndWord = -1;
                    TryActivateMonitor();

                    if (highlightWord != null)
                        highlightWord.Start();

                    return;
                }
            }
            else
            {
                if(!isMonitoring)
                ASContext.CurSciControl.SetSel(previous.startWord, previous.endWord);
                numCursors = 1;
            }

            if (isMonitoring)
            {
                if (highlightWord != null)
                    highlightWord.Start();

                if (nextWord != null)
                {
                    nextWord.addCharactersNextWord(sb.Length);
                    wrCurrent.Disable();

                }
                sciMonitor.TextInserted += new TextInsertedHandler(sciMonitor_TextInserted);
                curIndWord--;
                MoveNextWord();

            }
        }
Пример #5
0
        public void CreateTemporaryVar()
        {
            sciMonitor = ASContext.CurSciControl;

            if (Words.Count == 0)
            {
                LastWordRegion wb = new LastWordRegion();
                wb.startWord = wb.endWord = sciMonitor.CurrentPos;
                Words.Add(wb);
                firstWord = wb;
                numCursors = 1;
            }

                declarationWord = new WordRegion();

                sciMonitor.TextInserted += new TextInsertedHandler(insertTemporaryText);
                sciMonitor.TextDeleted += new TextDeletedHandler(deleteTemporaryText);
            // it became firstword in the list

                declarationWord.startWord = declarationWord.endWord = firstWord.startWord;
                declarationWord.NextWord = firstWord;
                firstWord = declarationWord;
        }
Пример #6
0
        private void WordsDeleteChange(int position, int length)
        {
            wrTested = TestDeleteInRegion(position);

            if (wrTested == null) { DeactiveMonitorWords(); return; }

             wrTested.removeCharactersFromRegion(length);
        }
Пример #7
0
        private void WordsInsertChange(int position, int length)
        {
            wrTested = InsertInRegion(position);

            if (wrTested == null) { DeactiveMonitorWords(); return; }

             wrTested.addCharactersToRegion(length);
        }
Пример #8
0
        void sciMonitor_TextInserted(ScintillaControl sender, int position, int length, int linesAdded)
        {
            if (linesAdded > 0)
            {

                // Control import/declaration generator

                    if (length > 4)
                    {

                        // only a unique temporary world

                        string strControl = sciMonitor.GetLine(sciMonitor.LineFromPosition(position));
                        // is a snippet ,FlashDevelop has generated code

                        int indexImport = -1;

                        // FlashDevelop generate snippet
                        if (strControl.IndexOf("$(Boundary)") == -1 && (indexImport= strControl.IndexOf("import")) == -1)
                        {
                            DeactiveMonitorWords();
                            return;
                        }

                        WordRegion newStatmentWord = new WordRegion();

                            newStatmentWord.endWord = newStatmentWord.startWord = position;
                        // is import
                            if (indexImport != -1)
                            {
                                newStatmentWord.type = WordRegionBase.kind.Import;

                                if (importWord != null)
                                    RemoveDeclarationWord(sender, importWord);

                                importWord = newStatmentWord;

                            }
                            else
                            {

                                newStatmentWord.type = WordRegion.kind.temporary;
                                if (declarationWord != null)
                                    RemoveDeclarationWord(sender, declarationWord);

                                declarationWord = newStatmentWord;
                            }

                            newStatmentWord.NextWord = firstWord;
                            firstWord = newStatmentWord;

                            sender.TextInserted += new TextInsertedHandler(DeclarationWordTextChange);
                            sender.TextDeleted += new TextDeletedHandler(DeclarationWordTextChange);

                            if (indexImport == -1)
                            {
                                int posInsert = curIndWord;
                                if (posInsert >= Words.Count)
                                { posInsert = Words.Count - 1; }
                                else if (posInsert < 0) posInsert = 0;

                                Words.Insert(posInsert, newStatmentWord);
                            }

                            wrTested = newStatmentWord;
                            newStatmentWord.addCharactersToRegion(length);

                            if (highlightWord != null)
                            {
                                highlightWord.Stop();
                                highlightWord.Start();
                            }

                            return;

                    }

                    DeactiveMonitorWords();
                    return;

            }

            // Write before abbreviation
            if (position > lastWord.endWord) { DeactiveMonitorWords(); return; }

            WordsInsertChange(position, length);

            if (highlightWord != null)
            {
                highlightWord.Stop();
                highlightWord.Start();
            }
        }
Пример #9
0
 private void RemoveDeclarationWord(ScintillaControl sender, WordRegion wordToDelete)
 {
     firstWord = wordToDelete.NextWord;
     if (wordToDelete.type != WordRegionBase.kind.Import)
         Words.Remove(wordToDelete);
     wordToDelete.NextWord = null;
     wordToDelete = null;
     sender.TextInserted -= new TextInsertedHandler(DeclarationWordTextChange);
     sender.TextDeleted -= new TextDeletedHandler(DeclarationWordTextChange);
 }
Пример #10
0
        /// <summary>
        /// Convert Last word in list 
        /// </summary>
        public void ConvertLastWord()
        {
            if (secondLastWord != null)
            {
                VarDuplicateWordRegion vdw  =curWord as VarDuplicateWordRegion;

                if (vdw!=null)
                {

                    VarDuplicateWordRegion lwr = (VarDuplicateWordRegion)vdw.getLastWord();

                    secondLastWord.NextWord = lwr;

                    vdw.rootWord.SetLastVar(lwr);
                    lastWord = lwr;

                }
                else
                {

                    WordRegionBase lwr = curWord.getLastWord();

                    //    lwr.vwr = ((VarDuplicateWordRegion)curWord).vwr;

                    secondLastWord.NextWord = lwr;
                    // Words[Words.Count - 2].NextWord = lwr;
                    Words[Words.Count - 1] = lastWord = lwr;
                }

            }
            else if (imports!=null)
            {
                if (Words.Count == 1)
                {
                    WordRegionBase lwr = curWord.getLastWord();

                    Words[0] = firstWord = lwr;
                }
            }

            secondLastWord = null;
            curWord = null;
            dontCreateLastWord = false;
            if (Words.Count > 0)
            {
                firstWord = Words[0];
            }

            curIndWord = -1;
        }
Пример #11
0
        private void DeactiveMonitorWords()
        {
            if (isList>-1)
            {
                CompletionList.OnInsert -= new InsertedTextHandler(CompletionList_OnInsert);
                isList = -1;
            }

            if (highlightWord != null)
            {
                QuickGenerator.CustomCompletionList.ExplorerProject.RemoveHighlights(sciMonitor);
                highlightWord.Stop();

                if (!_setting._showHighLight)
                {
                    highlightWord.Tick -= new EventHandler(highlightWord_Tick);
                    highlightWord = null;
                }
            }

            alreadyInvoke = false;

            ASContext.CommonSettings.DisableCodeReformat = reformater;

            if (declarationWord != null)
            {
                sciMonitor.TextInserted -= new TextInsertedHandler(DeclarationWordTextChange);
                sciMonitor.TextDeleted -= new TextDeletedHandler(DeclarationWordTextChange);
                declarationWord.NextWord = null;
                declarationWord = null;
            }

            if (importWord != null)
            {
                sciMonitor.TextInserted -= new TextInsertedHandler(DeclarationWordTextChange);
                sciMonitor.TextDeleted -= new TextDeletedHandler(DeclarationWordTextChange);
                importWord.NextWord = null;
                importWord = null;
            }

            if (sciMonitor != null)
            {

                sciMonitor.TextInserted -= new TextInsertedHandler(sciMonitor_TextInserted);
                sciMonitor.TextDeleted -= new TextDeletedHandler(sciMonitor_TextDeleted);
                sciMonitor.CharAdded -= new CharAddedHandler(sciMonitor_CharAdded);
                sciMonitor.FocusChanged -= new FocusHandler(sciMonitor_FocusChanged);
            //    sciMonitor.FocusChanged -= new FocusHandler(sciMonitor_FocusChanged);

                sciMonitor = null;

            }
            //if (tmChangeWordText != null)
            //{
            //    tmChangeWordText.Stop();
            //    tmChangeWordText.Tick -= new EventHandler(tmChangeWordText_Tick);
            //    tmChangeWordText = null;
            //}

            lastWord = null;
            curWord = null;
            secondLastWord = null;

            WordRegionBase wb = firstWord;

            WordRegionBase disp = null;

            while (wb != null)
            {

                disp = wb;
                wb = wb.NextWord;
                disp.Dispose();
            }

            Words.Clear();

            if(imports!=null)
            imports.Clear();
            if (eventsHandler != null)
            eventsHandler.Clear();

            if (AfterCurrentMember != null)
            AfterCurrentMember.Clear();

            lsVar.Clear();
            isMonitoring = false;
            firstWord = null;

            numCursors = 0;

            curIndWord = -1;

            if(currentForm!=null)
            {
                currentForm.FormClosed -= new System.Windows.Forms.FormClosedEventHandler(currentForm_FormClosed);
                currentForm=null;
            }
            if (MonitorOnWordsDeactive != null)
                MonitorOnWordsDeactive(this);
            return;
        }
Пример #12
0
        public void RemoveTemporaryVar()
        {
            if (declarationWord != null)
            {
                firstWord = declarationWord.NextWord;
                sciMonitor.TextInserted -= new TextInsertedHandler(insertTemporaryText);
                sciMonitor.TextDeleted -= new TextDeletedHandler(deleteTemporaryText);
                declarationWord.Dispose();
                declarationWord = null;

            }
        }