Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 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
9712f7a
feat(linux-grid): choose how cells show dates
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
7c567cc
Merge branch 'feat/linux-invisible-chars' into feat/linux-date-format
sedax90 Nov 8, 2026
ab70c2d
fix(linux-grid): share live display preferences across grids
datlechin Nov 8, 2026
49e7b2f
fix(linux-grid): show date formats as examples so the combo does not …
sedax90 Nov 8, 2026
1d3f362
fix(linux-grid): merge updated NULL display behavior
datlechin Nov 8, 2026
d87631b
fix(linux-grid): keep the date format row to one line
sedax90 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
f820206
feat(linux-grid): share precise date formats with grids and find
datlechin Nov 8, 2026
d9f9728
fix(linux-grid): preserve leap-second fractions in date formats
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
d0ef64a
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
9c29876
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
1cca648
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
9b501f2
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
67ba8de
Merge commit '60f17aa37' into feat/linux-date-format
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
2452c0c
Merge commit 'dcab0cc0b' into feat/linux-date-format
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
fc0e68c
Merge commit 'a8ec7e9fd' into feat/linux-date-format
datlechin Nov 9, 2026
2974447
Merge remote-tracking branch 'origin/main' into feat/linux-date-format
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
d8ffa9a
Merge commit '5b0732c15' into feat/linux-date-format
datlechin Nov 9, 2026
f241535
feat(linux-grid): mark zero-width, control and special space characte…
datlechin Nov 9, 2026
68ca9c2
Merge commit 'f24153571' into feat/linux-date-format
datlechin Nov 9, 2026
65337b1
fix(linux-grid): size automatic columns to the marks their cells draw
datlechin Nov 9, 2026
89f23c6
Merge commit '65337b1b3' into feat/linux-date-format
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
743fbb3
Merge commit '70cbadc0d' into feat/linux-date-format
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
29a9a30
Merge commit 'b0c55edf561bf07bca02a57668daa4d4148955d0' 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
e99a89a
Merge commit '2cc00b8b2fb49ac9591d2ee85a06237707aacfcd' 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
52 changes: 46 additions & 6 deletions core/crates/core/src/export/value_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,9 @@ fn second_digits(kind: &ColumnKind) -> Option<u8> {
kind.fractional_digits().map(|digits| digits.min(9))
}

