Replies: 4 comments 1 reply
-
|
Hmm, I'm not a fan of tracking timestamps internally for this, but the underlying terminal state that is associated with this is based around sequence numbers. Internally the terminal bumps the I'm open to the idea of expanding Then your lua logic could keep track of the time and the seqno's to derive the the timing information? |
Beta Was this translation helpful? Give feedback.
-
|
Yeah, I've analyzed how logic behind |
Beta Was this translation helpful? Give feedback.
-
|
I've played a little and with adding diff --git a/lua-api-crates/mux/src/pane.rs b/lua-api-crates/mux/src/pane.rs
index f0d919e16..0a16b03d3 100644
--- a/lua-api-crates/mux/src/pane.rs
+++ b/lua-api-crates/mux/src/pane.rs
@@ -409,6 +409,12 @@ impl UserData for MuxPane {
let pane = this.resolve(&mux)?;
Ok(pane.tty_name())
});
+
+ methods.add_method("get_seqno", move |_lua, this, ()| {
+ let mux = Mux::get();
+ let pane = this.resolve(&mux)?;
+ Ok(pane.get_current_seqno())
+ });
}
}I was able to achieve what I want with this (a little bit lenghty) config example: local wezterm = require 'wezterm'
config = wezterm.config_builder()
-- keep tab and pane activity snapshots (timestamp and pane seqno)
wezterm.GLOBAL.activity = (wezterm.GLOBAL.activity or {})
local function get_seq(pane_id)
return wezterm.mux.get_pane(pane_id):get_seqno()
end
wezterm.on('format-tab-title', function(tab, tabs, panes, config, hover, max_width)
local act = wezterm.GLOBAL.activity
local tid, wid, pid = tostring(tab.tab_id), tostring(tab.window_id)
act[wid] = (act[wid] or {})
act[wid][tid] = (act[wid][tid] or {})
act = act[wid][tid]
if tab.is_active then
-- reset timestamp and panes, as they are not relevant for current tab
-- state
act.timestamp = nil
act.panes = {}
return {
{Text = tab.active_pane.title},
}
end
local color
local has_unseen_output = false
local seqno
local ts = os.time()
for _, pane in ipairs(tab.panes) do
pid = tostring(pane.pane_id)
seqno = get_seq(pane.pane_id)
if act.panes[pid] == nil then
act.panes[pid] = seqno
end
if pane.has_unseen_output then
has_unseen_output = true
if act.panes[pid] and act.panes[pid] < seqno then
act.timestamp = ts
act.panes[pid] = seqno
end
end
end
if has_unseen_output then
if act.timestamp == nil then
act.timestamp = ts
end
-- simple hardcoded values in seconds, it might be also a matter for
-- making color transitions instead
if os.difftime(ts, act.timestamp) > 9 then
color = '#9989e8'
elseif os.difftime(ts, act.timestamp) > 6 then
color = '#d65fe8'
elseif os.difftime(ts, act.timestamp) > 3 then
color = '#e83ec3'
else
color = '#e8331e'
end
return {
{Foreground = {Color = color}},
{Text = tab.active_pane.title}
}
end
return tab.active_pane.title
end
)
return config |
Beta Was this translation helpful? Give feedback.
-
|
Another issue, that I've noticed is, that watching for Also it's kind of awkward to me, that when issuing wezterm-gui, and then creating second tab with whatever, first tab is always have the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've dug deep for this and found some of the answers, and I'm aware of
has_unseen_outputattribute for the pane object, although, there is a small issue with it. When it is set, there is no way to distinguish if on inactive tab there is still some activity (which alter/add terminal content) or the activity has stopped. I'm not sure how to exactly implement that in current state, other than exposing timestamps for tab being inactive (not current) and last occurred changes in the pane terminal which user could use to implement lua function for that purpose. I'm trying to achieve something like this: https://github.com/gryf/tabbedalt#features (there is an animgif with colored indicators for activity). Or am I missing something obvious?Beta Was this translation helpful? Give feedback.
All reactions