This is simpler, as we do not have to worry about:
- randomly generating a unique here-doc tag to avoid
colliding with the yanked content
- newline munging as in 4a5dcd7557
- whether "sed -z" is portable (it's not in POSIX, though
I'd expect most modern implementations to have it)
This is the client side that matches the stdin handling
added in the previous commit. Note that we _don't_ check a
nativegate here. It's the responsibility of a caller sending
a non-empty content parameter to do so.
There's currently no way to tell the native messenger to
provide a particular stdin to a "run" command. This leads to
awkward uses of here-docs, which in turn require hacks like
the one in 4a5dcd7557.
Instead, let's take the "content" field from the message
body and feed that to the command's stdin, which gives us a
more robust channel for passing arbitrary bytes.
Note that we have to switch to using subprocess.Popen's
communicate() method, which will make sure we don't deadlock
if the input or output exceeds a pipe buffer.
Note also that when no stdin is provided by the caller
(i.e., all current cases), we'll pass an empty string. This
actually fixes a minor bug. Because we didn't override the
command's stdin argument, it's hooked to the messenger's
stdin, which is the pipe coming from firefox. If the command
tries to read, it (and the messenger) will hang forever,
since firefox is waiting for the messenger to respond before
writing anything else.
I bumped the native messenger version. This is mostly
backwards compatible (existing callers just don't send any
stdin content at all). But a caller that wants to send stdin
should check to make sure we have at least 0.1.7.
This makes debugging work correctly on Linux. Otherwise
you'll generally get EPERM as `/home/user\.tridactyl` is a
path in `/home`, which you likely don't have access to
write.
Apparently, Firefox can't give you key events for the window if <body>
is `display: none`. This is fixed by turning the page transparent
instead of not displaying it. Since the scrollbar is still visible when
the page is transparent, we also set the page's height to 0px.
All of these modifications are reversed when the page needs to be
displayed.
Mute takes a couple of arguments that are a bit loosely defined. `-u`
unmutes, as seen by the `unmute` exalias. `toggle` toggles between the
states. `all` applies `mute/unmute/toggle` on all the tabs in the current window.
Here-documents require a newline at the end of their content and there's
no way around it. In order to prevent the newline to be sent to the
clipboard command, we can do two things: not use here-documents or pipe
the content to sed first to remove the newline.
Not using here-documents means doing a lot of string manipulations to
escape the string properly. Using here-documents is conceptually
simpler.
Hence, we keep using here-documents and pipe the string to sed in order
to remove the newline.
This commit removes an if statement that is always true and a caching
optimization that can go wrong.
The caching optimization is the `if (!this.fuse)` statement. This
optimization can be buggy because it relies on this.options not
changing between two calls to scoredOptions but as far as I can tell,
this.options always changes between two scoredOptions calls.
If this.options changes, the array indexes used in searchThis do not
point to the right elements anymore and everything can break
(completions that should be matched disappear, completions with a lower
score get higher priority etc).
As far as I can tell, removing this optimization does not make
completions slower, but I couldn't test this with a large history.
The previous code called realFocus unconditionally. This fixed
https://github.com/cmcaine/tridactyl/issues/768 but broke
allowautofocus.
The new code makes sure to check the user's allowautofocus setting
before calling realFocus. I am not sure why it fixes#768 but I believe
it might be because bandcamp relies on synchronicity and that the
previous code used await.