Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
03e7ef4
feat(linux-grid): add row numbers, row height and NULL text preferences
sedax90 Nov 8, 2026
390a0a3
feat(linux-grid): let the data grid have its own cell font
sedax90 Nov 8, 2026
8c415d7
feat(linux-grid): choose the format Copy writes for several rows
sedax90 Nov 8, 2026
2bc031b
feat(linux-grid): open row details when a row is selected, if asked
sedax90 Nov 8, 2026
6ed90a9
feat(linux-grid): sort a table by a default column when it opens
sedax90 Nov 8, 2026
371e238
feat(linux-grid): mark spaces, tabs and line breaks in the value editor
sedax90 Nov 8, 2026
ff5eae3
fix(linux-grid): show the chosen NULL text in editable cells too
sedax90 Nov 8, 2026
e13f6f5
Merge branch 'feat/linux-grid-display-settings' into feat/linux-grid-…
sedax90 Nov 8, 2026
4db6483
Merge branch 'feat/linux-grid-font' into feat/linux-row-copy-format
sedax90 Nov 8, 2026
d31a4f6
Merge branch 'feat/linux-row-copy-format' into feat/linux-auto-inspector
sedax90 Nov 8, 2026
371e4b2
Merge branch 'feat/linux-auto-inspector' into feat/linux-default-sort
sedax90 Nov 8, 2026
86fefb4
Merge branch 'feat/linux-default-sort' into feat/linux-invisible-chars
sedax90 Nov 8, 2026
ab70c2d
fix(linux-grid): share live display preferences across grids
datlechin Nov 8, 2026
1d3f362
fix(linux-grid): merge updated NULL display behavior
datlechin Nov 8, 2026
b0f30c2
feat(linux-grid): scope cell fonts to each grid
datlechin Nov 8, 2026
76e860b
Merge branch 'feat/linux-grid-font' of https://github.com/sedax90/Tab…
datlechin Nov 8, 2026
1ad8564
fix(linux-grid): synchronize row copy format preferences
datlechin Nov 8, 2026
e1d1f5b
fix(linux-grid): open row details only for selected rows
datlechin Nov 8, 2026
3a92ff3
fix(linux-grid): preserve saved sort choices with shared defaults
datlechin Nov 8, 2026
c0da2cf
fix(linux-grid): keep display preferences when resetting columns
datlechin Nov 8, 2026
c03b4eb
test(linux-grid): load native styles for row height checks
datlechin Nov 8, 2026
45b2c6f
fix(linux-grid): merge display reset and test fixture fixes
datlechin Nov 8, 2026
a19f02a
fix(linux-grid): merge display reset and test fixture fixes
datlechin Nov 8, 2026
c791e77
fix(linux-grid): merge display reset and test fixture fixes
datlechin Nov 8, 2026
9a2ddbd
fix(linux-grid): merge display reset and test fixture fixes
datlechin Nov 8, 2026
c1decb6
feat(linux-grid): share native whitespace display preferences
datlechin Nov 8, 2026
38801c1
fix(linux-grid): expose editor state within row details
datlechin Nov 8, 2026
bbbaaac
fix(linux-grid): merge row detail test visibility fix
datlechin Nov 8, 2026
4c1fc4e
fix(linux-grid): merge row detail test visibility fix
datlechin Nov 8, 2026
f0b3070
test(linux-grid): isolate settings notification contexts
datlechin Nov 8, 2026
36f6505
test(linux-grid): merge isolated settings contexts
datlechin Nov 8, 2026
d702bda
test(linux-grid): merge isolated settings contexts
datlechin Nov 8, 2026
d671bf3
test(linux-grid): merge isolated settings contexts
datlechin Nov 8, 2026
0cd3691
test(linux-grid): merge isolated settings contexts
datlechin Nov 8, 2026
8dfa4ea
test(linux-grid): merge isolated settings contexts
datlechin Nov 8, 2026
65b6a7f
fix(linux-grid): type the settings test shutdown channel
datlechin Nov 8, 2026
1f2ca73
fix(linux-grid): merge the settings test channel type
datlechin Nov 8, 2026
4b52c85
fix(linux-grid): merge the settings test channel type
datlechin Nov 8, 2026
83a7fd8
fix(linux-grid): merge the settings test channel type
datlechin Nov 8, 2026
80692f9
fix(linux-grid): merge the settings test channel type
datlechin Nov 8, 2026
f5305bc
fix(linux-grid): merge the settings test channel type
datlechin Nov 8, 2026
068db68
test(linux-grid): assert copied JSON without unordered maps
datlechin Nov 8, 2026
6c94494
test(linux-grid): merge the ordered JSON assertions
datlechin Nov 8, 2026
28a8390
test(linux-grid): merge the ordered JSON assertions
datlechin Nov 8, 2026
3318fcc
test(linux-grid): merge the ordered JSON assertions
datlechin Nov 8, 2026
1d48659
Merge branch 'main' into feat/linux-grid-font
datlechin Nov 9, 2026
41df39f
fix(linux-grid): pass the NULL text to the row details search
datlechin Nov 9, 2026
1579040
Merge commit '41df39fb6' into feat/linux-default-sort
datlechin Nov 9, 2026
a1d4b07
Merge remote-tracking branch 'origin/main' into feat/linux-default-sort
datlechin Nov 9, 2026
8425752
Merge remote-tracking branch 'origin/main' into feat/linux-grid-font
datlechin Nov 9, 2026
60f17aa
Merge commit 'a1d4b07ed' into feat/linux-invisible-chars
datlechin Nov 9, 2026
8973772
Merge branch 'feat/linux-grid-font' into feat/linux-row-copy-format
datlechin Nov 9, 2026
ad05a62
Merge branch 'feat/linux-row-copy-format' into feat/linux-auto-inspector
datlechin Nov 9, 2026
ee70f82
Merge commit 'ad05a62e8' into feat/linux-default-sort
datlechin Nov 9, 2026
dcab0cc
Merge commit 'ee70f828c' into feat/linux-invisible-chars
datlechin Nov 9, 2026
48409b1
test(linux-grid): box the browse command the default sort test sends
datlechin Nov 9, 2026
a8ec7e9
Merge commit '48409b112' into feat/linux-invisible-chars
datlechin Nov 9, 2026
329b5e1
Merge remote-tracking branch 'origin/main' into feat/linux-default-sort
datlechin Nov 9, 2026
5b0732c
Merge commit '329b5e13b' into feat/linux-invisible-chars
datlechin Nov 9, 2026
f241535
feat(linux-grid): mark zero-width, control and special space characte…
datlechin Nov 9, 2026
65337b1
fix(linux-grid): size automatic columns to the marks their cells draw
datlechin Nov 9, 2026
5a0e6d9
Merge branch 'main' into feat/linux-row-copy-format
datlechin Nov 9, 2026
cac6093
Merge commit '5a0e6d95a' into feat/linux-auto-inspector
datlechin Nov 9, 2026
579e9a6
Merge commit 'cac6093da' into feat/linux-default-sort
datlechin Nov 9, 2026
70cbadc
Merge commit '579e9a614' into feat/linux-invisible-chars
datlechin Nov 9, 2026
fb2017d
Merge remote-tracking branch 'origin/main' into feat/linux-row-copy-f…
datlechin Nov 10, 2026
eef6e33
Merge commit 'fb2017ddaf829ac51ca52574b481d2776eb4a684' into feat/lin…
datlechin Nov 10, 2026
af234e8
Merge commit 'eef6e3301fe5418e28c47b55dc281046069cb19e' into feat/lin…
datlechin Nov 10, 2026
b0c55ed
Merge commit 'af234e843c1ae67866816e24ff429c4ce1fe60f6' into feat/lin…
datlechin Nov 10, 2026
b2a4b9c
Merge remote-tracking branch 'origin/main' into feat/linux-row-copy-f…
datlechin Nov 10, 2026
b9ff0f1
Merge commit 'b2a4b9c8fdef800402ee413bfadb55cfbc052832' into feat/lin…
datlechin Nov 10, 2026
6f68027
Merge commit 'b9ff0f1ff3490037750fe0dd97103ad7570aedc5' into feat/lin…
datlechin Nov 10, 2026
2cc00b8
Merge commit '6f68027d2d8f33aa9c9f0bd2c967e97a500bf5f9' into feat/lin…
datlechin Nov 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions linux/changelog.d/4137.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Preferences can set the format Copy writes when several rows are selected, as TSV, JSON, CSV or Markdown.
1 change: 1 addition & 0 deletions linux/changelog.d/4138.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Preferences can open the row details pane whenever a row is selected.
1 change: 1 addition & 0 deletions linux/changelog.d/4140.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Preferences can sort a table by its primary key or first column when it opens, ascending or descending.
1 change: 1 addition & 0 deletions linux/changelog.d/4141.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cells and value fields mark zero-width, control and special space characters, which Preferences can turn off.
1 change: 1 addition & 0 deletions linux/crates/app/src/services/grid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ mod result_refusal;
mod row_key_builder;
mod row_snapshot;
mod selection_summary;
pub mod special_characters;
#[cfg(test)]
mod test_columns;

