urwid 5.1.0__tar.gz → 5.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {urwid-5.1.0 → urwid-5.1.2}/.devcontainer/dev.dockerfile +19 -1
- {urwid-5.1.0 → urwid-5.1.2}/.devcontainer/devcontainer.json +3 -4
- urwid-5.1.2/.devcontainer/docs-pdf/devcontainer.json +10 -0
- urwid-5.1.2/.github/workflows/documentation-pdf.yml +42 -0
- {urwid-5.1.0 → urwid-5.1.2}/PKG-INFO +1 -1
- urwid-5.1.2/mypy-requirements.txt +2 -0
- urwid-5.1.2/pyrefly-requirements.txt +2 -0
- {urwid-5.1.0 → urwid-5.1.2}/pytest_requirements.txt +1 -1
- {urwid-5.1.0 → urwid-5.1.2}/urwid/__init__.py +2 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/canvas.py +32 -8
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/_web_common.js +11 -6
- urwid-5.1.2/urwid/display/_websocket.css +7 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/_websocket.html +1 -1
- urwid-5.1.2/urwid/display/_websocket.js +241 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/curses.py +10 -2
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/escape.py +29 -6
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/web.py +1 -1
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/websocket.py +161 -28
- {urwid-5.1.0 → urwid-5.1.2}/urwid/event_loop/asyncio_loop.py +11 -8
- {urwid-5.1.0 → urwid-5.1.2}/urwid/event_loop/select_loop.py +23 -11
- {urwid-5.1.0 → urwid-5.1.2}/urwid/event_loop/trio_loop.py +1 -1
- {urwid-5.1.0 → urwid-5.1.2}/urwid/testing.py +265 -9
- {urwid-5.1.0 → urwid-5.1.2}/urwid/version.py +3 -3
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/__init__.py +2 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/columns.py +14 -6
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/constants.py +60 -1
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/container.py +80 -5
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/divider.py +33 -1
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/filler.py +51 -29
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/frame.py +200 -57
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/grid_flow.py +14 -5
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/listbox.py +235 -11
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/notifications.py +1 -2
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/overlay.py +44 -7
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/overlay_stack.py +4 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/pile.py +14 -6
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/scrollable.py +102 -17
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/spinner.py +13 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/table.py +268 -60
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/tabs.py +63 -9
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/treetools.py +38 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/widget.py +232 -8
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/wimp.py +145 -7
- {urwid-5.1.0 → urwid-5.1.2}/urwid.egg-info/PKG-INFO +1 -1
- {urwid-5.1.0 → urwid-5.1.2}/urwid.egg-info/SOURCES.txt +2 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid.egg-info/scm_file_list.json +16 -0
- urwid-5.1.2/urwid.egg-info/scm_version.json +8 -0
- urwid-5.1.0/mypy-requirements.txt +0 -2
- urwid-5.1.0/pyrefly-requirements.txt +0 -2
- urwid-5.1.0/urwid/display/_websocket.css +0 -3
- urwid-5.1.0/urwid/display/_websocket.js +0 -82
- urwid-5.1.0/urwid.egg-info/scm_version.json +0 -8
- {urwid-5.1.0 → urwid-5.1.2}/.dockerignore +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.editorconfig +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.github/CODE_OF_CONDUCT.md +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.github/ISSUE_TEMPLATE/docs.md +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.github/ISSUE_TEMPLATE/question.md +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.github/dependabot.yml +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.github/labeler.yml +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.github/release.yml +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.github/workflows/documentation.yml +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.github/workflows/isolated_mypy.yml +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.github/workflows/isolated_pylint.yml +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.github/workflows/isolated_pyrefly.yml +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.github/workflows/labels.yml +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.github/workflows/pythonpackage.yml +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.github/workflows/yamllint.yml +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.gitignore +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.pre-commit-config.yaml +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/.yamllint.yml +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/COPYING +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/MANIFEST.in +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/README.rst +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/SECURITY.md +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/classifiers.txt +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/conftest.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/pylint-requirements.txt +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/pyproject.toml +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/requirements.txt +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/setup.cfg +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/tox.ini +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/_deprecation.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/_selectors.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/ansi_parser.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/command_map.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/__init__.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/_posix_raw_display.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/_raw_display_base.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/_web.css +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/_web.js +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/_web_common.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/_win32.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/_win32_raw_display.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/common.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/html_fragment.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/lcd.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/display/raw.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/event_loop/__init__.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/event_loop/abstract_loop.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/event_loop/glib_loop.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/event_loop/guarded_loop.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/event_loop/main_loop.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/event_loop/tornado_loop.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/event_loop/twisted_loop.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/event_loop/zmq_loop.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/font.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/graphics.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/numedit.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/py.typed +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/signals.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/split_repr.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/str_util.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/text_layout.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/util.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/vterm.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/ansi_text.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/attr_map.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/attr_wrap.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/bar_graph.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/big_text.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/box_adapter.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/deque_walker.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/drop_down.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/edit.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/filtered_walker.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/line_box.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/list_walker.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/monitored_deque.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/monitored_list.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/padding.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/popup.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/progress_bar.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/solid_fill.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/text.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid/widget/widget_decoration.py +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid.egg-info/dependency_links.txt +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid.egg-info/not-zip-safe +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid.egg-info/requires.txt +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/urwid.egg-info/top_level.txt +0 -0
- {urwid-5.1.0 → urwid-5.1.2}/yamllint-requirements.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
FROM ubuntu:26.04
|
|
1
|
+
FROM ubuntu:26.04 AS dev
|
|
2
2
|
RUN apt-get update -y \
|
|
3
3
|
&& apt-get upgrade -y \
|
|
4
4
|
&& apt-get install -y \
|
|
@@ -36,3 +36,21 @@ ENV LC_ALL=C.UTF-8
|
|
|
36
36
|
# exist with these permissions before it can create its socket; a
|
|
37
37
|
# non-root container user can't create it itself.
|
|
38
38
|
RUN mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix
|
|
39
|
+
|
|
40
|
+
# The PDF documentation, built by docs/tools/build_pdf.sh: LuaLaTeX, latexmk
|
|
41
|
+
# and the LaTeX packages Sphinx uses, with FreeFont for the text. The fonts
|
|
42
|
+
# installed above are the fallbacks docs/conf.py names for the box-drawing,
|
|
43
|
+
# CJK, emoji and symbol characters. xindy builds the index for LuaLaTeX.
|
|
44
|
+
# .github/workflows/documentation-pdf.yml installs the same packages; a
|
|
45
|
+
# change to one list is made to the other.
|
|
46
|
+
FROM dev AS docs-pdf
|
|
47
|
+
RUN apt-get update -y \
|
|
48
|
+
&& apt-get install -y --no-install-recommends \
|
|
49
|
+
latexmk \
|
|
50
|
+
texlive-luatex \
|
|
51
|
+
texlive-latex-recommended \
|
|
52
|
+
texlive-latex-extra \
|
|
53
|
+
texlive-fonts-recommended \
|
|
54
|
+
xindy \
|
|
55
|
+
fonts-freefont-otf \
|
|
56
|
+
&& apt-get clean
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"build": {
|
|
3
|
-
"dockerfile": "dev.dockerfile"
|
|
3
|
+
"dockerfile": "dev.dockerfile",
|
|
4
|
+
"target": "dev"
|
|
4
5
|
},
|
|
5
6
|
"features": {
|
|
6
7
|
"ghcr.io/devcontainers/features/github-cli": {}
|
|
@@ -32,7 +33,5 @@
|
|
|
32
33
|
"init": true,
|
|
33
34
|
"postCreateCommand": "uv venv /home/ubuntu/.venv-urwid && uv sync --all-groups",
|
|
34
35
|
"postStartCommand": "uv sync --all-groups --all-extras",
|
|
35
|
-
"mounts": [
|
|
36
|
-
"source=${localEnv:HOME}/.ssh,target=/home/ubuntu/.ssh,type=bind,readonly"
|
|
37
|
-
]
|
|
36
|
+
"mounts": ["source=${localEnv:HOME}/.ssh,target=/home/ubuntu/.ssh,type=bind,readonly"]
|
|
38
37
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: Documentation PDF
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch: # started by hand: a full TeX Live install is too slow for every push
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
PDF:
|
|
8
|
+
runs-on: ubuntu-26.04 # the release .devcontainer/dev.dockerfile is based on
|
|
9
|
+
steps:
|
|
10
|
+
- uses: actions/checkout@v7
|
|
11
|
+
with:
|
|
12
|
+
fetch-depth: 0 # need for setuptools_scm
|
|
13
|
+
# The same packages as the dev and docs-pdf stages of .devcontainer/dev.dockerfile need for the PDF build;
|
|
14
|
+
# a change to one list is made to the other.
|
|
15
|
+
- name: Install LaTeX, fonts and GLib build dependencies
|
|
16
|
+
run: |
|
|
17
|
+
sudo apt-get -qq update
|
|
18
|
+
sudo apt-get install -y --no-install-recommends \
|
|
19
|
+
latexmk \
|
|
20
|
+
texlive-luatex \
|
|
21
|
+
texlive-latex-recommended \
|
|
22
|
+
texlive-latex-extra \
|
|
23
|
+
texlive-fonts-recommended \
|
|
24
|
+
xindy \
|
|
25
|
+
fonts-freefont-otf \
|
|
26
|
+
fonts-dejavu-core \
|
|
27
|
+
fonts-noto-core \
|
|
28
|
+
fonts-noto-cjk \
|
|
29
|
+
fonts-noto-color-emoji \
|
|
30
|
+
python3-dev \
|
|
31
|
+
gobject-introspection \
|
|
32
|
+
gir1.2-glib-2.0 \
|
|
33
|
+
libgirepository-2.0-dev \
|
|
34
|
+
libcairo2-dev
|
|
35
|
+
- name: Install uv
|
|
36
|
+
uses: astral-sh/setup-uv@v10.3.3
|
|
37
|
+
- name: Build PDF documentation
|
|
38
|
+
run: docs/tools/build_pdf.sh
|
|
39
|
+
- uses: actions/upload-artifact@v7
|
|
40
|
+
with:
|
|
41
|
+
path: build/pdf/latex/Urwid.pdf
|
|
42
|
+
name: documentation-pdf
|
|
@@ -249,6 +249,7 @@ from .widget import (
|
|
|
249
249
|
WidgetError,
|
|
250
250
|
WidgetMeta,
|
|
251
251
|
WidgetPlaceholder,
|
|
252
|
+
WidgetSizingError,
|
|
252
253
|
WidgetWrap,
|
|
253
254
|
WidgetWrapError,
|
|
254
255
|
WrapMode,
|
|
@@ -440,6 +441,7 @@ __all__: tuple[str, ...] = (
|
|
|
440
441
|
"WidgetError",
|
|
441
442
|
"WidgetMeta",
|
|
442
443
|
"WidgetPlaceholder",
|
|
444
|
+
"WidgetSizingError",
|
|
443
445
|
"WidgetWrap",
|
|
444
446
|
"WidgetWrapError",
|
|
445
447
|
"WrapMode",
|
|
@@ -525,14 +525,35 @@ class TextCanvas(Canvas):
|
|
|
525
525
|
) -> None:
|
|
526
526
|
"""Build a text canvas from the given lines and attributes.
|
|
527
527
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
528
|
+
Each line of *text* is padded with spaces to *maxcol* columns.
|
|
529
|
+
*attr* and *cs* hold one list of runs per line.
|
|
530
|
+
A run is a ``(value, length)`` tuple that applies *value* to the next *length* bytes of the line.
|
|
531
|
+
The runs of a line cover it from its first byte, and their lengths add up to at most the padded line's length.
|
|
532
|
+
The bytes after the last run, and every line with no list of runs, get ``None``:
|
|
533
|
+
the default attribute, or the default character set.
|
|
534
|
+
|
|
535
|
+
For example, ``attr=[[("bold", 3), ("red", 2)], [("blue", 4)]]`` with ``text=[b"foobar", b"test string"]``
|
|
536
|
+
shows ``foo`` as ``bold``, ``ba`` as ``red``, ``r`` with the default attribute, ``test`` as ``blue``,
|
|
537
|
+
and the rest of the second line with the default attribute:
|
|
538
|
+
|
|
539
|
+
>>> canvas = TextCanvas([b"foobar", b"test string"], [[("bold", 3), ("red", 2)], [("blue", 4)]])
|
|
540
|
+
>>> [[(a, text) for a, _cs, text in row] for row in canvas.content()]
|
|
541
|
+
[[('bold', b'foo'), ('red', b'ba'), (None, b'r ')], [('blue', b'test'), (None, b' string')]]
|
|
542
|
+
|
|
543
|
+
:param text: lines of text, encoded in the screen's encoding (see :func:`urwid.set_encoding`)
|
|
544
|
+
:param attr: runs of display attributes for each line:
|
|
545
|
+
palette entry names, :class:`AttrSpec` or :class:`LayeredAttr` values, or ``None`` for the default attribute
|
|
546
|
+
:param cs: runs of character sets for each line:
|
|
547
|
+
|
|
548
|
+
- ``"0"``: the DEC special graphics set, in a non-UTF-8 encoding.
|
|
549
|
+
- ``"U"``: bytes written unchanged, without filtering control characters;
|
|
550
|
+
in a non-UTF-8 encoding, also the IBM PC character set.
|
|
551
|
+
- ``None``: the default set.
|
|
531
552
|
:param cursor: (x,y) of cursor or None
|
|
532
553
|
:param maxcol: screen columns taken by this canvas
|
|
533
554
|
:param check_width: check and fix width of all lines in text
|
|
534
555
|
:raises CanvasError: a line of *text* is not a plain string in the screen encoding, is wider than *maxcol*, or
|
|
535
|
-
has an attribute or character set run extending beyond its text.
|
|
556
|
+
has an attribute or character set run extending beyond its padded text.
|
|
536
557
|
:raises TypeError: *maxcol* is not an integer.
|
|
537
558
|
"""
|
|
538
559
|
super().__init__()
|
|
@@ -560,10 +581,13 @@ class TextCanvas(Canvas):
|
|
|
560
581
|
else:
|
|
561
582
|
maxcol = 0
|
|
562
583
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
if
|
|
566
|
-
|
|
584
|
+
# content() pairs each line with its runs, so a line with no list of runs would be left out of it
|
|
585
|
+
attr = attr or []
|
|
586
|
+
if len(attr) < len(text):
|
|
587
|
+
attr = [*attr, *([] for _ in range(len(text) - len(attr)))]
|
|
588
|
+
cs = cs or []
|
|
589
|
+
if len(cs) < len(text):
|
|
590
|
+
cs = [*cs, *([] for _ in range(len(text) - len(cs)))]
|
|
567
591
|
|
|
568
592
|
# pad text and attr to maxcol
|
|
569
593
|
for i, (w, a_row, cs_row) in enumerate(zip(widths, attr, cs, strict=False)):
|
|
@@ -129,19 +129,24 @@ function key_name(e) {
|
|
|
129
129
|
return null; // modifier or a key urwid has no name for
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
//
|
|
133
|
-
function
|
|
132
|
+
// Return the size of one character cell in pixels, as [width, height].
|
|
133
|
+
function char_size() {
|
|
134
134
|
const t = document.getElementById('testchar');
|
|
135
135
|
const t2 = document.getElementById('testchar2');
|
|
136
|
+
return [t.offsetLeft / 44, t2.offsetTop - t.offsetTop];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Fit the text area to the window in whole characters, at most max_cols by max_rows,
|
|
140
|
+
// and return its size in [columns, rows].
|
|
141
|
+
function measure_screen(max_cols = Infinity, max_rows = Infinity) {
|
|
136
142
|
const text = document.getElementById('text');
|
|
143
|
+
const [char_width, char_height] = char_size();
|
|
137
144
|
|
|
138
|
-
const char_width = t.offsetLeft / 44;
|
|
139
145
|
const avail_width = window.innerWidth - 18;
|
|
140
|
-
const x_size = (avail_width - (avail_width % char_width)) / char_width;
|
|
146
|
+
const x_size = Math.min((avail_width - (avail_width % char_width)) / char_width, max_cols);
|
|
141
147
|
|
|
142
|
-
const char_height = t2.offsetTop - t.offsetTop;
|
|
143
148
|
const avail_height = window.innerHeight - text.offsetTop - 10;
|
|
144
|
-
const y_size = (avail_height - (avail_height % char_height)) / char_height;
|
|
149
|
+
const y_size = Math.min((avail_height - (avail_height % char_height)) / char_height, max_rows);
|
|
145
150
|
|
|
146
151
|
text.style.width = x_size * char_width + "px";
|
|
147
152
|
text.style.height = y_size * char_height + "px";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/* Added to _web.css for the WebSocket page, which has no inline styles. */
|
|
2
|
+
|
|
3
|
+
.measure { position: absolute; visibility: hidden; }
|
|
4
|
+
|
|
5
|
+
/* The pointer on the screen goes to the application, not to scrolling or zooming the page. */
|
|
6
|
+
/* It also cannot start a text selection, which a drag inside the application would otherwise do. */
|
|
7
|
+
#text { touch-action: none; user-select: none; }
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<script src="web_common.js" defer></script>
|
|
9
9
|
<script src="websocket.js" defer></script>
|
|
10
10
|
</head>
|
|
11
|
-
<body data-websocket-path="$websocket_path">
|
|
11
|
+
<body data-websocket-path="$websocket_path" data-max-cols="$max_cols" data-max-rows="$max_rows">
|
|
12
12
|
<div class="measure">
|
|
13
13
|
<pre>The quick brown fox jumps over the lazy dog.<span id="testchar">X</span>
|
|
14
14
|
<span id="testchar2">Y</span></pre>
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
// Urwid WebSocket display: the page script's connection to urwid.display.websocket.Screen
|
|
2
|
+
|
|
3
|
+
// Loaded after web_common.js, whose rendering and key names it uses.
|
|
4
|
+
// Every message the server sends is a screen update in the row format of render_update().
|
|
5
|
+
// The page sends JSON messages: {"type": "key", "key": <name>}, {"type": "resize", "cols": <n>, "rows": <n>}
|
|
6
|
+
// and {"type": "mouse", "event": <name>, "button": <n>, "col": <n>, "row": <n>}.
|
|
7
|
+
|
|
8
|
+
"use strict";
|
|
9
|
+
|
|
10
|
+
const check_font_delay = 1000;
|
|
11
|
+
|
|
12
|
+
let socket = null;
|
|
13
|
+
let screen_x = null;
|
|
14
|
+
let screen_y = null;
|
|
15
|
+
|
|
16
|
+
// urwid's button numbers for MouseEvent.button: left, middle, right, back, forward
|
|
17
|
+
const mouse_buttons = [1, 2, 3, 8, 9];
|
|
18
|
+
// the MouseEvent.buttons bit of each MouseEvent.button value
|
|
19
|
+
const button_bits = [1, 4, 2, 8, 16];
|
|
20
|
+
// the urwid number of the button held down, which drag and release events report, or null
|
|
21
|
+
let pressed_button = null;
|
|
22
|
+
// the MouseEvent.buttons bit of that button, and the pointer that pressed it
|
|
23
|
+
let pressed_bit = 0;
|
|
24
|
+
let pressed_pointer = null;
|
|
25
|
+
// the cell of the last press or drag, so a drag is sent only when the pointer reaches another cell
|
|
26
|
+
let last_cell = null;
|
|
27
|
+
|
|
28
|
+
// the wheel distance of one step, in lines of text; one notch of a mouse wheel is about this or more
|
|
29
|
+
const wheel_lines = 3;
|
|
30
|
+
// the wheel distance not sent yet, so the small steps of a touchpad add up to whole steps
|
|
31
|
+
let wheel_x = 0;
|
|
32
|
+
let wheel_y = 0;
|
|
33
|
+
|
|
34
|
+
function websocket_url() {
|
|
35
|
+
const url = new URL(document.body.dataset.websocketPath, window.location.href);
|
|
36
|
+
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
37
|
+
return url;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function send_message(message) {
|
|
41
|
+
if (socket !== null && socket.readyState === WebSocket.OPEN) {
|
|
42
|
+
socket.send(JSON.stringify(message));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function on_keydown(e) {
|
|
47
|
+
if (socket === null) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const name = key_event_name(e);
|
|
51
|
+
if (name === null) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
e.stopPropagation();
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
send_message({type: "key", key: name});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// The modifier prefix of a mouse event name, in the order urwid writes it.
|
|
60
|
+
function mouse_modifiers(e) {
|
|
61
|
+
let mod = "";
|
|
62
|
+
if (e.shiftKey) { mod += "shift "; }
|
|
63
|
+
if (e.altKey || e.metaKey) { mod += "meta "; }
|
|
64
|
+
if (e.ctrlKey) { mod += "ctrl "; }
|
|
65
|
+
return mod;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// The screen cell under the pointer, as [column, row]; it may be outside the screen.
|
|
69
|
+
function mouse_cell(e) {
|
|
70
|
+
const [char_width, char_height] = char_size();
|
|
71
|
+
const text = document.getElementById('text');
|
|
72
|
+
const rect = text.getBoundingClientRect();
|
|
73
|
+
// the rows start inside the border of the text area
|
|
74
|
+
const x = e.clientX - rect.left - text.clientLeft;
|
|
75
|
+
const y = e.clientY - rect.top - text.clientTop;
|
|
76
|
+
return [Math.floor(x / char_width), Math.floor(y / char_height)];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function inside_screen(cell) {
|
|
80
|
+
return screen_x !== null && cell[0] >= 0 && cell[1] >= 0 && cell[0] < screen_x && cell[1] < screen_y;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// The nearest cell of the screen, for a drag or a release outside it.
|
|
84
|
+
function clamp_cell(cell) {
|
|
85
|
+
return [Math.min(Math.max(cell[0], 0), screen_x - 1), Math.min(Math.max(cell[1], 0), screen_y - 1)];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function send_mouse(event, e, button, cell) {
|
|
89
|
+
send_message({type: "mouse", event: mouse_modifiers(e) + event, button: button, col: cell[0], row: cell[1]});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function on_pointerdown(e) {
|
|
93
|
+
const button = mouse_buttons[e.button];
|
|
94
|
+
const cell = mouse_cell(e);
|
|
95
|
+
// a second button pressed while one is held is not reported
|
|
96
|
+
if (socket === null || button === undefined || pressed_button !== null || !inside_screen(cell)) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
// the release arrives here even when the pointer leaves the screen first
|
|
101
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
102
|
+
pressed_button = button;
|
|
103
|
+
pressed_bit = button_bits[e.button];
|
|
104
|
+
pressed_pointer = e.pointerId;
|
|
105
|
+
last_cell = cell;
|
|
106
|
+
send_mouse("mouse press", e, button, cell);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function release(e, cell) {
|
|
110
|
+
send_mouse("mouse release", e, pressed_button, cell);
|
|
111
|
+
pressed_button = null;
|
|
112
|
+
pressed_pointer = null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// With several buttons held, the browser reports each one released before the last as a pointermove,
|
|
116
|
+
// and only the last one as a pointerup, so both check whether the pressed button is still held.
|
|
117
|
+
function on_pointermove(e) {
|
|
118
|
+
if (pressed_button === null || e.pointerId !== pressed_pointer) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const cell = clamp_cell(mouse_cell(e));
|
|
122
|
+
if ((e.buttons & pressed_bit) === 0) {
|
|
123
|
+
release(e, cell);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (cell[0] === last_cell[0] && cell[1] === last_cell[1]) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
last_cell = cell;
|
|
130
|
+
send_mouse("mouse drag", e, pressed_button, cell);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function on_pointerup(e) {
|
|
134
|
+
if (pressed_button === null || e.pointerId !== pressed_pointer || (e.buttons & pressed_bit) !== 0) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
e.preventDefault();
|
|
138
|
+
release(e, clamp_cell(mouse_cell(e)));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// The browser took the pointer away, for example for a touch gesture, without a pointerup;
|
|
142
|
+
// the application still gets the release.
|
|
143
|
+
function on_pointercancel(e) {
|
|
144
|
+
if (pressed_button === null || e.pointerId !== pressed_pointer) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
release(e, last_cell);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Add a wheel distance to the one not sent yet, and return the remainder and the direction of a step,
|
|
151
|
+
// -1, 0 or 1. A large distance, such as a mouse notch, is one step, as a terminal reports one notch.
|
|
152
|
+
function wheel_step(pending, delta, step) {
|
|
153
|
+
// a turn the other way drops the distance left from the last one
|
|
154
|
+
const total = Math.sign(pending) === -Math.sign(delta) ? delta : pending + delta;
|
|
155
|
+
if (Math.abs(total) < step) {
|
|
156
|
+
return [total, 0];
|
|
157
|
+
}
|
|
158
|
+
return [total % step, Math.sign(total)];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function on_wheel(e) {
|
|
162
|
+
const cell = mouse_cell(e);
|
|
163
|
+
// the wheel turned with ctrl held is left to the browser, which zooms the page with it
|
|
164
|
+
if (socket === null || e.ctrlKey || !inside_screen(cell)) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
e.preventDefault();
|
|
168
|
+
const line = char_size()[1];
|
|
169
|
+
// WheelEvent.deltaMode: 0 is pixels, 1 is lines, 2 is pages
|
|
170
|
+
const scale = [1, line, line * screen_y][e.deltaMode] || 1;
|
|
171
|
+
let up_down;
|
|
172
|
+
let left_right;
|
|
173
|
+
[wheel_y, up_down] = wheel_step(wheel_y, e.deltaY * scale, wheel_lines * line);
|
|
174
|
+
[wheel_x, left_right] = wheel_step(wheel_x, e.deltaX * scale, wheel_lines * line);
|
|
175
|
+
if (up_down !== 0) {
|
|
176
|
+
send_mouse("mouse press", e, up_down < 0 ? 4 : 5, cell);
|
|
177
|
+
}
|
|
178
|
+
if (left_right !== 0) {
|
|
179
|
+
send_mouse("mouse press", e, left_right < 0 ? 6 : 7, cell);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// force sends the size even when it did not change, for the server's first view of it
|
|
184
|
+
function on_resize(force) {
|
|
185
|
+
// the screen uses at most this size, so the text area is not wider or taller and takes no mouse input beyond it;
|
|
186
|
+
// a page without the attributes, such as one an adapter writes itself, has no limit
|
|
187
|
+
const limits = document.body.dataset;
|
|
188
|
+
const max_cols = Number(limits.maxCols) || Infinity;
|
|
189
|
+
const max_rows = Number(limits.maxRows) || Infinity;
|
|
190
|
+
// the measured size is a quotient of floats, and not a number before the fonts are laid out
|
|
191
|
+
const [x_size, y_size] = measure_screen(max_cols, max_rows).map(Math.floor);
|
|
192
|
+
if (!(x_size >= 1 && y_size >= 1)) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (force === true || screen_x !== x_size || screen_y !== y_size) {
|
|
196
|
+
send_message({type: "resize", cols: x_size, rows: y_size});
|
|
197
|
+
}
|
|
198
|
+
screen_x = x_size;
|
|
199
|
+
screen_y = y_size;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function on_message(event) {
|
|
203
|
+
if (typeof event.data !== "string") {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
// the newline that ends the last row
|
|
207
|
+
render_update(event.data.endsWith("\n") ? event.data.slice(0, -1) : event.data);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function on_close() {
|
|
211
|
+
socket = null;
|
|
212
|
+
set_status("Connection Closed");
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function start() {
|
|
216
|
+
set_status("Connecting");
|
|
217
|
+
socket = new WebSocket(websocket_url());
|
|
218
|
+
socket.addEventListener("open", () => {
|
|
219
|
+
set_status("Connected");
|
|
220
|
+
on_resize(true);
|
|
221
|
+
});
|
|
222
|
+
socket.addEventListener("message", on_message);
|
|
223
|
+
socket.addEventListener("close", on_close);
|
|
224
|
+
|
|
225
|
+
document.addEventListener("keydown", on_keydown);
|
|
226
|
+
window.addEventListener("resize", on_resize);
|
|
227
|
+
|
|
228
|
+
const text = document.getElementById('text');
|
|
229
|
+
text.addEventListener("pointerdown", on_pointerdown);
|
|
230
|
+
text.addEventListener("pointermove", on_pointermove);
|
|
231
|
+
text.addEventListener("pointerup", on_pointerup);
|
|
232
|
+
text.addEventListener("pointercancel", on_pointercancel);
|
|
233
|
+
text.addEventListener("lostpointercapture", on_pointercancel);
|
|
234
|
+
// not passive, so the page does not scroll while the application takes the wheel
|
|
235
|
+
text.addEventListener("wheel", on_wheel, {passive: false});
|
|
236
|
+
// the right button goes to the application rather than opening the browser's menu
|
|
237
|
+
text.addEventListener("contextmenu", (e) => e.preventDefault());
|
|
238
|
+
setInterval(on_resize, check_font_delay);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
start();
|
|
@@ -477,9 +477,17 @@ class Screen(BaseScreen, RealTerminal):
|
|
|
477
477
|
return processed, raw
|
|
478
478
|
|
|
479
479
|
def _encode_mouse_event(self) -> list[int]:
|
|
480
|
-
|
|
480
|
+
"""Encode the pending curses mouse event as X10 mouse reports.
|
|
481
|
+
|
|
482
|
+
:returns: the codes of the reports, empty when ncurses has no event in its queue.
|
|
483
|
+
"""
|
|
481
484
|
last_state = next_state = self.last_bstate
|
|
482
|
-
|
|
485
|
+
try:
|
|
486
|
+
(_id, x, y, _z, bstate) = curses.getmouse()
|
|
487
|
+
except curses.error:
|
|
488
|
+
# ncurses returns KEY_MOUSE also when its queue holds no event matching the mask,
|
|
489
|
+
# e.g. for every pointer move on the FreeBSD syscons console, and getmouse() then fails.
|
|
490
|
+
return []
|
|
483
491
|
|
|
484
492
|
mod = 0
|
|
485
493
|
if bstate & curses.BUTTON_SHIFT:
|
|
@@ -435,14 +435,16 @@ class KeyqueueTrie:
|
|
|
435
435
|
more_available: bool,
|
|
436
436
|
*,
|
|
437
437
|
csi_u_shift_applied: bool = False,
|
|
438
|
-
) -> tuple[str | _MouseInput | _CursorPosition | _TerminalReport, list[int]] | None:
|
|
438
|
+
) -> tuple[str | _MouseInput | _CursorPosition | _TerminalReport | None, list[int]] | None:
|
|
439
439
|
"""Decode the longest key sequence matching the start of ``keys``, trying the trie then the special reports.
|
|
440
440
|
|
|
441
441
|
:param keys: the codes after the ESC that starts the sequence.
|
|
442
442
|
:param more_available: raise MoreInputRequired when the codes end in the middle of a sequence.
|
|
443
443
|
:param csi_u_shift_applied: see `read_key_report`.
|
|
444
|
+
:returns: the input and the codes left after it, with ``None`` as the input of a mouse report cut short;
|
|
445
|
+
``None`` when no sequence matches.
|
|
444
446
|
"""
|
|
445
|
-
result: tuple[str | _MouseInput | _CursorPosition | _TerminalReport, list[int]] | None
|
|
447
|
+
result: tuple[str | _MouseInput | _CursorPosition | _TerminalReport | None, list[int]] | None
|
|
446
448
|
if result := self.get_recurse(self.data, keys, more_available):
|
|
447
449
|
return result
|
|
448
450
|
|
|
@@ -465,7 +467,7 @@ class KeyqueueTrie:
|
|
|
465
467
|
root: (_KeyQueueData | str),
|
|
466
468
|
keys: list[int],
|
|
467
469
|
more_available: bool,
|
|
468
|
-
) -> tuple[str | _MouseInput, list[int]] | None:
|
|
470
|
+
) -> tuple[str | _MouseInput | None, list[int]] | None:
|
|
469
471
|
"""
|
|
470
472
|
Walk the trie for the next key, consuming codes as it goes.
|
|
471
473
|
|
|
@@ -495,14 +497,32 @@ class KeyqueueTrie:
|
|
|
495
497
|
self,
|
|
496
498
|
keys: list[int],
|
|
497
499
|
more_available: bool,
|
|
498
|
-
) -> tuple[_MouseInput, list[int]] | None:
|
|
500
|
+
) -> tuple[_MouseInput | None, list[int]] | None:
|
|
499
501
|
"""Read an X10 mouse report from the codes and return the resulting input.
|
|
500
502
|
|
|
503
|
+
A report cut short is consumed and gives ``None`` as its input.
|
|
504
|
+
It is cut short when the next ``ESC [ M`` report starts in place of one of its three bytes,
|
|
505
|
+
or when the codes end after one or two of them.
|
|
506
|
+
The FreeBSD ``vt(4)`` console sends such reports, since it leaves out a column or row past 94.
|
|
507
|
+
|
|
508
|
+
:returns: the mouse event, or ``None`` for a report cut short, and the codes left after the report;
|
|
509
|
+
``None`` when the codes end right after ``ESC [ M``.
|
|
501
510
|
:raises MoreInputRequired: the codes end in the middle of a sequence and *more_available* is set.
|
|
502
511
|
"""
|
|
512
|
+
# Any other byte below the offset is a coordinate the terminal wrapped past 255, as the Linux console does;
|
|
513
|
+
# 27 is one too (column or row 250), so only a whole "ESC [ M" marks the next report.
|
|
514
|
+
for i, k in enumerate(keys[:3]):
|
|
515
|
+
if k == 27:
|
|
516
|
+
following = tuple(keys[i + 1 : i + 3])
|
|
517
|
+
if following == _NEXT_MOUSE_REPORT:
|
|
518
|
+
return None, keys[i:]
|
|
519
|
+
if more_available and len(following) < 2 and following == _NEXT_MOUSE_REPORT[: len(following)]:
|
|
520
|
+
raise MoreInputRequired
|
|
503
521
|
if len(keys) < 3:
|
|
504
522
|
if more_available:
|
|
505
523
|
raise MoreInputRequired
|
|
524
|
+
if keys:
|
|
525
|
+
return None, []
|
|
506
526
|
return None
|
|
507
527
|
|
|
508
528
|
b = keys[0] - _MOUSE_BYTE_OFFSET
|
|
@@ -955,6 +975,8 @@ _MOUSE_BYTE_MAX: typing.Final = 255
|
|
|
955
975
|
# the 0-based column or row an X10 report cannot carry: xterm sends it, and any farther one, as a NUL byte,
|
|
956
976
|
# which decodes back to this value
|
|
957
977
|
MOUSE_X10_PAST_END: typing.Final = 255 - _MOUSE_BYTE_OFFSET
|
|
978
|
+
# the codes after ESC that start an X10 report
|
|
979
|
+
_NEXT_MOUSE_REPORT: typing.Final = (ord("["), ord("M"))
|
|
958
980
|
|
|
959
981
|
|
|
960
982
|
#################################################
|
|
@@ -1052,6 +1074,7 @@ def process_keyqueue(
|
|
|
1052
1074
|
rather than the Delete key st sends it for; with xterm's modifyOtherKeys, a CSI u report carries the character
|
|
1053
1075
|
typed with shift.
|
|
1054
1076
|
:returns: a ``(list of input, list of remaining key codes)`` tuple.
|
|
1077
|
+
The list of input is empty when the codes consumed are a mouse report cut short.
|
|
1055
1078
|
:raises MoreInputRequired: the codes end in the middle of a sequence and *more_available* is set.
|
|
1056
1079
|
"""
|
|
1057
1080
|
code = codes[0]
|
|
@@ -1129,7 +1152,7 @@ def process_keyqueue(
|
|
|
1129
1152
|
shift_applied = keyboard_protocol == "modify other keys"
|
|
1130
1153
|
if (result := input_trie.get(codes[1:], more_available, csi_u_shift_applied=shift_applied)) is not None:
|
|
1131
1154
|
decoded, remaining_codes = result
|
|
1132
|
-
return [decoded], remaining_codes
|
|
1155
|
+
return ([] if decoded is None else [decoded]), remaining_codes
|
|
1133
1156
|
|
|
1134
1157
|
# An unrecognised control sequence is one key: decoding it byte by byte would type its body as text.
|
|
1135
1158
|
if codes[1:2] == [ord("[")] and (length := _control_sequence_length(codes[2:], more_available)) is not None:
|
|
@@ -1145,7 +1168,7 @@ def process_keyqueue(
|
|
|
1145
1168
|
run, remaining_codes = process_keyqueue(codes[1:], more_available, keyboard_protocol=keyboard_protocol)
|
|
1146
1169
|
# A mouse event or a terminal report (cursor position, DECRPM, a query reply) cannot take a meta prefix,
|
|
1147
1170
|
# and an unrecognised control sequence may be such a report.
|
|
1148
|
-
if not isinstance(run[0], str) or run[0] == "esc" or "meta " in run[0] or run[0].startswith("<csi "):
|
|
1171
|
+
if not run or not isinstance(run[0], str) or run[0] == "esc" or "meta " in run[0] or run[0].startswith("<csi "):
|
|
1149
1172
|
return ["esc", *run], remaining_codes
|
|
1150
1173
|
return [f"meta {run[0]}", *run[1:]], remaining_codes
|
|
1151
1174
|
|
|
@@ -413,7 +413,7 @@ def _session_dir() -> str:
|
|
|
413
413
|
uid = os.geteuid()
|
|
414
414
|
path = os.path.join(_prefs.pipe_dir, f"urwid-web-{uid}")
|
|
415
415
|
with suppress(FileExistsError):
|
|
416
|
-
|
|
416
|
+
pathlib.Path(path).mkdir(mode=0o700)
|
|
417
417
|
# lstat: a symbolic link planted at the path is refused rather than followed
|
|
418
418
|
st = os.lstat(path)
|
|
419
419
|
if not stat.S_ISDIR(st.st_mode) or st.st_uid != uid or stat.S_IMODE(st.st_mode) & 0o077:
|