summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2074220)
raw | patch | inline | side by side (parent: 2074220)
author | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 4 Feb 2009 17:40:15 +0000 (18:40 +0100) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Thu, 5 Feb 2009 08:34:17 +0000 (09:34 +0100) |
tig.c | patch | blob | history | |
tigrc.5.txt | patch | blob | history |
index bd9a7a4bf0852cd23413adf32c5eb3282beaadde..f1c8211f830a661e62acad81f3eecb61fc0ff06c 100644 (file)
--- a/tig.c
+++ b/tig.c
LINE(STATUS, "", COLOR_GREEN, COLOR_DEFAULT, 0), \
LINE(DELIMITER, "", COLOR_MAGENTA, COLOR_DEFAULT, 0), \
LINE(DATE, "", COLOR_BLUE, COLOR_DEFAULT, 0), \
+LINE(MODE, "", COLOR_CYAN, COLOR_DEFAULT, 0), \
LINE(LINE_NUMBER, "", COLOR_CYAN, COLOR_DEFAULT, 0), \
LINE(TITLE_BLUR, "", COLOR_WHITE, COLOR_BLUE, 0), \
LINE(TITLE_FOCUS, "", COLOR_WHITE, COLOR_BLUE, A_BOLD), \
LINE(MAIN_HEAD, "", COLOR_CYAN, COLOR_DEFAULT, A_BOLD), \
LINE(MAIN_REVGRAPH,"", COLOR_MAGENTA, COLOR_DEFAULT, 0), \
LINE(TREE_PARENT, "", COLOR_DEFAULT, COLOR_DEFAULT, A_BOLD), \
-LINE(TREE_MODE, "", COLOR_CYAN, COLOR_DEFAULT, 0), \
LINE(TREE_DIR, "", COLOR_YELLOW, COLOR_DEFAULT, A_NORMAL), \
LINE(TREE_FILE, "", COLOR_DEFAULT, COLOR_DEFAULT, A_NORMAL), \
LINE(STAT_HEAD, "", COLOR_YELLOW, COLOR_DEFAULT, 0), \
return draw_field(view, LINE_AUTHOR, author, opt_author_cols, trim);
}
+static bool
+draw_mode(struct view *view, mode_t mode)
+{
+ static const char dir_mode[] = "drwxr-xr-x";
+ static const char link_mode[] = "lrwxrwxrwx";
+ static const char exe_mode[] = "-rwxr-xr-x";
+ static const char file_mode[] = "-rw-r--r--";
+ const char *str;
+
+ if (S_ISDIR(mode))
+ str = dir_mode;
+ else if (S_ISLNK(mode))
+ str = link_mode;
+ else if (mode & S_IXUSR)
+ str = exe_mode;
+ else
+ str = file_mode;
+
+ return draw_field(view, LINE_MODE, str, sizeof(file_mode), FALSE);
+}
+
static bool
draw_view_line(struct view *view, unsigned int lineno)
{
if (draw_text(view, line->type, "Directory path /", TRUE))
return TRUE;
} else {
- char mode[11] = "-r--r--r--";
-
- if (S_ISDIR(entry->mode)) {
- mode[3] = mode[6] = mode[9] = 'x';
- mode[0] = 'd';
- }
- if (S_ISLNK(entry->mode))
- mode[0] = 'l';
- if (entry->mode & S_IWUSR)
- mode[2] = 'w';
- if (entry->mode & S_IXUSR)
- mode[3] = 'x';
- if (entry->mode & S_IXGRP)
- mode[6] = 'x';
- if (entry->mode & S_IXOTH)
- mode[9] = 'x';
- if (draw_field(view, LINE_TREE_MODE, mode, 11, TRUE))
+ if (draw_mode(view, entry->mode))
return TRUE;
if (opt_author && draw_author(view, entry->author))
diff --git a/tigrc.5.txt b/tigrc.5.txt
index 2beb269c11ab369e7402e784e1720478a2d84186..149fcd7a9fedf08532ea950515933bee1ad8f872 100644 (file)
--- a/tigrc.5.txt
+++ b/tigrc.5.txt
line-number Line numbers.
date The commit date.
author The commit author.
+mode The file mode holding the permissions and type.
------------------------------------------------------------------------------
ifdef::backend-xhtml11[]
blame-id The commit ID.
------------------------------------------------------------------------------
+ifdef::backend-xhtml11[]
+[frame="none"]
+`-----------------------`-----------------------------------------------------
+endif::backend-xhtml11[]
+Tree view:
+------------------------------------------------------------------------------
+tree-head The "Directory /"-line
+tree-dir The directory name.
+tree-file The file name.
+------------------------------------------------------------------------------
+
Highlighting
~~~~~~~~~~~~