git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 6/9] column: add column.ui for default column output settings

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Mar 20, 2011, 12:57 UTC
Message-ID
<1300625873-18435-7-git-send-email-pclouds@gmail.com>
In-Reply-To
<1300625873-18435-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Documentation/config.txt |   24 ++++++++++++++++++++++++
 column.c                 |   11 +++++++++++
 column.h                 |    3 +++
 3 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index c5e1835..7183712 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -805,6 +805,30 @@ color.ui::
 	terminal. When more specific variables of color.* are set, they always
 	take precedence over this setting. Defaults to false.
 
+column.ui::
+	Specify whether supported commands should output in columns.
+	This variable consists of a list of tokens separated by spaces
+	or commas:
++
+--
+`always`;;
+	always show in columns
+`never`;;
+	never show in columns
+`auto`;;
+	show in columns if the output is to the terminal
+`column`;;
+	fill columns before rows (default)
+`row`;;
+	fill rows before columns
+`dense`;;
+	make unequal size columns to utilize more space
+`nodense`;;
+	make equal size columns
+--
++
+	This option defaults to 'never'.
+
 commit.status::
 	A boolean to enable/disable inclusion of status information in the
 	commit message template when using an editor to prepare the commit
diff --git a/column.c b/column.c
index 69d42f8..7c1a6f1 100644
--- a/column.c
+++ b/column.c
@@ -2,6 +2,7 @@
 #include "column.h"
 #include "string-list.h"
 #include "parse-options.h"
+#include "color.h"
 #include "utf8.h"
 
 #define MODE(mode) ((mode) & COL_MODE)
@@ -21,6 +22,8 @@ struct column_data {
 	int *width;			/* index to the longest row in column */
 };
 
+int git_core_column;
+
 /* return length of 's' in letters, ANSI escapes stripped */
 static int item_length(int mode, const char *s)
 {
@@ -350,6 +353,14 @@ static int parse_string(int *mode, const char *value,
 	return 0;
 }
 
+int git_column_default_config(const char *var, const char *value, void *cb)
+{
+	if (!strcmp(var, "column.ui"))
+		return parse_string(&git_core_column, value, -1);
+
+	return git_color_default_config(var, value, cb);
+}
+
 int parseopt_column_callback(const struct option *opt,
 			     const char *arg, int unset)
 {
diff --git a/column.h b/column.h
index 48c6345..0f4190d 100644
--- a/column.h
+++ b/column.h
@@ -9,9 +9,12 @@
 #define COL_ANSI         (1 << 6)  /* Remove ANSI escapes from string length */
 #define COL_DENSE        (1 << 7)  /* Shrink columns when possible, making space for more columns */
 
+extern int git_core_column;
+
 extern int term_columns(void);
 extern struct string_list_item *add_to_columns(struct string_list *list, int mode, const char *string);
 extern void display_columns(const struct string_list *list, int mode, int width, int padding, const char *indent);
+extern int git_column_default_config(const char *var, const char *value, void *cb);
 
 struct option;
 extern int parseopt_column_callback(const struct option *opt, const char *arg, int unset);
-- 
1.7.4.74.g639db
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 7 of 13 in “column output v3”
  1. 0/9 column output v3Nguyễn Thái Ngọc Duy, Mar 20, 2011
  2. 1/9 Move term_columns() to pager.c and save terminal width before pagerNguyễn Thái Ngọc Duy, Mar 20, 2011
  3. 2/9 Add display_columns() to display in columnar layoutNguyễn Thái Ngọc Duy, Mar 20, 2011
  4. 3/9 column: add functions to parse column settingsNguyễn Thái Ngọc Duy, Mar 20, 2011
  5. 4/9 display_columns: add COL_MODE_{COLUMN,ROW} modeNguyễn Thái Ngọc Duy, Mar 20, 2011
  6. 5/9 display_columns: add COL_DENSE to do unequal column layoutNguyễn Thái Ngọc Duy, Mar 20, 2011
  7. 6/9 column: add column.ui for default column output settingsNguyễn Thái Ngọc Duy, Mar 20, 2011
  8. 7/9 help: reuse display_columns() for help -aNguyễn Thái Ngọc Duy, Mar 20, 2011
  9. 7/9 help: reuse display_columns() for help -aNguyễn Thái Ngọc Duy, Mar 20, 2011
  10. 8/9 tag: add --columnNguyễn Thái Ngọc Duy, Mar 20, 2011
  11. 9/9 branch: add --columnNguyễn Thái Ngọc Duy, Mar 20, 2011
  12. Teemu LikonenMar 20, 2011
  13. 9/9 branch: add --columnNguyễn Thái Ngọc Duy, Mar 20, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.