Giter Site home page Giter Site logo

Comments (14)

trdwll avatar trdwll commented on September 13, 2024

Sounds great. Would be very helpful for intellisense.

from scintillanet.

jacobslusser avatar jacobslusser commented on September 13, 2024

Can you explain it again... I'm not sure I get it. j/k

That's an interesting request. As a proof of concept you can try placing the following code in your Form (and Form_Load) event:

private System.Windows.Forms.Timer idleTimer;
public event EventHandler TextChangedDelayed;

private void form_Load(object sender, EventArgs e)
{
    // Wire the new event
    TextChangedDelayed += scintilla_TextChangedDelayed;

    idleTimer = new Timer() { Enabled = true, Interval = 1000 }; // 1 sec
    idleTimer.Tick += (s, ea) =>
    {
        // Stop tracking idle time
        idleTimer.Stop();

        // No text has changed in the last 1 sec; i.e. the user stopped
        // typing 1 sec ago. Fire the event.
        var handler = TextChangedDelayed;
        if (handler != null)
            handler(scintilla, EventArgs.Empty);
    };

    scintilla.TextChanged += (s, ea) =>
    {
        // Restart the timer each time the text changes so that the timer
        // tick event only fires when idle for 1 sec.
        idleTimer.Stop();
        idleTimer.Start();
    };
}

private void scintilla_TextChangedDelayed(object sender, EventArgs e)
{
    Debug.WriteLine("Time for a break...");
}

Are we sure we need this feature for all users? or is this more of a situation that is specific to you?

from scintillanet.

Ahmad45123 avatar Ahmad45123 commented on September 13, 2024

Yes, That should work.
Thanks for the hint.. I can just apply it in my IDE :P

And about the Are we sure we need this feature for all users? or is this more of a situation that is specific to you?

Well, I can't answer that :/
Its your choice.. But as I can see, This is a needed thing for any editor.

from scintillanet.

Ahmad45123 avatar Ahmad45123 commented on September 13, 2024

Did some tests and googles and found that .Stop fires the tick event when its called so its not very accurate... Because the counting is running on another thread.

Details: https://msdn.microsoft.com/en-us/library/system.timers.timer.stop%28v=vs.110%29.aspx

Will try and find a solution.

from scintillanet.

Ahmad45123 avatar Ahmad45123 commented on September 13, 2024

Okay.. Found a solution.

Since .Stop makes .Enabled to False, Just add this under .Tick event:

if (idleTimer.Enabled == false) return;

from scintillanet.

jacobslusser avatar jacobslusser commented on September 13, 2024

I'm confused, did you find a problem with the sample? If you chose to use the System.Timers.Timer be very careful because it executes on the ThreadPool and you might accidentally attempt to execute a UI call on a non-UI thread. I chose the System.Windows.Forms.Timer specifically because it will execute on the UI thread.

from scintillanet.

Ahmad45123 avatar Ahmad45123 commented on September 13, 2024

Yes.,. But actually I used System.Timers accidentally :P

Didn't know there is a difference.

I use VB.NET, that's why I didn't copy your example.
But I wrote my own code using the same idea.

Thanks though :)

from scintillanet.

jacobslusser avatar jacobslusser commented on September 13, 2024

I would strongly recommend against usingSystem.Timers.Timer for this purpose. The System.Windows.Forms.Timer is created specifically for doing what you want and will be thread-safe.

from scintillanet.

Ahmad45123 avatar Ahmad45123 commented on September 13, 2024

Actually I was already using Windows.Forms.Timer. :P
http://gyazo.com/ece676d72e5e9c12d2dd3aee438b5384
You can see the tooltip.
And same problem...

Maybe you mean vice versa ?

from scintillanet.

jacobslusser avatar jacobslusser commented on September 13, 2024

I'm still a little unclear on what your issue is... but if the issues is that the Tick event fires when you call Stop or that calling Stop will set the Enabled property to false, that is not what happens in my tests. When I use the System.Windows.Forms.Timer, calling Stop does NOT cause the Tick event to fire or the Enable property to change.

Regardless, if you found a solution for your problem that's great.

from scintillanet.

Ahmad45123 avatar Ahmad45123 commented on September 13, 2024

Okay.. It worked.
I am stupid, I was doing something wrong.. First time I had System.Timers imported.. thats why it bugged :P

Thanks for your help.
Hope it gets implemented though.

OffTopic:
Also, I need you to help me in a problem.. Are you free ?
Its not related to ScintillaNET.

from scintillanet.

jacobslusser avatar jacobslusser commented on September 13, 2024

You may contact me at "jslusser [dot] mobile [at] gmail [dot] com" if you would like to send me a personal message.

from scintillanet.

Ahmad45123 avatar Ahmad45123 commented on September 13, 2024

Can I know how lexers work ?

Does it store the code parts internally ?.. if yes can't you make that lists accessible ?

It would be a lot better then parsing the code twice :P

from scintillanet.

jacobslusser avatar jacobslusser commented on September 13, 2024

Internally character data and style data are stored in the same array. Each character is assigned a numeric value corresponding to a style index. For example, if you wanted to style "Hello" with style index 1 and "World" with style index 2, the internal representation would look like:

H1e1l1l1o1 0W2o2r2l2d2

That's a long way of saying, no, there isn't an easy way to split out the individual tokens. :)

from scintillanet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.