Пример #1
0
 public MacroRecordEventArgs(NativeScintillaEventArgs ea)
 {
     _recordedMessage        = ea.Msg;
     _recordedMessage.LParam = ea.SCNotification.lParam;
     _recordedMessage.WParam = ea.SCNotification.wParam;
     // QuickSharp
     _notification = ea.SCNotification;
 }
Пример #2
0
 private void txtSnippet_DocumentChange(object sender, NativeScintillaEventArgs e)
 {
     ////	If for any reason the window DOES manage to hide itself
     ////	we merely reshow it.
     if (!txtSnippet.AutoComplete.IsActive && Visible)
     {
         int pos = Scintilla.Caret.Position;
         Scintilla.Caret.Goto(0);
         txtSnippet.AutoComplete.Show(0, _snippetList);
         Scintilla.Caret.Goto(pos);
     }
 }
Пример #3
0
 /// <summary>
 /// Raises the <see cref="DocumentChange"/> event.
 /// </summary>
 /// <param name="e">An <see cref="NativeScintillaEventArgs"/> that contains the event data.</param>
 protected virtual void OnDocumentChange(NativeScintillaEventArgs e)
 {
     EventHandler<NativeScintillaEventArgs> handler = Events[_documentChangeEventKey] as EventHandler<NativeScintillaEventArgs>;
     if (handler != null)
         handler(this, e);
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the MacroRecordEventArgs class.
 /// </summary>
 /// <param name="ea">NativeScintillaEventArgs object containing the message data</param>
 public MacroRecordEventArgs(NativeScintillaEventArgs ea)
 {
     _recordedMessage = ea.Msg;
     _recordedMessage.LParam = ea.SCNotification.lParam;
     _recordedMessage.WParam = ea.SCNotification.wParam;
 }
Пример #5
0
 /// <summary>
 /// Check if cursor is on a brace or not, highlighting if necessary
 /// </summary>
 private void Scintilla_NativeInterface_UpdateUI(object sender, NativeScintillaEventArgs e)
 {
     Scintilla scintilla = (Scintilla)sender;
       int pos = scintilla.CurrentPos;
       if (IsBrace(pos) || IsBrace(--pos))
       {
     int match = scintilla.NativeInterface.BraceMatch(pos, 0);
     if (match != -1)
       scintilla.NativeInterface.BraceHighlight(pos, match);
     else
       scintilla.NativeInterface.BraceBadLight(pos);
       }
       else
     scintilla.NativeInterface.BraceHighlight(-1, -1);
 }
		internal void FireIndicatorClick(NativeScintillaEventArgs ea)
		{
			if (Events[_indicatorClickKeyNative] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_indicatorClickKeyNative])(this, ea);

			OnIndicatorClick(new ScintillaMouseEventArgs(ea.SCNotification.x, ea.SCNotification.y, ea.SCNotification.position));
		}
		internal void FireCallTipClick(NativeScintillaEventArgs ea)
		{
			if(Events[_callTipClickEventKeyNative] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_callTipClickEventKeyNative])(this, ea);

			FireCallTipClick(ea.SCNotification.position);
		}
		internal void FireZoom(NativeScintillaEventArgs ea)
		{
			if(Events[_zoomEventKey] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_zoomEventKey])(this, ea);

			OnZoomChanged(EventArgs.Empty);
		}
		internal void FireUriDropped(NativeScintillaEventArgs ea)
		{
			if(Events[_uriDroppedEventKeyNative] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_uriDroppedEventKeyNative])(this, ea);
		}
		internal void FireModifyAttemptRO(NativeScintillaEventArgs ea)
		{
			if(Events[_modifyAttemptROEventKey] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_modifyAttemptROEventKey])(this, ea);

			OnReadOnlyModifyAttempt(EventArgs.Empty);
		}
		internal void FireSavePointLeft(NativeScintillaEventArgs ea)
		{
			if(Events[_savePointLeftEventKeyNative] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_savePointLeftEventKeyNative])(this, ea);

			// Update the local property (and if necessary raise the changed event)
			Modified = true;
		}
		internal void FireCharAdded(NativeScintillaEventArgs ea)
		{
			
			if(Events[_charAddedEventKeyNative] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_charAddedEventKeyNative])(this, ea);

			OnCharAdded(new CharAddedEventArgs(ea.SCNotification.ch));
		}
		internal void FireStyleNeeded(NativeScintillaEventArgs ea)
		{
			if(Events[_styleNeededEventKeyNative] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_styleNeededEventKeyNative])(this, ea);

			//	TODO: When this event fires it fires A LOT over and over again if
			//	you don't actually style the document. Additionally I'm making 2
			//	more calls to Scintilla to get the Start position of the style
			//	range. I need to come up with a good way to supress this logic
			//	unless the client app is actually interested in it. 

			//	Now that we've fired the Native event we do the same for the
			//	SourceEdit's StyleNeeded event. This code should look VERY familliar
			//	to anyone who's read the Scintilla Documentation
			int startPos	= _ns.GetEndStyled();
			int lineNumber	= _ns.LineFromPosition(startPos);
			startPos		= _ns.PositionFromLine(lineNumber);

			StyleNeededEventArgs snea = new StyleNeededEventArgs(new Range(startPos, ea.SCNotification.position, this));
			OnStyleNeeded(snea);
		}
