@@ -87,7 +87,7 @@ fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> {
90−pub fn list_languages(assets: &HighlightingAssets, term_width: usize) -> Result<()> {
90+pub fn list_languages(assets: &HighlightingAssets, config: &Config) -> Result<()> {
91 let mut languages = assets
91 let mut languages = assets
92 .syntax_set
92 .syntax_set
93 .syntaxes()
93 .syntaxes()
@@ -105,11 +105,17 @@ pub fn list_languages(assets: &HighlightingAssets, term_width: usize) -> Result<
105 let comma_separator = ", ";
105 let comma_separator = ", ";
106 let separator = " ";
106 let separator = " ";
107 // Line-wrapping for the possible file extension overflow.
107 // Line-wrapping for the possible file extension overflow.
108− let desired_width = term_width - longest - separator.len();
108+ let desired_width = config.term_width - longest - separator.len();
110 let stdout = io::stdout();
110 let stdout = io::stdout();
111 let mut stdout = stdout.lock();
111 let mut stdout = stdout.lock();
113+ let style = if config.colored_output {
113 for lang in languages {
119 for lang in languages {
114 write!(stdout, "{:width$}{}", lang.name, separator, width = longest)?;
120 write!(stdout, "{:width$}{}", lang.name, separator, width = longest)?;
@@ -126,7 +132,7 @@ pub fn list_languages(assets: &HighlightingAssets, term_width: usize) -> Result<
128 num_chars += new_chars;
134 num_chars += new_chars;
129− write!(stdout, "{}", Green.paint(&word[..]))?;
135+ write!(stdout, "{}", style.paint(&word[..]))?;
130 if extension.peek().is_some() {
136 if extension.peek().is_some() {
131 write!(stdout, "{}", comma_separator)?;
137 write!(stdout, "{}", comma_separator)?;
@@ -148,15 +154,21 @@ pub fn list_themes(assets: &HighlightingAssets, cfg: &Config) -> Result<()> {
148 let stdout = io::stdout();
154 let stdout = io::stdout();
149 let mut stdout = stdout.lock();
155 let mut stdout = stdout.lock();
157+ if config.colored_output {
151− for (theme, _) in themes.iter() {
158+ for (theme, _) in themes.iter() {
152− writeln!(
159+ writeln!(
154− "Theme: {}\n",
161+ "Theme: {}\n",
155− Style::new().bold().paint(theme.to_string())
162+ Style::new().bold().paint(theme.to_string())
157− config.theme = theme.to_string();
164+ config.theme = theme.to_string();
158− let _controller = Controller::new(&config, &assets).run();
165+ let _controller = Controller::new(&config, &assets).run();
169+ for (theme, _) in themes.iter() {
159− writeln!(stdout)?;
170+ writeln!(stdout, "{}", theme)?;
@@ -177,7 +189,7 @@ fn run() -> Result<bool> {
177 let assets = HighlightingAssets::new();
189 let assets = HighlightingAssets::new();
179 if app.matches.is_present("list-languages") {
191 if app.matches.is_present("list-languages") {
180− list_languages(&assets, config.term_width)?;
192+ list_languages(&assets, &config)?;
183 } else if app.matches.is_present("list-themes") {
195 } else if app.matches.is_present("list-themes") {