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.PtrToStringUtf8(scn.text, scn.length)
                    );

                //	These messages all get fired seperately hence the if else ifs
                if((modType & Constants.SC_MOD_BEFOREDELETE) > 0)
                    OnBeforeTextDelete(mea);
                else if((modType & Constants.SC_MOD_BEFOREINSERT) > 0)
                    OnBeforeTextInsert(mea);
                else if((modType & Constants.SC_MOD_DELETETEXT) > 0)
                    OnTextDeleted(mea);
                else if((modType & Constants.SC_MOD_INSERTTEXT) > 0)
                    OnTextInserted(mea);
            }
            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);
        }
Esempio n. 2
0
 protected virtual void OnDocumentChange(NativeScintillaEventArgs e)
 {
     if (Events[_documentChangeEventKey] != null)
         ((EventHandler<NativeScintillaEventArgs>)Events[_documentChangeEventKey])(this, e);
 }
        internal void FireMarginClick(NativeScintillaEventArgs ea)
        {
            if(Events[_marginClickEventKeyNative] != null)
                ((EventHandler<NativeScintillaEventArgs>)Events[_marginClickEventKeyNative])(this, ea);

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

            OnZoomChanged(EventArgs.Empty);
        }
 internal void FirePainted(NativeScintillaEventArgs ea)
 {
     if(Events[_paintedEventKey] != null)
         ((EventHandler<NativeScintillaEventArgs>)Events[_paintedEventKey])(this, ea);
 }
        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);
        }
 internal void FireDoubleClick(NativeScintillaEventArgs ea)
 {
     if(Events[_doubleClickEventKey] != null)
         ((EventHandler<NativeScintillaEventArgs>)Events[_doubleClickEventKey])(this, ea);
 }
        internal void FireDwellEnd(NativeScintillaEventArgs ea)
        {
            if(Events[_dwellEndEventKeyNative] != null)
                ((EventHandler<NativeScintillaEventArgs>)Events[_dwellEndEventKeyNative])(this, ea);

            OnDwellEnd(EventArgs.Empty);
        }
        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);
        }
        internal void FireCharAdded(NativeScintillaEventArgs ea)
        {
            if(Events[_charAddedEventKeyNative] != null)
                ((EventHandler<NativeScintillaEventArgs>)Events[_charAddedEventKeyNative])(this, ea);

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

            FireCallTipClick(ea.SCNotification.position);
        }
 internal void FireAutoCSelection(NativeScintillaEventArgs ea)
 {
     if (Events[_autoCSelectionEventKey] != null)
         ((EventHandler<NativeScintillaEventArgs>)Events[_autoCSelectionEventKey])(this, ea);
 }
Esempio n. 14
0
        protected override void WndProc(ref Message m)
        {
            if ((int)m.Msg == NativeMethods.WM_PAINT)
            {
                //	I tried toggling the ControlStyles.UserPaint flag and sending the message
                //	to both base.WndProc and DefWndProc in order to get the best of both worlds,
                //	Scintilla Paints as normal and .NET fires the Paint Event with the proper
                //	clipping regions and such. This didn't work too well, I kept getting weird
                //	phantom paints, or sometimes the .NET paint events would seem to get painted
                //	over by Scintilla. This technique I use below seems to work perfectly.

                base.WndProc(ref m);

                if(_isCustomPaintingEnabled)
                {
                    RECT r;
                    if (!NativeMethods.GetUpdateRect(Handle, out r, false))
                        r = ClientRectangle;

                    Graphics g = CreateGraphics();
                    g.SetClip(r);

                    OnPaint(new PaintEventArgs(CreateGraphics(), r));
                }
                return;
            }
            else if ((m.Msg) == NativeMethods.WM_DROPFILES)
            {
                handleFileDrop(m.WParam);
                return;
            }

            //	Uh-oh. Code based on undocumented unsupported .NET behavior coming up!
            //	Windows Forms Sends Notify messages back to the originating
            //	control ORed with 0x2000. This is way cool becuase we can listen for
            //	WM_NOTIFY messages originating form our own hWnd (from Scintilla)
            if ((m.Msg ^ 0x2000) != NativeMethods.WM_NOTIFY)
            {
                switch (m.Msg)
                {
                    case NativeMethods.WM_HSCROLL:
                    case NativeMethods.WM_VSCROLL:
                        FireScroll(ref m);

                        //	FireOnScroll calls WndProc so no need to call it again
                        return;
                }
                base.WndProc(ref m);
                return;
            }
            else if ((int)m.Msg >= 10000)
            {
                _commands.Execute((BindableCommand)m.Msg);
                return;
            }

            SCNotification scn				= (SCNotification)Marshal.PtrToStructure(m. LParam, typeof(SCNotification));
            NativeScintillaEventArgs nsea	= new NativeScintillaEventArgs(m, scn);

            switch(scn.nmhdr.code)
            {
                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;

            }

            base.WndProc(ref m);
        }
        internal void FireModifyAttemptRO(NativeScintillaEventArgs ea)
        {
            if(Events[_modifyAttemptROEventKey] != null)
                ((EventHandler<NativeScintillaEventArgs>)Events[_modifyAttemptROEventKey])(this, ea);

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

            OnDwellStart(new ScintillaMouseEventArgs(ea.SCNotification.x, ea.SCNotification.y, ea.SCNotification.position));
        }
        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));
        }
        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 FireSavePointReached(NativeScintillaEventArgs ea)
        {
            if(Events[_savePointReachedEventKeyNative] != null)
                ((EventHandler<NativeScintillaEventArgs>)Events[_savePointReachedEventKeyNative])(this, ea);

            OnSavePointReached(EventArgs.Empty);
        }
        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 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.
            OnSelectionChanged(EventArgs.Empty);
        }
 internal void FireIndicatorRelease(NativeScintillaEventArgs ea)
 {
     if (Events[_indicatorReleaseKeyNative] != null)
         ((EventHandler<NativeScintillaEventArgs>)Events[_indicatorReleaseKeyNative])(this, ea);
 }
 internal void FireUserListSelection(NativeScintillaEventArgs ea)
 {
     if(Events[_userListSelectionEventKeyNative] != null)
         ((EventHandler<NativeScintillaEventArgs>)Events[_userListSelectionEventKeyNative])(this, ea);
 }
        internal void FireMacroRecord(NativeScintillaEventArgs ea)
        {
            if(Events[_macroRecordEventKeyNative] != null)
                ((EventHandler<NativeScintillaEventArgs>)Events[_macroRecordEventKeyNative])(this, ea);

            OnMacroRecord(new MacroRecordEventArgs(ea));
        }
Esempio n. 25
0
		public MacroRecordEventArgs(NativeScintillaEventArgs ea)
		{
			_recordedMessage = ea.Msg;
			_recordedMessage.LParam = ea.SCNotification.lParam;
			_recordedMessage.WParam = ea.SCNotification.wParam;
		}
Esempio n. 26
0
 public MacroRecordEventArgs(NativeScintillaEventArgs ea)
 {
     _recordedMessage        = ea.Msg;
     _recordedMessage.LParam = ea.SCNotification.lParam;
     _recordedMessage.WParam = ea.SCNotification.wParam;
 }