Пример #14
0
        private void EditorView_DocumentChange(object sender, NativeScintillaEventArgs e)
        {
            //update line marging to suit the content
            const int LINENUMBER_MARGIN=0;
            const int STYLE_LINENUMBER = 33;
            int Ratio = (int)this.EditorView.Styles[STYLE_LINENUMBER].Font.Size;

            if (this.LineMarginWidth < Ratio * this.EditorView.Lines.Count.ToString().Length)
            {
                this.LineMarginWidth = Ratio * this.EditorView.Lines.Count.ToString().Length;
                this.EditorView.Margins[LINENUMBER_MARGIN].Width = this.LineMarginWidth+4;

            }
            //update the title to notify that the doc has changed
            if (this.EditorView.Modified)
            {
                if (!this.TabText.EndsWith(" *"))
                    TabText += " *";
            }
        }
		internal void FireDoubleClick(NativeScintillaEventArgs ea)
		{
			if(Events[_doubleClickEventKey] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_doubleClickEventKey])(this, ea);
		}
		internal void FireUserListSelection(NativeScintillaEventArgs ea)
		{
			if(Events[_userListSelectionEventKeyNative] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_userListSelectionEventKeyNative])(this, ea);
		}
		internal void FireUpdateUI(NativeScintillaEventArgs ea)
		{
			if (Events[_updateUIEventKey] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_updateUIEventKey])(this, ea);

			//	The SCN_UPDATEUI Notification message is sent whenever text, style or
			//	selection range changes. This means that the SelectionChangeEvent could
			//	potentially fire without the selection actually having changed. However
			//	I feel that it's important enough that SelectionChanged gets its own
			//	event.

			if (lastSelection.Start != this.Selection.Start
			|| lastSelection.End != this.Selection.End
			|| lastSelection.Length != this.Selection.Length)
			{
				OnSelectionChanged(EventArgs.Empty);
			}

			//I think the selection changed event should only be fired if the selection differs
			//from the selection values in the previous call to this function			
			//so here we take note of what the selection was last time 
			lastSelection.Start = this.Selection.Start;
			lastSelection.End = this.Selection.End;
			lastSelection.Length = this.Selection.Length;
		}
		internal void FireDwellEnd(NativeScintillaEventArgs ea)
		{
			if(Events[_dwellEndEventKeyNative] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_dwellEndEventKeyNative])(this, ea);

			OnDwellEnd(new ScintillaMouseEventArgs(ea.SCNotification.x, ea.SCNotification.y, ea.SCNotification.position));
		}
		internal void FireMacroRecord(NativeScintillaEventArgs ea)
		{
			if(Events[_macroRecordEventKeyNative] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_macroRecordEventKeyNative])(this, ea);

			OnMacroRecord(new MacroRecordEventArgs(ea));
		}
		internal void FireHotSpotDoubleclick(NativeScintillaEventArgs ea)
		{
			if(Events[_hotSpotDoubleClickEventKey] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_hotSpotDoubleClickEventKey])(this, ea);

			Point p = PointToClient(new Point(MousePosition.X, MousePosition.Y));
			OnHotspotDoubleClick(new ScintillaMouseEventArgs(p.X, p.Y, ea.SCNotification.position));
		}
		internal void FireMarginClick(NativeScintillaEventArgs ea)
		{
			if(Events[_marginClickEventKeyNative] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_marginClickEventKeyNative])(this, ea);

			FireMarginClick(ea.SCNotification);
		}
		internal void FireAutoCSelection(NativeScintillaEventArgs ea)
		{
			if (Events[_autoCSelectionEventKey] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_autoCSelectionEventKey])(this, ea);

			OnAutoCompleteAccepted(new AutoCompleteAcceptedEventArgs(ea.SCNotification, _encoding));
		}
		internal void FireModified(NativeScintillaEventArgs ea)
		{
			//	First we fire the INativeScintilla Modified event.
			if(Events[_modifiedEventKey] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_modifiedEventKey])(this, ea);

			//	Now we use raw information from the Modified event to construct
			//	some more user friendly Events to fire.
			SCNotification scn	= ea.SCNotification;
			int modType			= scn.modificationType;

			if((modType & TEXT_MODIFIED_FLAGS) > 0)
			{
				TextModifiedEventArgs mea = new TextModifiedEventArgs
					(
					modType,
					(modType & Constants.SC_PERFORMED_USER) != 0,
					scn.line,
					scn.position,
					scn.length,
					scn.linesAdded,
					Utilities.IntPtrToString(_encoding, scn.text, scn.length)
					);

				//	Adding in TextChanged because it's really common to 
				//	just want to know when the damned text changed
				bool textChanged = false;

				//	These messages all get fired seperately hence the if else ifs
				if ((modType & Constants.SC_MOD_BEFOREDELETE) > 0)
				{
					OnBeforeTextDelete(mea);
					textChanged = true;
				}
				else if ((modType & Constants.SC_MOD_BEFOREINSERT) > 0)
				{
					OnBeforeTextInsert(mea);
					textChanged = true;
				}
				else if ((modType & Constants.SC_MOD_DELETETEXT) > 0)
				{
					OnTextDeleted(mea);
					textChanged = true;
				}
				else if ((modType & Constants.SC_MOD_INSERTTEXT) > 0)
				{
					OnTextInserted(mea);
					textChanged = true;
				}

				if (textChanged)
				{
					_textChangedTimer.Start();
				}
			}
			else if((modType & Constants.SC_MOD_CHANGEFOLD) > 0)
			{
				FoldChangedEventArgs fea = new FoldChangedEventArgs(scn.line, scn.foldLevelNow, scn.foldLevelPrev, scn.modificationType);
				OnFoldChanged(fea);
			}
			else if((modType & Constants.SC_MOD_CHANGESTYLE) > 0)
			{
				StyleChangedEventArgs sea = new StyleChangedEventArgs(scn.position, scn.length, scn.modificationType);
				OnStyleChanged(sea);
			}
			else if((modType & Constants.SC_MOD_CHANGEMARKER) > 0)
			{
				MarkerChangedEventArgs mea = new MarkerChangedEventArgs(scn.line, scn.modificationType);
				OnMarkerChanged(mea);
			}

			OnDocumentChange(ea);
		}
		internal void FireIndicatorRelease(NativeScintillaEventArgs ea)
		{
			if (Events[_indicatorReleaseKeyNative] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_indicatorReleaseKeyNative])(this, ea);
		}
		internal void FireChange(NativeScintillaEventArgs ea)
		{
			if(Events[_changeEventKey] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_changeEventKey])(this, ea);

			//	This one is already defined for us
			OnTextChanged(EventArgs.Empty);
		}
