Silence bells caused by cursor movement after click at prompt
This commit is contained in:
parent
3c3e97aa6e
commit
10fbf36e92
@ -969,6 +969,9 @@ class Screen:
|
|||||||
def cursor_at_prompt(self) -> bool:
|
def cursor_at_prompt(self) -> bool:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def ignore_bells_for(self, duration: float = 1) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
def current_key_encoding_flags(self) -> int:
|
def current_key_encoding_flags(self) -> int:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@ -1699,6 +1699,14 @@ screen_invert_colors(Screen *self) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
screen_bell(Screen *self) {
|
screen_bell(Screen *self) {
|
||||||
|
if (self->ignore_bells.start) {
|
||||||
|
monotonic_t now = monotonic();
|
||||||
|
if (now < self->ignore_bells.start + self->ignore_bells.duration) {
|
||||||
|
self->ignore_bells.start = now;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self->ignore_bells.start = 0;
|
||||||
|
}
|
||||||
request_window_attention(self->window_id, OPT(enable_audio_bell));
|
request_window_attention(self->window_id, OPT(enable_audio_bell));
|
||||||
if (OPT(visual_bell_duration) > 0.0f) self->start_visual_bell_at = monotonic();
|
if (OPT(visual_bell_duration) > 0.0f) self->start_visual_bell_at = monotonic();
|
||||||
CALLBACK("on_bell", NULL);
|
CALLBACK("on_bell", NULL);
|
||||||
@ -2818,6 +2826,15 @@ current_key_encoding_flags(Screen *self, PyObject *args UNUSED) {
|
|||||||
return PyLong_FromUnsignedLong(ans);
|
return PyLong_FromUnsignedLong(ans);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject*
|
||||||
|
ignore_bells_for(Screen *self, PyObject *args) {
|
||||||
|
double duration = 1;
|
||||||
|
if (!PyArg_ParseTuple(args, "|d", &duration)) return NULL;
|
||||||
|
self->ignore_bells.start = monotonic();
|
||||||
|
self->ignore_bells.duration = s_double_to_monotonic_t(duration);
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
start_selection(Screen *self, PyObject *args) {
|
start_selection(Screen *self, PyObject *args) {
|
||||||
unsigned int x, y;
|
unsigned int x, y;
|
||||||
@ -3557,6 +3574,7 @@ static PyMethodDef methods[] = {
|
|||||||
MND(reverse_index, METH_NOARGS)
|
MND(reverse_index, METH_NOARGS)
|
||||||
MND(mark_as_dirty, METH_NOARGS)
|
MND(mark_as_dirty, METH_NOARGS)
|
||||||
MND(resize, METH_VARARGS)
|
MND(resize, METH_VARARGS)
|
||||||
|
MND(ignore_bells_for, METH_VARARGS)
|
||||||
MND(set_margins, METH_VARARGS)
|
MND(set_margins, METH_VARARGS)
|
||||||
MND(detect_url, METH_VARARGS)
|
MND(detect_url, METH_VARARGS)
|
||||||
MND(rescale_images, METH_NOARGS)
|
MND(rescale_images, METH_NOARGS)
|
||||||
|
|||||||
@ -128,6 +128,9 @@ typedef struct {
|
|||||||
ANSIBuf as_ansi_buf;
|
ANSIBuf as_ansi_buf;
|
||||||
char_type last_graphic_char;
|
char_type last_graphic_char;
|
||||||
uint8_t main_key_encoding_flags[8], alt_key_encoding_flags[8], *key_encoding_flags;
|
uint8_t main_key_encoding_flags[8], alt_key_encoding_flags[8], *key_encoding_flags;
|
||||||
|
struct {
|
||||||
|
monotonic_t start, duration;
|
||||||
|
} ignore_bells;
|
||||||
} Screen;
|
} Screen;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -11,9 +11,10 @@ from enum import IntEnum
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
from time import monotonic
|
||||||
from typing import (
|
from typing import (
|
||||||
Any, Callable, Deque, Dict, Iterable, List, NamedTuple, Optional, Pattern,
|
TYPE_CHECKING, Any, Callable, Deque, Dict, Iterable, List, NamedTuple,
|
||||||
Sequence, Tuple, Union, TYPE_CHECKING
|
Optional, Pattern, Sequence, Tuple, Union
|
||||||
)
|
)
|
||||||
|
|
||||||
from .child import ProcessDesc
|
from .child import ProcessDesc
|
||||||
@ -931,6 +932,7 @@ class Window:
|
|||||||
break
|
break
|
||||||
if a == 'prompt':
|
if a == 'prompt':
|
||||||
if move_cursor_to_mouse_if_in_prompt(self.os_window_id, self.tab_id, self.id):
|
if move_cursor_to_mouse_if_in_prompt(self.os_window_id, self.tab_id, self.id):
|
||||||
|
self.screen.ignore_bells_for(1)
|
||||||
break
|
break
|
||||||
|
|
||||||
@ac('mouse', 'Click the URL under the mouse')
|
@ac('mouse', 'Click the URL under the mouse')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user