add wezterm.column_width
refs: https://github.com/wez/wezterm/issues/647
This commit is contained in:
1 parent
3ad2a46ecf
commit
0f2f3734d9
3 files changed
+20
-1
No files matched your search
+6
-1
@@ -7,7 +7,7 @@ use mlua::{Lua, Table, Value};
|
||||
use serde::*;
|
||||
use smol::prelude::*;
|
||||
use std::path::Path;
|
||||
use termwiz::cell::{AttributeChange, CellAttributes};
|
||||
use termwiz::cell::{unicode_column_width, AttributeChange, CellAttributes};
|
||||
use termwiz::color::{AnsiColor, ColorAttribute, ColorSpec, RgbColor};
|
||||
use termwiz::input::Modifiers;
|
||||
use termwiz::surface::change::Change;
|
||||
@@ -115,6 +115,11 @@ pub fn make_lua_context(config_file: &Path) -> anyhow::Result<Lua> {
|
||||
})?,
|
||||
)?;
|
||||
|
||||
wezterm_mod.set(
|
||||
"column_width",
|
||||
lua.create_function(|_, s: String| Ok(unicode_column_width(&s)))?,
|
||||
)?;
|
||||
|
||||
wezterm_mod.set("font", lua.create_function(font)?)?;
|
||||
wezterm_mod.set(
|
||||
"font_with_fallback",
|
||||
|
||||
@@ -44,6 +44,7 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
* New: [Quick Select Mode](quickselect.md) for a tmux-fingers/tmux-thumbs style mouse-less select and copy flow [#732](https://github.com/wez/wezterm/issues/732)
|
||||
* Fixed: tabs would remain hovered after moving the mouse down into the main terminal area [#591](https://github.com/wez/wezterm/issues/591)
|
||||
* New: [tab_bar_at_bottom](config/lua/config/tab_bar_at_bottom.md) setting to put the tab bar at the bottom of the window [#278](https://github.com/wez/wezterm/issues/278)
|
||||
* New: [wezterm.column_width](config/lua/wezterm/column_width.md) function for measuring the displayed width of a string
|
||||
|
||||
### 20210405-110924-a5bb5be8
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# wezterm.column_width(string)
|
||||
|
||||
*Since: nightly builds only*
|
||||
|
||||
Given a string parameter, returns the number of columns that that text occupies
|
||||
in the terminal, which is useful together with
|
||||
[format-tab-title](../window-events/format-tab-title.md) and
|
||||
[update-right-status](../window-events/update-right-status.md) to
|
||||
compute/layout tabs and status information.
|
||||
|
||||
This is different from [string.len](https://www.lua.org/manual/5.3/manual.html#pdf-string.len)
|
||||
which returns the number of bytes that comprise the string.
|
||||
|
||||
Reference in new issue
Block a user