Skip to content
Merged
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
9 changes: 9 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,15 @@ impl App {
.transient_message
.replace(format!("Failed to copy to clipboard: {e}")),
};
} else if let Some((index, row)) = self.rows_view.get_row_value() {
match self.clipboard.as_mut().map(|c| c.set_text(&row)) {
Ok(_) => self
.transient_message
.replace(format!("Copied row {} to clipboard", index)),
Err(e) => self
.transient_message
.replace(format!("Failed to copy to clipboard: {e}")),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if there is a way to reduce the duplication between this if block and the above.

};
}
}
Control::Reset => {
Expand Down
9 changes: 9 additions & 0 deletions src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,15 @@ impl RowsView {
None
}

pub fn get_row_value(&self) -> Option<(usize, String)> {
if let Some(row_index) = self.selection.row.index() {
if let Some(row) = self.rows().get(row_index as usize) {
return Some((row.record_num, row.fields.join("\t")));
}
}
None
}

pub fn num_rows(&self) -> u64 {
self.num_rows
}
Expand Down