alltom
11/24/2019, 7:45 PMGary Trakhman
11/24/2019, 8:03 PMalltom
11/24/2019, 8:39 PMDan Cook
11/24/2019, 8:43 PMEdward de Jong / Beads Project
11/24/2019, 11:12 PMwtaysom
11/25/2019, 2:01 AMyoshiki
11/25/2019, 4:25 AMEdward de Jong / Beads Project
11/25/2019, 5:35 AMEdward de Jong / Beads Project
11/25/2019, 6:09 AMDoug Moen
11/25/2019, 2:53 PMDoug Moen
11/25/2019, 2:59 PMshalabh
11/26/2019, 5:24 AMalltom
11/28/2019, 6:08 AM9p read [path]
and 9p write [path]
.
So given any interface problem, you can attack it in a variety of ways:
• Make a program that the user invokes, whose input is the current selection and/or whose output overwrites the current selection.
• Make a program that controls Acme from afar with the network protocol.
• Combination of the first two.
And it's remarkably simple. Like, here's a shell script that you can use as your $EDITOR that opens a file in a new Acme window, adding "Cancel" and "Done" commands to the UI that dictate the exit code and whether it saves:
#!/bin/bash
filename="$1"
winid=$(echo $(9p read acme/new/ctl) | cut -d ' ' -f 1)
# Open the file
echo name $filename | 9p write acme/$winid/ctl
echo get | 9p write acme/$winid/ctl
# Add commands to the tag line
echo -n Cancel Done | 9p write acme/$winid/tag
9p read acme/$winid/event 2> /dev/null | while read -r line; do
cmd=$(echo $line | cut -d ' ' -f 5)
if [ "$cmd" == "Cancel" ]; then
# Mark the file clean
echo clean | 9p write acme/$winid/ctl
# Close the window
echo del | 9p write acme/$winid/ctl
exit 1
fi
if [ "$cmd" == "Done" ]; then
# Write the file
echo put | 9p write acme/$winid/ctl
# Close the window
echo del | 9p write acme/$winid/ctl
exit
fi
done
The whole thing might be complex to implement for the editor devs, but there are obvious compromises that would make it easy, and probably still be infinitely better than an API that consists entirely of command-line arguments and SIGINT. 😅 If it ever doesn't seem worth it, consider threads like this: https://twitter.com/geoffreylitt/status/1178806585289773056