refactor: Improve comfy_table usage and consistency
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -69,12 +69,13 @@ fn show_item(
|
||||
let item_tags: Vec<String> = item_with_meta.tags.iter().map(|t| t.name.clone()).collect();
|
||||
|
||||
let mut table = Table::new();
|
||||
if std::io::stdout().is_terminal() {
|
||||
table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS);
|
||||
} else {
|
||||
table.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS)
|
||||
.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
|
||||
if !std::io::stdout().is_terminal() {
|
||||
table.force_no_tty();
|
||||
}
|
||||
|
||||
// Add all the rows
|
||||
|
||||
@@ -62,12 +62,13 @@ pub fn mode_list(
|
||||
debug!("Terminal width: {}", term_width);
|
||||
|
||||
let mut table = Table::new();
|
||||
if stdout().is_terminal() {
|
||||
table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS);
|
||||
} else {
|
||||
table.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS)
|
||||
.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
|
||||
if !stdout().is_terminal() {
|
||||
table.force_no_tty();
|
||||
}
|
||||
|
||||
// Create header row
|
||||
|
||||
@@ -19,13 +19,13 @@ use crate::meta_plugin::get_meta_plugin;
|
||||
|
||||
fn build_path_table(path_info: &PathInfo) -> Table {
|
||||
let mut path_table = Table::new();
|
||||
path_table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS)
|
||||
.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
|
||||
if std::io::stdout().is_terminal() {
|
||||
path_table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS);
|
||||
} else {
|
||||
path_table.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
if !std::io::stdout().is_terminal() {
|
||||
path_table.force_no_tty();
|
||||
}
|
||||
|
||||
path_table.set_header(vec![
|
||||
@@ -42,12 +42,13 @@ fn build_path_table(path_info: &PathInfo) -> Table {
|
||||
|
||||
fn build_config_table(settings: &config::Settings) -> Table {
|
||||
let mut config_table = Table::new();
|
||||
if std::io::stdout().is_terminal() {
|
||||
config_table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS);
|
||||
} else {
|
||||
config_table.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
config_table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS)
|
||||
.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
|
||||
if !std::io::stdout().is_terminal() {
|
||||
config_table.force_no_tty();
|
||||
}
|
||||
|
||||
config_table.set_header(vec![
|
||||
@@ -82,12 +83,13 @@ fn build_meta_plugins_configured_table(status_info: &StatusInfo) -> Option<Table
|
||||
sorted_meta_plugins.sort_by(|a, b| a.name.cmp(&b.name));
|
||||
|
||||
let mut table = Table::new();
|
||||
if std::io::stdout().is_terminal() {
|
||||
table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS);
|
||||
} else {
|
||||
table.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS)
|
||||
.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
|
||||
if !std::io::stdout().is_terminal() {
|
||||
table.force_no_tty();
|
||||
}
|
||||
|
||||
table.set_header(vec![
|
||||
|
||||
@@ -53,12 +53,13 @@ use crate::common::status::{MetaPluginInfo, CompressionInfo};
|
||||
|
||||
fn build_meta_plugin_table(meta_plugin_info: &std::collections::HashMap<String, MetaPluginInfo>) -> Table {
|
||||
let mut meta_plugin_table = Table::new();
|
||||
if std::io::stdout().is_terminal() {
|
||||
meta_plugin_table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS);
|
||||
} else {
|
||||
meta_plugin_table.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
meta_plugin_table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS)
|
||||
.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
|
||||
if !std::io::stdout().is_terminal() {
|
||||
meta_plugin_table.force_no_tty();
|
||||
}
|
||||
|
||||
meta_plugin_table.set_header(vec![
|
||||
@@ -121,12 +122,13 @@ fn build_meta_plugin_table(meta_plugin_info: &std::collections::HashMap<String,
|
||||
|
||||
fn build_compression_table(compression_info: &Vec<CompressionInfo>) -> Table {
|
||||
let mut compression_table = Table::new();
|
||||
if std::io::stdout().is_terminal() {
|
||||
compression_table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS);
|
||||
} else {
|
||||
compression_table.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
compression_table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS)
|
||||
.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
|
||||
if !std::io::stdout().is_terminal() {
|
||||
compression_table.force_no_tty();
|
||||
}
|
||||
|
||||
compression_table.set_header(vec![
|
||||
@@ -160,12 +162,13 @@ fn build_compression_table(compression_info: &Vec<CompressionInfo>) -> Table {
|
||||
|
||||
fn build_filter_plugin_table(filter_plugins: &Vec<crate::common::status::FilterPluginInfo>) -> Table {
|
||||
let mut filter_plugin_table = Table::new();
|
||||
if std::io::stdout().is_terminal() {
|
||||
filter_plugin_table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS);
|
||||
} else {
|
||||
filter_plugin_table.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
filter_plugin_table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS)
|
||||
.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
|
||||
if !std::io::stdout().is_terminal() {
|
||||
filter_plugin_table.force_no_tty();
|
||||
}
|
||||
|
||||
filter_plugin_table.set_header(vec![
|
||||
|
||||
Reference in New Issue
Block a user