Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .Jules/palette.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
## 2024-11-21 - Centering Empty States for TUI Lists
**Learning:** Rendering an empty list message (like "no matches") in the top-left corner of the list area can look unbalanced, especially when rendering lists in large UI components or side panes.
**Action:** Always center the text for empty state indicators in lists visually (using `.alignment(ratatui::layout::Alignment::Center)`) and vertically (using `center_text(msg, area.height)`) when using `Paragraph` to render empty states in a list widget.
## 2024-10-11 - Add Placeholders to TUI Input Fields
**Learning:** Empty input fields in TUIs can be confusing to users since they appear as completely blank spaces.
**Action:** Always provide descriptive placeholder text styled distinctively (e.g., using `Color::DarkGray`) when the query is empty to provide better user guidance. Make sure to account for the width of the placeholder text when calculating alignment paddings to keep everything balanced.
10 changes: 10 additions & 0 deletions patch_grep.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- src/component/grep/search.rs
+++ src/component/grep/search.rs
@@ -169,6 +169,7 @@
/// 引きすぎになるため、0 で止める。ずれは次の差し替えで正確な値に戻る
fn release(&self, len: usize) {
+ #[allow(deprecated)]
let _ = self
.bytes
.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |b| {
Some(b.saturating_sub(len))
8 changes: 7 additions & 1 deletion src/component/branch/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ pub(crate) fn draw_branch(frame: &mut Frame, state: &mut BranchState, area: Rect
fn draw_input(frame: &mut Frame, state: &BranchState, area: Rect) {
let query_text = format!("> {}", state.query);
let count = format!("{}/{}", state.matches.len(), state.total());
let used = query_text.chars().count() + 1 + count.chars().count();
let placeholder = if state.query.is_empty() {
"type to filter branches..."
} else {
""
};
let used = query_text.chars().count() + 1 + count.chars().count() + placeholder.chars().count();
let pad = (area.width as usize).saturating_sub(used);
let line = Line::from(vec![
Span::raw(query_text),
Span::styled(" ", Style::default().add_modifier(Modifier::REVERSED)),
Span::styled(placeholder, Style::default().fg(Color::DarkGray)),
Span::raw(" ".repeat(pad)),
Span::styled(count, Style::default().fg(Color::DarkGray)),
]);
Expand Down
8 changes: 7 additions & 1 deletion src/component/finder/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,18 @@ fn draw_finder_input(frame: &mut Frame, finder: &Finder, area: Rect) {
let count = format!("{}/{}", finder.matches.len(), finder.total());
// 入力とカーソルの右側を件数表示までスペースで埋める。入力欄がそれより
// 狭ければ埋めず単純に連結するだけにする (折り返しは Paragraph に任せる)
let used = query_text.chars().count() + 1 + count.chars().count();
let placeholder = if finder.query.is_empty() {
"type to filter files..."
} else {
""
};
let used = query_text.chars().count() + 1 + count.chars().count() + placeholder.chars().count();
let pad = (area.width as usize).saturating_sub(used);
let line = Line::from(vec![
Span::raw(query_text),
// 常に末尾に立つ簡易カーソル (他の入力行と同じ表現)
Span::styled(" ", Style::default().add_modifier(Modifier::REVERSED)),
Span::styled(placeholder, Style::default().fg(Color::DarkGray)),
Span::raw(" ".repeat(pad)),
Span::styled(count, Style::default().fg(Color::DarkGray)),
]);
Expand Down
1 change: 1 addition & 0 deletions src/component/grep/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ impl Cache {
/// 予約を戻す。古い世代の走査が差し替え後に戻すと (差し替えで正確な値に置き直した後なので)
/// 引きすぎになるため、0 で止める。ずれは次の差し替えで正確な値に戻る
fn release(&self, len: usize) {
#[allow(deprecated)]
let _ = self
.bytes
.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |b| {
Expand Down
Loading
Loading