mcpcpc / kirc

A tiny IRC client written in POSIX C99.

Home Page:https://mcpcpc.github.io/kirc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remember last command

cferrys opened this issue · comments

Hello,

First of all, congrats on your project. I certainly like it! hope to see it thriving in the upcoming years.

I was wondering whether you could add a feature where our last command is remembered. Ideally, we could re-run our last commands with the up-arrow + enter.

I'm uncertain if this is something too complex to implement?

Would certainly love to see it in kirc.c!

Have a great week.

absolutely! line history would definitely enhance the user experience. however, please see issue https://github.com/mcpcpc/kirc/issues/102 where i will be tracking closure of this issue.

@cferrys: I somewhat gave up on the previously mentioned issue in favor of smaller incremental changes. With that said, I am have a somewhat working implementation of the history buffer: https://github.com/mcpcpc/kirc/tree/0.2.5

There are some issues i am still working to resolve (e.g. how the history buffer increments/decrements values), but there should be no memory leaks or set faults at the very least least =). You are welcome to play around with it while I work out the bugs and let me know your thoughts.

hey mcpcpc!

Thanks for notifying me about the update.

Yes, it does seem to be that you are on the right track. However, it does seem to be that we can only keep one command at the time in the history_index buffer. It also seems to be that you are having a bit of a problem storing the last char on the last command.

In C++, something like this would do the the trick.

    std::multimap<time_t, std::string> cmds;

whereas you can keep a track of commands and when it was inserted, then a timer or so could delete the cmds buffer if there are too many commands in history.

Overall I like the progress, keep the hard work and let me know if you have some free time to fix the last letter from the l->buf when storing.

Have a great week.

Finally got around to debugging it. Try the latest commit to the 0.2.5 branch: c7f090e