Пример #26
0
 void Scintilla_UpdateUI(object sender, NativeScintillaEventArgs e)
 {
     DoBraceMatching();
     if (doShowAutocomplete)
     {
         string words = Regex.Replace(LuaFuncs, @"\s+", " ");
         words = Regex.Replace(words, @"^\s+", "");
         words = Regex.Replace(words, @"\s+$", "");
         words = Regex.Replace(words, @"\S+", @"${0}?1");
         ShowAutoComplete(0, words);
         doShowAutocomplete = false;
     }
 }
		internal void FireNeedShown(NativeScintillaEventArgs ea)
		{
			if(Events[_needShownEventKey] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_needShownEventKey])(this, ea);

			//	Again, this shoold look familiar...
			int pos			= ea.SCNotification.position;
			int firstLine	= _ns.LineFromPosition(pos);
			int lastLine	= _ns.LineFromPosition(pos + ea.SCNotification.length - 1);
			OnLinesNeedShown(new LinesNeedShownEventArgs(firstLine, lastLine));
		}
Пример #28
0
		private void txtSnippet_DocumentChange(object sender, NativeScintillaEventArgs e)
		{
			////	If for any reason the window DOES manage to hide itself
			////	we merely reshow it.
			if (!txtSnippet.AutoComplete.IsActive && Visible)
			{
				int pos = Scintilla.Caret.Position;
				Scintilla.Caret.Goto(0);
				txtSnippet.AutoComplete.Show(0, _snippetList);
				Scintilla.Caret.Goto(pos);
			}
		}
		internal void FirePainted(NativeScintillaEventArgs ea)
		{
			if(Events[_paintedEventKey] != null)
				((EventHandler<NativeScintillaEventArgs>)Events[_paintedEventKey])(this, ea);
		}