Expand Down
380 changes: 380 additions & 0 deletions linux/crates/app/src/services/grid/special_characters.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,380 @@
use std::borrow::Cow;
use std::ops::Range;

// The macOS app's cap per line: past it a value of control bytes would draw one mark each.
pub const MAX_MARKS: usize = 4_096;

const EMOJI_TAG_BASE: u32 = 0x1F3F4;

const C0_LABELS: [&str; 32] = [
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", "DLE",
"DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US",
];

const C1_LABELS: [&str; 32] = [
"PAD", "HOP", "BPH", "NBH", "IND", "NEL", "SSA", "ESA", "HTS", "HTJ", "VTS", "PLD", "PLU", "RI", "SS2", "SS3",
"DCS", "PU1", "PU2", "STS", "CCH", "MW", "SPA", "EPA", "SOS", "SGC", "SCI", "CSI", "ST", "OSC", "PM", "APC",
];

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SpecialCharacter {
/// Drawn as its short name, since it has no width or no glyph of its own.
Marker(Cow<'static, str>),
/// A space other than U+0020, drawn at its own width.
BlankSpace,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Classified {
/// Bytes of the text the character takes.
pub range: Range<usize>,
pub character: SpecialCharacter,
}

/// The zero-width, control and special space characters of `text`, as the
/// macOS app's "Show invisible characters" marks them. `line_breaks` is for
/// a one-line view, which draws no break for LF or CR.
pub fn special_characters(text: &str, line_breaks: bool) -> SpecialCharacters<'_> {
SpecialCharacters {
text,
chars: text.char_indices(),
line_breaks,
tag_sequence: false,
found: 0,
}
}

pub struct SpecialCharacters<'a> {
text: &'a str,
chars: std::str::CharIndices<'a>,
line_breaks: bool,
// Whether the characters so far end in an emoji tag sequence's base and tags.
tag_sequence: bool,
found: usize,
}

