501b0f6898df
show unselected entries as Koh 2 does, with only the mark and ID greyed, and sit the entries 15% tighter than Koh 2's spread (3.0.67)
- time
- 2026-09-26 13:29 UTC · 2 weeks ago
- machine
- Junes-MacBook-Pro.local
- agent
- claude-opus-5-5
- session
- history view
- parent
- ebe6c3ba542a
↓ koh-501b0f68.tar.gzatlas at this save
files changed4 files
VERSION+1 −1src/view/view.v+12 −11src/view/view_test.v+23 −0v.mod+1 −1src/view/view.v+12 −11
@@ -395,7 +395,8 @@395395 396396 // list_body lays the entries out in up to six equal blocks, each a header, a397397 // message, the selected entry's details and a separator, with the spare rows398-// split above and below so the list spreads over the whole screen.398+// split above and below. Koh 2 spread the blocks over the whole body; June399+// asked for them 15% tighter, which leaves the last rows empty.399400 fn list_body(screen Screen, body int, cols int) []string {400401 if screen.items.len == 0 {401402 return [' ${fmt.muted('no results')}']@@ -408,7 +409,9 @@408409 start := window_start(screen.selected, slots, screen.items.len)409410 mut lines := []string{}410411 for slot in 0 .. slots {411- height := body / slots + if slot < body % slots { 1 } else { 0 }412+ spread := body / slots + if slot < body % slots { 1 } else { 0 }413+ tighter := (spread * 85 + 50) / 100414+ height := if tighter > 4 { tighter } else { spread }412415 spare := if height > 4 { height - 4 } else { 0 }413416 for _ in 0 .. spare / 2 {414417 lines << ''@@ -418,7 +421,7 @@418421 entry := screen.items[index]419422 selected := index == screen.selected420423 lines << entry_header(entry, selected, screen)421- lines << entry_message(entry, selected, screen)424+ lines << entry_message(entry, screen)422425 lines << if selected { entry_meta(entry) } else { '' }423426 } else {424427 lines << ['', '', '']@@ -444,8 +447,8 @@444447 }445448 446449 // entry_header is the mark, ID, time and date. HEAD has its own mark; every447-// other save is a dot. The selected save's ID is gold and everything else is448-// greyed out around it.450+// other save is a dot. As in Koh 2, only the ID tells the selected save apart:451+// gold when selected, grey otherwise, while time, date and message stay plain.449452 fn entry_header(save history.Save, selected bool, screen Screen) string {450453 head := save.id == screen.head451454 flagged := is_flagged(screen, save.id)@@ -472,16 +475,14 @@472475 labels << '[replayed away]'473476 }474477 if labels.len > 0 {475- line += ' ${fmt.muted(labels.join(' '))}'478+ line += ' ${labels.join(' ')}'476479 }477- stamp := '${fmt.hour_of(save.created_at)} ${fmt.date_of(save.created_at)}'478- line += ' ${if selected { stamp } else { fmt.muted(stamp) }}'479- return line480+ return line + ' ${fmt.hour_of(save.created_at)} ${fmt.date_of(save.created_at)}'480481 }481482 482-fn entry_message(save history.Save, selected bool, screen Screen) string {483+fn entry_message(save history.Save, screen Screen) string {483484 warning := if is_flagged(screen, save.id) { fmt.red('⚠ ') } else { '' }484- return ' ${warning}${if selected { save.message } else { fmt.muted(save.message) }}'485+ return ' ${warning}${save.message}'485486 }486487 487488 fn entry_meta(save history.Save) string {src/view/view_test.v+23 −0
@@ -288,3 +288,26 @@288288 assert last.ends_with('flagged [70c78decf279]')289289 assert fmt.visible_width(last) <= 50290290 }291+292+// Koh 2 spreads six entries over the whole body; June asked for them 15%293+// tighter, with the rows that frees left empty below the list.294+fn test_entries_sit_fifteen_percent_tighter_than_koh_2() {295+ mut items := []history.Save{}296+ for i in 0 .. 10 {297+ items << save('id${i:09}', 'message ${i}', false)298+ }299+ mut session := list_session(items)300+ session.screen.rows = 51 // a body of 48 rows: Koh 2's blocks are 8 tall301+ lines := plain(frame_lines(session))302+ assert lines.len == 51303+ mut headers := []int{}304+ for i, line in lines {305+ if line.starts_with(' · ') || line.starts_with(' ▸ ') {306+ headers << i307+ }308+ }309+ assert headers.len == 6310+ for i in 1 .. headers.len {311+ assert headers[i] - headers[i - 1] == 7312+ }313+}v.mod+1 −1
@@ -1,6 +1,6 @@11 Module {22 name: 'koh3'3- version: '3.0.66'3+ version: '3.0.67'44 description: 'One SQLite file per repo, one line of history.'55 license: 'MIT'66 }