internal void InitEvents() { INpp npp = Plugin.NppIntf; npp.Ready += OnReady; npp.Shutdown += OnShutdown; npp.FileClosing += OnFileClosing; npp.FileClosed += OnFileClosed; npp.FileOpening += OnFileOpening; npp.FileOpened += OnFileOpened; npp.FileSaving += OnFileSaving; npp.FileSaved += OnFileSaved; npp.FileActivated += OnFileActivated; npp.LanguageChanged += OnLanguageChanged; npp.StyleUpdate += OnStyleUpdate; npp.FileLoading += OnFileLoading; npp.FileLoadFailed += OnFileLoadFailed; npp.FileOrderChanged += OnFileOrderChanged; npp.CharAdded += OnCharAdded; npp.DoubleClick += OnDoubleClick; npp.Modification += OnModification; npp.SelectionChanged += OnSelectionChanged; npp.ScrolledVertically += OnScrolledVertically; npp.ScrolledHorizontally += OnScrolledHorizontally; }
internal Tokenizer(int line, int startPosition, INpp nppHelper, IntPtr sciPtr, bool isExtended = false) { _lineNumber = line; _lineText = new StringBuilder(nppHelper.GetLine(_lineNumber, sciPtr)); _startPosition = startPosition; _isLineExtended = isExtended; }
/// <summary> /// Initializes the plugin. /// </summary> /// <param name="npp">The Notepad++ interface object.</param> public static void Initialize(INpp npp) { _npp = npp; _output = new OutputView(); ScriptManager.Compile(); OutputStyleDef.InitStyles(); _npp.GetCommands += OnGetCommands; _npp.RegisterToolbarIcons += OnRegisterToolbarIcons; _npp.CommandExecuted += OnCommandExecuted; }
internal static Tokenizer.TokenTag FindTokenUnderCursor(int position, INpp nppHelper, IntPtr sciPtr) { if (position != -1) { int aCurrentLine = nppHelper.GetLineNumber(position, nppHelper.CurrentScintilla); bool aIsExtended = IsLineExtended(aCurrentLine, nppHelper, sciPtr); Tokenizer aTokenizer = new Tokenizer(aCurrentLine, nppHelper.GetLineStart(aCurrentLine, sciPtr), nppHelper, sciPtr, aIsExtended); foreach (var t in aTokenizer.Tokenize()) { if (t.BufferPosition <= position && t.EndPosition >= position) { return(t); } } } return(default(Tokenizer.TokenTag)); }
internal static bool IsLineExtended(int currentLine, INpp nppHelper, IntPtr sciPtr) { if (currentLine <= 0) { return(false); } else { //get previous line - if Scintilla loses focus we have an endless loop -> stack overflow think of a way to fix this... string aline = nppHelper.GetLine(--currentLine, sciPtr); if (String.IsNullOrWhiteSpace(aline)) { return(IsLineExtended(currentLine, nppHelper, sciPtr)); } else { char c = aline.TrimEnd().Last(); return(c == ',' || c == '[' || c == '\\'); } } }