impl Iterator for SpecialCharacters<'_> {
type Item = Classified;

fn next(&mut self) -> Option<Classified> {
while self.found < MAX_MARKS {
let (index, character) = self.chars.next()?;
let in_tag_sequence = self.tag_sequence;
let value = u32::from(character);
self.tag_sequence = value == EMOJI_TAG_BASE || (is_tag(value) && in_tag_sequence);
let end = index + character.len_utf8();
let Some(kind) = self.classify(value, index..end, in_tag_sequence) else {
continue;
};
self.found += 1;
return Some(Classified {
range: index..end,
character: kind,
});
}
None
}
}

impl SpecialCharacters<'_> {
fn classify(&self, value: u32, range: Range<usize>, in_tag_sequence: bool) -> Option<SpecialCharacter> {
let marker = |label| Some(SpecialCharacter::Marker(label));
match value {
0x0A | 0x0D if self.line_breaks => marker(control_label(value)),
0x09 | 0x0A | 0x0D => None,
0x00..=0x1F | 0x7F..=0x9F => marker(control_label(value)),
0x2028 | 0x2029 | 0xFFF9..=0xFFFB => marker(label(value)),
0x00A0 | 0x1680 | 0x2000..=0x200A | 0x202F | 0x205F | 0x3000 => Some(SpecialCharacter::BlankSpace),
_ if is_default_ignorable(value) && !self.is_exempt(value, range, in_tag_sequence) => marker(label(value)),
_ => None,
}
}

