diff --git a/src/app.rs b/src/app.rs index be65a9d..f2f0bdd 100644 --- a/src/app.rs +++ b/src/app.rs @@ -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}")), + }; } } Control::Reset => { diff --git a/src/view.rs b/src/view.rs index e09615b..9f20474 100644 --- a/src/view.rs +++ b/src/view.rs @@ -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 }