aboutsummaryrefslogtreecommitdiffstats
path: root/vimput.pl
AgeCommit message (Collapse)Author
2017-12-16Get simple forking working without Vim & FIFO nonsenseTeddy Wing
Add a simple fork that creates a pipe between the parent and child processes so they can communicate with one another, passes a message from the child to the parent, and prints that message to the Irssi window. Thanks to these plugins which I used as invaluable examples: https://github.com/shabble/irssi-scripts/blob/master/feature-tests/pipes.pl https://github.com/irssi/scripts.irssi.org/blob/d62bb05a34ffd6d8d0f719c551d8e454880ef8e1/scripts/chansearch.pl https://github.com/irssi/scripts.irssi.org/blob/d62bb05a34ffd6d8d0f719c551d8e454880ef8e1/scripts/shortenurl.pl https://github.com/irssi/scripts.irssi.org/blob/d62bb05a34ffd6d8d0f719c551d8e454880ef8e1/scripts/dns.pl
2017-12-16FIFO sort of worksTeddy Wing
After a ton of trial and error, I have something that kind of works. Couldn't figure out forking for the moment, so this does block Irssi. And if you do something like change the window layout in Tmux with <prefix>-M-1, it messes up and closes the FIFO prematurely. Key points were: * Opening Vim before making the FIFO, otherwise Vim will block and not start. * Opening Vim with a random other file instead of the FIFO because it hasn't been created yet. On write, Vim is set up to write to the FIFO. Luckily chat messages don't get messed up when the interface blocks, but I'd like to fix that urgently.
2017-12-16Try to listen on a FIFO for the updated messageTeddy Wing
All kinds of things wrong with this, I'm just fiddling to try to see if I can get something to work. This blocks Irssi, which is bad. * Rename `tempfile` to `vimput_file` so as not to collide with the `tempfile()` function that creates a temporary file. * Add a new sub that ostensibly is supposed to read from a file handle and print the message received. Read https://github.com/shabble/irssi-docs/wiki/Guide#Dealing-with-Blocking-IO and https://github.com/shabble/irssi-scripts/blob/master/feature-tests/pipes.pl I feel like I have a better idea of how to deal with this using `fork`.
2017-12-15Take note of a possible message level to use for errorsTeddy Wing
2017-12-15Add a TODO to see if we can replace our signal with a commandTeddy Wing
2017-12-15Open a Tmux split with the prompt contentsTeddy Wing
After writing to the file, our keyboard shortcut opens a Tmux pane with a Vim and our input message available for editing. If we're not in Tmux, we should print an error message. Need to rewrite that to print a real Irssi message.
2017-12-15Write input contents on C-xTeddy Wing
Instead of writing the input message to a file on every key press, only write when Ctrl-X is pressed. This will be our command for opening Vim.
2017-12-15Write input contents on key pressTeddy Wing
Now instead of printing the current input to the Irssi window, write it to a script-specific file. The filename is inspired by Git. I figure we'll probably want to remove the file when we're done with it. Debated between creating a real temp file and using this one. We'll decide that later.
2017-12-15Make `$VERSION` and `%IRSSI` `our` variablesTeddy Wing
Learned about the Perl `our` keyword from https://github.com/shabble/irssi-docs/wiki/Guide#preamble which recommends using it. This allows us to eliminate the `use vars` line. Neat.
2017-12-15Print current input contentsTeddy Wing
Yes! Managed to read the current input line contents. Print this out on every key press. Thanks to these resources: Key press signal: https://github.com/shabble/irssi-docs/wiki/Signals#gui-readlinec Getting input line contents: https://github.com/shabble/irssi-docs/wiki/Irssi#getting-the-input-field-contents https://github.com/irssi/scripts.irssi.org/blob/master/scripts/per_window_prompt.pl