// Each of these shapes the characters around it, as a joiner inside an
// emoji or a variation selector does, so marking it would break what the
// reader sees.
fn is_exempt(&self, value: u32, range: Range<usize>, in_tag_sequence: bool) -> bool {
match value {
0x034F | 0x115F | 0x1160 | 0x17B4 | 0x17B5 | 0x180B..=0x180D | 0x180F => true,
0xFE00..=0xFE0F | 0xE0100..=0xE01EF => true,
0x200C | 0x200D => self.joins_non_ascii(range),
_ if is_tag(value) => in_tag_sequence,
_ => false,
}
}

fn joins_non_ascii(&self, range: Range<usize>) -> bool {
let before = self.text[..range.start].chars().next_back();
let after = self.text[range.end..].chars().next();
before.into_iter().chain(after).any(|neighbour| !neighbour.is_ascii())
}
}

fn is_tag(value: u32) -> bool {
(0xE0020..=0xE007F).contains(&value)
}

fn is_default_ignorable(value: u32) -> bool {
matches!(
value,
0x00AD
| 0x034F
| 0x061C
| 0x115F..=0x1160
| 0x17B4..=0x17B5
| 0x180B..=0x180F
| 0x200B..=0x200F
| 0x202A..=0x202E
| 0x2060..=0x206F
| 0x3164
| 0xFE00..=0xFE0F
| 0xFEFF
| 0xFFA0
| 0xFFF0..=0xFFF8
| 0x1BCA0..=0x1BCA3
| 0x1D173..=0x1D17A
| 0xE0000..=0xE0FFF
)
}

fn control_label(value: u32) -> Cow<'static, str> {
let named = match value {
0x00..=0x1F => usize::try_from(value).ok().and_then(|index| C0_LABELS.get(index)),
0x7F => Some(&"DEL"),
0x80..=0x9F => usize::try_from(value - 0x80)
.ok()
.and_then(|index| C1_LABELS.get(index)),
_ => None,
};
named.map_or_else(|| hex_label(value), |label| Cow::Borrowed(*label))
}

fn label(value: u32) -> Cow<'static, str> {
let named = match value {
0x00AD => "SHY",
0x061C => "ALM",
0x180E => "MVS",
0x200B => "ZWSP",
0x200C => "ZWNJ",
0x200D => "ZWJ",
0x200E => "LRM",
0x200F => "RLM",
0x2028 => "LSEP",
0x2029 => "PSEP",
0x202A => "LRE",
0x202B => "RLE",
0x202C => "PDF",
0x202D => "LRO",
0x202E => "RLO",
0x2060 => "WJ",
0x2066 => "LRI",
0x2067 => "RLI",
0x2068 => "FSI",
0x2069 => "PDI",
0x206A => "ISS",
0x206B => "ASS",
0x206C => "IAFS",
0x206D => "AAFS",
0x206E => "NADS",
0x206F => "NODS",
0xFEFF => "BOM",
0xFFF9 => "IAA",
0xFFFA => "IAS",
0xFFFB => "IAT",
_ => return hex_label(value),
};
Cow::Borrowed(named)
}

fn hex_label(value: u32) -> Cow<'static, str> {
Cow::Owned(format!("{value:04X}"))
}

/// A one-line view's text with each special character written as its mark.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Revealed {
pub text: String,
pub marks: Vec<Mark>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Mark {
/// Bytes of the revealed text the mark takes.
pub range: Range<usize>,
pub labelled: bool,
}

/// `None` when `text` holds nothing to mark, so a plain value costs no copy.
pub fn reveal(text: &str) -> Option<Revealed> {
let mut found = special_characters(text, true).peekable();
found.peek()?;
let mut shown = String::with_capacity(text.len() + 8);
let mut marks = Vec::new();
let mut copied = 0;
for Classified { range, character } in found {
shown.push_str(&text[copied..range.start]);
let start = shown.len();
let labelled = match character {
SpecialCharacter::Marker(label) => {
shown.push_str(&label);
true
}
SpecialCharacter::BlankSpace => {
shown.push_str(&text[range.clone()]);
false
}
};
marks.push(Mark {
range: start..shown.len(),
labelled,
});
copied = range.end;
}
shown.push_str(&text[copied..]);
Some(Revealed { text: shown, marks })
}