Пример #30
0
        private void ReflectNotify(ref Message m)
        {
            SCNotification scn = (SCNotification)Marshal.PtrToStructure(m.LParam, typeof(SCNotification));
            NativeScintillaEventArgs nsea = new NativeScintillaEventArgs(m, scn);

            switch (scn.nmhdr.code)
            {
                case Constants.SCN_AUTOCSELECTION:
                    FireAutoCSelection(nsea);
                    break;

                case Constants.SCN_CALLTIPCLICK:
                    FireCallTipClick(nsea);
                    break;

                case Constants.SCN_CHARADDED:
                    FireCharAdded(nsea);
                    break;

                case Constants.SCEN_CHANGE:
                    FireChange(nsea);
                    break;

                case Constants.SCN_DOUBLECLICK:
                    FireDoubleClick(nsea);
                    break;

                case Constants.SCN_DWELLEND:
                    FireDwellEnd(nsea);
                    break;

                case Constants.SCN_DWELLSTART:
                    FireDwellStart(nsea);
                    break;

                case Constants.SCN_HOTSPOTCLICK:
                    FireHotSpotClick(nsea);
                    break;

                case Constants.SCN_HOTSPOTDOUBLECLICK:
                    FireHotSpotDoubleclick(nsea);
                    break;

                case Constants.SCN_INDICATORCLICK:
                    FireIndicatorClick(nsea);
                    break;

                case Constants.SCN_INDICATORRELEASE:
                    FireIndicatorRelease(nsea);
                    break;

                case Constants.SCN_KEY:
                    FireKey(nsea);
                    break;

                case Constants.SCN_MACRORECORD:
                    FireMacroRecord(nsea);
                    break;

                case Constants.SCN_MARGINCLICK:
                    FireMarginClick(nsea);
                    break;

                case Constants.SCN_MODIFIED:
                    FireModified(nsea);
                    break;

                case Constants.SCN_MODIFYATTEMPTRO:
                    FireModifyAttemptRO(nsea);
                    break;

                case Constants.SCN_NEEDSHOWN:
                    FireNeedShown(nsea);
                    break;

                case Constants.SCN_PAINTED:
                    FirePainted(nsea);
                    break;

                case Constants.SCN_SAVEPOINTLEFT:
                    FireSavePointLeft(nsea);
                    break;

                case Constants.SCN_SAVEPOINTREACHED:
                    FireSavePointReached(nsea);
                    break;

                case Constants.SCN_STYLENEEDED:
                    FireStyleNeeded(nsea);
                    break;

                case Constants.SCN_UPDATEUI:
                    FireUpdateUI(nsea);
                    break;

                case Constants.SCN_URIDROPPED:
                    FireUriDropped(nsea);
                    break;

                case Constants.SCN_USERLISTSELECTION:
                    FireUserListSelection(nsea);
                    break;

                case Constants.SCN_ZOOM:
                    FireZoom(nsea);
                    break;

            }
        }
Пример #31
0
 private void editor_DocumentChange(object sender, NativeScintillaEventArgs e)
 {
     modifiedDocument = true;
 }