/// The fractional second, at the digits the column declares.
///
/// With no declared precision the fraction is the one the value
/// carries, trimmed, because inventing digits would claim a precision
/// the column never promised.
fn fraction_text(nanos: u32, digits: Option<u8>) -> String {
let nanos = nanos.min(999_999_999);
// Chrono encodes a leap second above one billion nanos; %S already prints its extra second.
let nanos = nanos % 1_000_000_000;
let Some(digits) = digits else {
return match nanos {
0 => String::new(),
Expand Down Expand Up @@ -461,6 +457,50 @@ mod tests {
);
}

#[test]
fn timestamp_leap_seconds_keep_their_fraction_at_each_precision() {
let value = Value::Timestamp(Temporal::Finite(
NaiveDate::from_ymd_opt(2016, 12, 31)
.expect("a date")
.and_hms_nano_opt(23, 59, 59, 1_123_000_000)
.expect("a leap second"),
));
for (digits, expected) in [
(Some(0), "2016-12-31 23:59:60"),
(Some(3), "2016-12-31 23:59:60.123"),
(Some(6), "2016-12-31 23:59:60.123000"),
(Some(9), "2016-12-31 23:59:60.123000000"),
(None, "2016-12-31 23:59:60.123"),
] {
let column = typed("timestamp", stamp(digits, TemporalZone::Naive));
assert_eq!(value_text(&value, &column).as_deref(), Some(expected), "{digits:?}");
}
assert_eq!(value_to_text(&value).as_deref(), Some("2016-12-31 23:59:60.123"));
}

#[test]
fn offset_timestamp_leap_seconds_keep_their_fraction_at_each_precision() {
let timestamp = chrono::DateTime::parse_from_rfc3339("2017-01-01T05:29:60.123456789+05:30")
.expect("a leap second with an offset");
let value = Value::TimestampTz(Temporal::Finite(crate::value::OffsetTimestamp::from_datetime(
timestamp,
)));
for (digits, expected) in [
(Some(0), "2017-01-01 05:29:60+05:30"),
(Some(3), "2017-01-01 05:29:60.123+05:30"),
(Some(6), "2017-01-01 05:29:60.123456+05:30"),
(Some(9), "2017-01-01 05:29:60.123456789+05:30"),
(None, "2017-01-01 05:29:60.123456789+05:30"),
] {
let column = typed("timestamptz", stamp(digits, TemporalZone::Offset));
assert_eq!(value_text(&value, &column).as_deref(), Some(expected), "{digits:?}");
}
assert_eq!(
value_to_text(&value).as_deref(),
Some("2017-01-01 05:29:60.123456789+05:30")
);
}

#[test]
fn value_text_time_precision_from_kind() {
let value = Value::Time(SqlTime::new(false, 12, 0, 0, 123_456_000).expect("a time"));
Expand Down
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/changelog.d/4142.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Preferences can show dates and timestamps in cells as ISO, US or EU dates, with or without the time.
110 changes: 72 additions & 38 deletions linux/crates/app/src/services/grid/column_width.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ use tablepro_core::Value;
use tablepro_core::column::{ColumnKind, TemporalZone, TextLength};
use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};

use super::display_text::display_text;
use super::display_text::display_text_formatted;
use super::{CellDisplay, GridColumn};
use tablepro_linux_platform::settings::DateFormat;

const MIN_CHARS: u32 = 4;
const TEXT_MAX_CHARS: u32 = 40;
Expand All @@ -15,25 +16,22 @@ const TYPICAL_CHARS: u32 = 20;
/// A number of a type that sets no precision.
const TYPICAL_DIGITS: u32 = 10;

/// The monospace cells a column's values open at: its widest sampled
/// value. Text is capped so one long value does not push the rest off
/// screen; a number or a date is never cut. The header, drawn in another
/// font, is the caller's to measure.
pub fn default_width_chars<'a>(column: &GridColumn, sample: impl IntoIterator<Item = &'a Value>) -> u32 {
let widest = widest_cells(column, sample);
pub fn default_width_chars<'a>(
column: &GridColumn,
sample: impl IntoIterator<Item = &'a Value>,
date_format: DateFormat,
) -> u32 {
let widest = widest_cells(column, sample, date_format);
let cells = match column.display() {
CellDisplay::Bool => BOOL_CHARS,
CellDisplay::Number => widest,
CellDisplay::Temporal => widest.max(spelled_chars(&column.column_type.kind).unwrap_or(0)),
CellDisplay::Temporal => widest.max(spelled_chars(&column.column_type.kind, date_format).unwrap_or(0)),
CellDisplay::Text | CellDisplay::Json | CellDisplay::Binary => widest.min(TEXT_MAX_CHARS),
};
cells.max(MIN_CHARS)
}

/// The monospace cells a column's values open at in a table that holds
/// no rows: a value its type leads one to expect. A bounded type gives
/// its widest value, text no wider than a name.
pub fn typical_width_chars(column: &GridColumn) -> u32 {
pub fn typical_width_chars(column: &GridColumn, date_format: DateFormat) -> u32 {
let kind = &column.column_type.kind;
let typical = match kind {
ColumnKind::Bool(_) => BOOL_CHARS,
Expand All @@ -46,56 +44,53 @@ pub fn typical_width_chars(column: &GridColumn) -> u32 {
ColumnKind::Text {
length: TextLength::Varying(length) | TextLength::Fixed(length),
} => (*length).min(TYPICAL_CHARS),
_ => spelled_chars(kind).unwrap_or(TYPICAL_CHARS),
_ => spelled_chars(kind, date_format).unwrap_or(TYPICAL_CHARS),
};
typical.clamp(MIN_CHARS, TEXT_MAX_CHARS)
}

/// The values the column's type spells out, cut at the cap, for the
/// caller to measure.
pub fn typical_texts(column: &GridColumn) -> Vec<String> {
spelled(&column.column_type.kind)
pub fn typical_texts(column: &GridColumn, date_format: DateFormat) -> Vec<String> {
spelled(&column.column_type.kind, date_format)
.into_iter()
.map(|text| within_cap(text).to_owned())
.map(|text| within_cap(&text).to_owned())
.collect()
}

/// The width of a column that turned out to hold only numbers, as an
/// untyped PostgreSQL result does: a number is never cut.
pub fn number_width_chars<'a>(column: &GridColumn, sample: impl IntoIterator<Item = &'a Value>) -> u32 {
widest_cells(column, sample).max(MIN_CHARS)
widest_cells(column, sample, DateFormat::Iso).max(MIN_CHARS)
}

/// The column's name as its header draws it, cut at the cap.
pub fn header_text(column: &GridColumn) -> &str {
within_cap(&column.name)
}

fn widest_cells<'a>(column: &GridColumn, sample: impl IntoIterator<Item = &'a Value>) -> u32 {
fn widest_cells<'a>(column: &GridColumn, sample: impl IntoIterator<Item = &'a Value>, date_format: DateFormat) -> u32 {
let mut scratch = String::new();
sample
.into_iter()
.take(SAMPLE_ROWS)
.filter(|value| !value.is_null())
.map(|value| cells(display_text(value, &column.column_type, &mut scratch).text))
.map(|value| cells(display_text_formatted(value, &column.column_type, date_format, &mut scratch).text))
.max()
.unwrap_or(0)
}

/// The sampled values for the caller to measure, as the cells draw them
/// and cut at the cap: of the plain ASCII ones, which a monospace font
/// draws one cell each, the one that takes the most cells, and every
/// other one, since its characters may draw in a fallback font. A number
/// column is measured in tabular digits instead.
pub fn sampled_texts<'a>(column: &GridColumn, sample: impl IntoIterator<Item = &'a Value>) -> Vec<String> {
pub fn sampled_texts<'a>(
column: &GridColumn,
sample: impl IntoIterator<Item = &'a Value>,
date_format: DateFormat,
) -> Vec<String> {
if column.display() == CellDisplay::Number {
return Vec::new();
}
let mut scratch = String::new();
let mut widest_plain: Option<(u32, String)> = None;
let mut others = Vec::new();
for value in sample.into_iter().take(SAMPLE_ROWS).filter(|value| !value.is_null()) {
let text = within_cap(display_text(value, &column.column_type, &mut scratch).text);
let text = within_cap(display_text_formatted(value, &column.column_type, date_format, &mut scratch).text);
if !is_plain(text) {
others.push(text.to_owned());
continue;
Expand All @@ -111,12 +106,8 @@ pub fn sampled_texts<'a>(column: &GridColumn, sample: impl IntoIterator<Item = &
others
}

/// The values of a type that holds nothing wider: a date or a time
/// without the fractional seconds a sample adds when the column holds
/// them, a UUID, or an enum's labels, as many as a sample holds. A MySQL
/// SET joins its labels, so it has none.
fn spelled(kind: &ColumnKind) -> Vec<&str> {
match kind {
fn spelled(kind: &ColumnKind, date_format: DateFormat) -> Vec<String> {
let values: Vec<&str> = match kind {
ColumnKind::Date => vec!["0000-00-00"],
ColumnKind::Time { with_offset: false, .. } => vec!["00:00:00"],
ColumnKind::Time { with_offset: true, .. } => vec!["00:00:00+00:00"],
Expand All @@ -131,11 +122,15 @@ fn spelled(kind: &ColumnKind) -> Vec<&str> {
multiple: false,
} => labels.iter().take(SAMPLE_ROWS).map(String::as_str).collect(),
_ => Vec::new(),
}
};
values
.into_iter()
.map(|text| super::date_display::width_text(text, kind, date_format))
.collect()
}

fn spelled_chars(kind: &ColumnKind) -> Option<u32> {
spelled(kind).into_iter().map(cells).max()
fn spelled_chars(kind: &ColumnKind, date_format: DateFormat) -> Option<u32> {
spelled(kind, date_format).iter().map(|text| cells(text)).max()
}

/// The cells `text` takes in a monospace font, where a Chinese or
Expand Down Expand Up @@ -169,9 +164,26 @@ mod tests {
use tablepro_core::column::{BoolStorage, ColumnKind, IntegerKind, IntegerWidth, TemporalZone, TextLength};
use tablepro_core::value::{SqlDecimal, Temporal};

use super::{default_width_chars, number_width_chars, sampled_texts, typical_texts, typical_width_chars};
use super::{DateFormat, number_width_chars};
use crate::services::grid::GridColumn;
use crate::services::grid::test_columns::result_only;

fn default_width_chars<'a>(column: &GridColumn, sample: impl IntoIterator<Item = &'a Value>) -> u32 {
super::default_width_chars(column, sample, DateFormat::Iso)
}

fn sampled_texts<'a>(column: &GridColumn, sample: impl IntoIterator<Item = &'a Value>) -> Vec<String> {
super::sampled_texts(column, sample, DateFormat::Iso)
}

fn typical_width_chars(column: &GridColumn) -> u32 {
super::typical_width_chars(column, DateFormat::Iso)
}

fn typical_texts(column: &GridColumn) -> Vec<String> {
super::typical_texts(column, DateFormat::Iso)
}

fn text() -> ColumnKind {
ColumnKind::Text {
length: TextLength::Unbounded,
Expand Down Expand Up @@ -431,4 +443,26 @@ mod tests {
"text has no widest"
);
}
#[test]
fn empty_timestamp_columns_size_the_selected_format_and_declared_fraction() {
let column = result_only(
"at",
ColumnKind::Timestamp {
fractional_digits: Some(6),
zone: TemporalZone::Offset,
},
);
for (format, width) in [
(DateFormat::Iso, 32),
(DateFormat::UsLong, 35),
(DateFormat::EuLong, 32),
(DateFormat::IsoDate, 10),
(DateFormat::UsShort, 10),
(DateFormat::EuShort, 10),
] {
assert_eq!(super::default_width_chars(&column, &[], format), width);
assert_eq!(super::typical_width_chars(&column, format), width);
assert_eq!(super::typical_texts(&column, format)[0].len(), width as usize);
}
}
}
Loading
Loading