#[cfg(test)]
mod tests {
use super::*;

fn marked(text: &str, line_breaks: bool) -> Vec<(Range<usize>, SpecialCharacter)> {
special_characters(text, line_breaks)
.map(|found| (found.range, found.character))
.collect()
}

fn marker(label: &str) -> SpecialCharacter {
SpecialCharacter::Marker(Cow::Owned(label.to_owned()))
}

#[test]
fn plain_text_spaces_and_tabs_are_not_marked() {
assert!(marked("plain text\twith a tab", true).is_empty());
assert!(marked("ünïcödé 日本語", true).is_empty());
assert_eq!(reveal("plain text"), None);
}

#[test]
fn line_breaks_are_marked_only_in_a_one_line_view() {
assert!(marked("one\ntwo\r\n", false).is_empty());
assert_eq!(
marked("one\ntwo\r\n", true),
[(3..4, marker("LF")), (7..8, marker("CR")), (8..9, marker("LF"))]
);
}

#[test]
fn controls_take_their_names() {
assert_eq!(
marked("\u{1}\u{1b}\u{7f}\u{85}\u{9f}", false),
[
(0..1, marker("SOH")),
(1..2, marker("ESC")),
(2..3, marker("DEL")),
(3..5, marker("NEL")),
(5..7, marker("APC")),
]
);
}

#[test]
fn special_spaces_keep_their_width() {
for space in [
'\u{a0}', '\u{1680}', '\u{2000}', '\u{2007}', '\u{200a}', '\u{202f}', '\u{205f}', '\u{3000}',
] {
let text = format!("a{space}b");
assert_eq!(
marked(&text, false),
[(1..1 + space.len_utf8(), SpecialCharacter::BlankSpace)],
"U+{:04X}",
u32::from(space)
);
}
}

#[test]
fn format_characters_take_their_short_names() {
let cases = [
('\u{ad}', "SHY"),
('\u{200b}', "ZWSP"),
('\u{200e}', "LRM"),
('\u{2028}', "LSEP"),
('\u{2029}', "PSEP"),
('\u{202e}', "RLO"),
('\u{2060}', "WJ"),
('\u{2066}', "LRI"),
('\u{feff}', "BOM"),
('\u{fff9}', "IAA"),
('\u{3164}', "3164"),
('\u{2061}', "2061"),
('\u{1d173}', "1D173"),
('\u{e0001}', "E0001"),
];
for (character, label) in cases {
let text = format!("x{character}y");
assert_eq!(
marked(&text, false),
[(1..1 + character.len_utf8(), marker(label))],
"U+{:04X}",
u32::from(character)
);
}
}

#[test]
fn joiners_inside_non_ascii_text_are_left_alone() {
assert!(marked("👨\u{200d}👩", false).is_empty());
assert!(marked("क\u{200c}ष", false).is_empty());
assert_eq!(marked("a\u{200d}b", false), [(1..4, marker("ZWJ"))]);
assert_eq!(marked("\u{200c}", false), [(0..3, marker("ZWNJ"))]);
}

#[test]
fn shaping_selectors_and_combining_ignorables_are_left_alone() {
assert!(marked("✌\u{fe0f}", false).is_empty());
assert!(marked("a\u{e0100}", false).is_empty());
assert!(marked("e\u{34f}\u{180b}\u{17b4}\u{115f}", false).is_empty());
}

#[test]
fn tags_mark_only_outside_an_emoji_tag_sequence() {
let flag = "\u{1f3f4}\u{e0067}\u{e0062}\u{e0073}\u{e0063}\u{e0074}\u{e007f}";
assert!(marked(flag, false).is_empty());
assert_eq!(marked("a\u{e0067}", false), [(1..5, marker("E0067"))]);
let broken = format!("{flag}x\u{e0067}");
assert_eq!(
marked(&broken, false),
[(broken.len() - 4..broken.len(), marker("E0067"))]
);
}

#[test]
fn marks_stop_at_the_cap() {
let text = "\u{1}".repeat(MAX_MARKS + 10);
assert_eq!(special_characters(&text, false).count(), MAX_MARKS);
}

#[test]
fn reveal_writes_labels_and_keeps_special_spaces() {
let revealed = reveal("a\u{200b}b\u{a0}c\nd").expect("marks");
assert_eq!(revealed.text, "aZWSPb\u{a0}cLFd");
assert_eq!(
revealed.marks,
[
Mark {
range: 1..5,
labelled: true
},
Mark {
range: 6..8,
labelled: false
},
Mark {
range: 9..11,
labelled: true
},
]
);
}
}
Loading
Loading