Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af718955fe |
No files matched your search
Vendored
-10
@@ -1,13 +1,3 @@
|
|||||||
devdesk (0.12.1) bookworm; urgency=medium
|
|
||||||
|
|
||||||
* Touch screens (#64):
|
|
||||||
- A swipe on the terminal scrolls tmux's history like the mouse wheel;
|
|
||||||
a flick keeps going. Taps still focus and switch windows.
|
|
||||||
- Resize handles can be dragged with a finger and are wider on
|
|
||||||
touch screens.
|
|
||||||
|
|
||||||
-- Jared Vititoe <jjvititoe1@gmail.com> Thu, 26 Nov 2026 12:55:00 -0500
|
|
||||||
|
|
||||||
devdesk (0.12.0) bookworm; urgency=medium
|
devdesk (0.12.0) bookworm; urgency=medium
|
||||||
|
|
||||||
* Settings window, from the ⋯ menu or the palette (#61):
|
* Settings window, from the ⋯ menu or the palette (#61):
|
||||||
|
|||||||
+15
-3
@@ -163,6 +163,17 @@ cmd_alerts() {
|
|||||||
fi
|
fi
|
||||||
jq -cM --arg pub "$DEVDESK_GRAFANA_PUBLIC_URL" --slurpfile g <(cat "$DEVDESK_GUESTS" 2>/dev/null || echo null) "$DD_LOCATE_JQ"'
|
jq -cM --arg pub "$DEVDESK_GRAFANA_PUBLIC_URL" --slurpfile g <(cat "$DEVDESK_GUESTS" 2>/dev/null || echo null) "$DD_LOCATE_JQ"'
|
||||||
def num: (tonumber? // .) | tostring;
|
def num: (tonumber? // .) | tostring;
|
||||||
|
# Rule-level annotations are raw Go templates. Fill {{ $labels.X }} with the
|
||||||
|
# distinct values across the active instances and {{ $value }} with the first.
|
||||||
|
def fill($t; $active):
|
||||||
|
reduce ([$t | scan("\\{\\{ *\\$labels\\.([A-Za-z_][A-Za-z0-9_]*) *\\}\\}") | .[0]] | unique[]) as $k
|
||||||
|
($t; ([$active[] | .labels[$k] // empty] | unique | join(", ")) as $v
|
||||||
|
| gsub("\\{\\{ *\\$labels\\.\($k) *\\}\\}"; if $v == "" then "?" else $v end))
|
||||||
|
| gsub("\\{\\{ *\\$value *\\}\\}"; ($active[0].value // "?" | num));
|
||||||
|
# One active instance: Grafana already rendered its annotations, use them as is.
|
||||||
|
def annotation($key; $t; $active):
|
||||||
|
if ($active | length) == 1 and (($active[0].annotations // {})[$key] // "") != ""
|
||||||
|
then $active[0].annotations[$key] else fill($t; $active) end;
|
||||||
($g[0]) as $guests
|
($g[0]) as $guests
|
||||||
| {configured: true, checked: (now | floor), pve: ($guests != null), alerts: [
|
| {configured: true, checked: (now | floor), pve: ($guests != null), alerts: [
|
||||||
.data.groups[] | .name as $group | .file as $folder | .rules[]
|
.data.groups[] | .name as $group | .file as $folder | .rules[]
|
||||||
@@ -171,9 +182,10 @@ cmd_alerts() {
|
|||||||
| {uid, name, state, severity: (.labels.severity // null), group: $group, folder: $folder,
|
| {uid, name, state, severity: (.labels.severity // null), group: $group, folder: $folder,
|
||||||
query: (.query // null),
|
query: (.query // null),
|
||||||
since: (.activeAt // $active[0].activeAt // null),
|
since: (.activeAt // $active[0].activeAt // null),
|
||||||
summary: ((.annotations.summary // .annotations.description // "")
|
summary: (if .annotations.summary then annotation("summary"; .annotations.summary; $active)
|
||||||
| gsub("\\{\\{ *\\$value *\\}\\}"; ($active[0].value // "?" | num))),
|
else annotation("description"; .annotations.description // ""; $active) end),
|
||||||
description: (if .annotations.summary then (.annotations.description // null) else null end),
|
description: (if .annotations.summary and .annotations.description
|
||||||
|
then annotation("description"; .annotations.description; $active) else null end),
|
||||||
labelsets: [$active[] | .labels
|
labelsets: [$active[] | .labels
|
||||||
| del(.__alert_rule_uid__, .__grafana_origin__, .alertname, .grafana_folder, .__name__, .severity)
|
| del(.__alert_rule_uid__, .__grafana_origin__, .alertname, .grafana_folder, .__name__, .severity)
|
||||||
| select(length > 0)],
|
| select(length > 0)],
|
||||||
|
|||||||
-109
@@ -90,113 +90,6 @@ export async function loadFonts(size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Touch scrolling (devdesk#64). xterm.js has none, and tmux owns the mouse, so
|
|
||||||
// a finger swipe did nothing. A one-finger vertical swipe now scrolls the way
|
|
||||||
// the mouse wheel does: with mouse tracking on (tmux) it becomes wheel reports
|
|
||||||
// at the touch point, and tmux scrolls WHEEL_LINES lines per report (entering
|
|
||||||
// copy mode, leaving it at the bottom); without it, xterm's own buffer scrolls.
|
|
||||||
// The content follows the finger, and a flick keeps going and slows down.
|
|
||||||
const WHEEL_LINES = 5; // tmux copy mode: send -N5 -X scroll-up per wheel report
|
|
||||||
const SLOP = 8; // px before a touch counts as a scroll rather than a tap
|
|
||||||
|
|
||||||
function wireTouchScroll(term, container) {
|
|
||||||
let touch = null;
|
|
||||||
let carry = 0; // finger travel not yet turned into lines
|
|
||||||
let fling = 0;
|
|
||||||
const screen = () => container.querySelector('.xterm-screen');
|
|
||||||
|
|
||||||
// Scroll by finger travel px (positive = finger down = back into history).
|
|
||||||
const scrollBy = (px, at) => {
|
|
||||||
const rect = screen()?.getBoundingClientRect();
|
|
||||||
if (!rect || !term.rows) return false;
|
|
||||||
const cell = rect.height / term.rows;
|
|
||||||
const mouse = term.modes.mouseTrackingMode !== 'none';
|
|
||||||
const per = mouse ? cell * WHEEL_LINES : cell;
|
|
||||||
carry += px;
|
|
||||||
const steps = Math.trunc(carry / per);
|
|
||||||
if (!steps) return true;
|
|
||||||
carry -= steps * per;
|
|
||||||
if (!mouse) {
|
|
||||||
term.scrollLines(-steps);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// Inside the pane the swipe started on, and never on tmux's status line
|
|
||||||
// (a wheel there switches windows).
|
|
||||||
const clientX = Math.min(Math.max(at.x, rect.left + 1), rect.right - 1);
|
|
||||||
const clientY = Math.min(Math.max(at.y, rect.top + cell / 2), rect.bottom - cell * 1.5);
|
|
||||||
for (let i = 0; i < Math.abs(steps); i++) {
|
|
||||||
screen().dispatchEvent(new WheelEvent('wheel', {
|
|
||||||
bubbles: true, cancelable: true, view: window, clientX, clientY,
|
|
||||||
deltaMode: WheelEvent.DOM_DELTA_LINE, deltaY: steps > 0 ? -1 : 1,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const stopFling = () => {
|
|
||||||
cancelAnimationFrame(fling);
|
|
||||||
fling = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
container.addEventListener('touchstart', (event) => {
|
|
||||||
stopFling();
|
|
||||||
if (event.touches.length !== 1) {
|
|
||||||
touch = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const t = event.touches[0];
|
|
||||||
touch = { id: t.identifier, start: { x: t.clientX, y: t.clientY }, y: t.clientY, scrolling: false, samples: [[event.timeStamp, t.clientY]] };
|
|
||||||
carry = 0;
|
|
||||||
}, { passive: true });
|
|
||||||
|
|
||||||
container.addEventListener('touchmove', (event) => {
|
|
||||||
if (!touch) return;
|
|
||||||
if (event.touches.length !== 1) {
|
|
||||||
touch = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const t = [...event.changedTouches].find((c) => c.identifier === touch.id);
|
|
||||||
if (!t) return;
|
|
||||||
if (!touch.scrolling) {
|
|
||||||
const dx = t.clientX - touch.start.x;
|
|
||||||
const dy = t.clientY - touch.start.y;
|
|
||||||
if (Math.abs(dy) < SLOP || Math.abs(dy) < Math.abs(dx)) return;
|
|
||||||
touch.scrolling = true;
|
|
||||||
touch.y = t.clientY;
|
|
||||||
}
|
|
||||||
if (event.cancelable) event.preventDefault();
|
|
||||||
scrollBy(t.clientY - touch.y, touch.start);
|
|
||||||
touch.y = t.clientY;
|
|
||||||
touch.samples.push([event.timeStamp, t.clientY]);
|
|
||||||
while (touch.samples.length > 2 && event.timeStamp - touch.samples[0][0] > 100) touch.samples.shift();
|
|
||||||
}, { passive: false });
|
|
||||||
|
|
||||||
const end = (event) => {
|
|
||||||
const done = touch;
|
|
||||||
touch = null;
|
|
||||||
if (!done?.scrolling) return;
|
|
||||||
if (event.cancelable) event.preventDefault(); // no click after a swipe
|
|
||||||
if (event.type !== 'touchend') return;
|
|
||||||
// Flick: keep scrolling at the release speed, easing out.
|
|
||||||
const [t0, y0] = done.samples[0];
|
|
||||||
const [t1, y1] = done.samples[done.samples.length - 1];
|
|
||||||
let speed = t1 > t0 && event.timeStamp - t1 < 80 ? (y1 - y0) / (t1 - t0) : 0; // px/ms
|
|
||||||
if (Math.abs(speed) < 0.3) return;
|
|
||||||
let last = performance.now();
|
|
||||||
const frame = (now) => {
|
|
||||||
const dt = Math.min(now - last, 50);
|
|
||||||
last = now;
|
|
||||||
if (!scrollBy(speed * dt, done.start)) return stopFling();
|
|
||||||
speed *= 0.95 ** (dt / 16);
|
|
||||||
fling = Math.abs(speed) > 0.05 ? requestAnimationFrame(frame) : 0;
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
fling = requestAnimationFrame(frame);
|
|
||||||
};
|
|
||||||
container.addEventListener('touchend', end, { passive: false });
|
|
||||||
container.addEventListener('touchcancel', end, { passive: false });
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createTerminal(container, { fontSize, theme = 'dark', onShiftEnter, onCopied }) {
|
export function createTerminal(container, { fontSize, theme = 'dark', onShiftEnter, onCopied }) {
|
||||||
const term = new Terminal({
|
const term = new Terminal({
|
||||||
fontFamily: FONT_FAMILY,
|
fontFamily: FONT_FAMILY,
|
||||||
@@ -283,8 +176,6 @@ export function createTerminal(container, { fontSize, theme = 'dark', onShiftEnt
|
|||||||
}, 0);
|
}, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
wireTouchScroll(term, container);
|
|
||||||
|
|
||||||
// Touch devices: the DOM renderer is more reliable at high DPR than WebGL.
|
// Touch devices: the DOM renderer is more reliable at high DPR than WebGL.
|
||||||
if (window.matchMedia?.('(pointer: coarse)').matches) return { term, fit };
|
if (window.matchMedia?.('(pointer: coarse)').matches) return { term, fit };
|
||||||
try {
|
try {
|
||||||
|
|||||||
+1
-8
@@ -186,7 +186,6 @@ body.dd-app::after {
|
|||||||
|
|
||||||
.dd-terminal .xterm {
|
.dd-terminal .xterm {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
touch-action: none; /* swipes scroll tmux (term.js wireTouchScroll), not the page */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dd-terminal .xterm-viewport {
|
.dd-terminal .xterm-viewport {
|
||||||
@@ -750,7 +749,6 @@ body.dd-resizing .dd-md-frame { pointer-events: none; }
|
|||||||
left: calc(-1 * var(--dd-gap) - 2px);
|
left: calc(-1 * var(--dd-gap) - 2px);
|
||||||
width: calc(var(--dd-gap) + 6px);
|
width: calc(var(--dd-gap) + 6px);
|
||||||
cursor: col-resize;
|
cursor: col-resize;
|
||||||
touch-action: none; /* a finger drag resizes instead of scrolling */
|
|
||||||
z-index: 3;
|
z-index: 3;
|
||||||
}
|
}
|
||||||
.dd-files-resizer:hover,
|
.dd-files-resizer:hover,
|
||||||
@@ -798,12 +796,7 @@ body.dd-resizing .dd-files-resizer { background: linear-gradient(90deg, transpar
|
|||||||
.dd-files.explorer-hidden .dd-explorer,
|
.dd-files.explorer-hidden .dd-explorer,
|
||||||
.dd-files.explorer-hidden .dd-explorer-resizer,
|
.dd-files.explorer-hidden .dd-explorer-resizer,
|
||||||
.dd-files.is-narrow .dd-explorer-resizer { display: none; }
|
.dd-files.is-narrow .dd-explorer-resizer { display: none; }
|
||||||
.dd-explorer-resizer { flex: 0 0 4px; margin-left: -2px; margin-right: -2px; cursor: col-resize; touch-action: none; z-index: 2; }
|
.dd-explorer-resizer { flex: 0 0 4px; margin-left: -2px; margin-right: -2px; cursor: col-resize; z-index: 2; }
|
||||||
/* Touch screens (devdesk#64): wider grab areas for a finger. */
|
|
||||||
@media (any-pointer: coarse) {
|
|
||||||
.dd-explorer-resizer { flex-basis: 14px; margin-left: -7px; margin-right: -7px; }
|
|
||||||
.dd-files-resizer { left: calc(-1 * var(--dd-gap) - 6px); width: calc(var(--dd-gap) + 14px); }
|
|
||||||
}
|
|
||||||
.dd-explorer-resizer:hover { background: var(--accent-cyan); }
|
.dd-explorer-resizer:hover { background: var(--accent-cyan); }
|
||||||
.dd-explorer-views { display: flex; border-bottom: 1px solid var(--border-dim); }
|
.dd-explorer-views { display: flex; border-bottom: 1px solid var(--border-dim); }
|
||||||
.dd-explorer-views button[role="tab"] {
|
.dd-explorer-views button[role="tab"] {
|
||||||
|
|||||||
Reference in new issue
Block a user