Fossil SCM

Remove options for rendering the tree hierarchy using ASCII-art for the "fossil tree" command and similar. Always use only Unicode box-drawing characters. This works on newer Win10 and Win11. Maybe it doesn't work on older Windows, but the "fossil tree" command is not essential for anything - it is only a convenience - so if it doesn't work on an older platform, that really doesn't really matter.

drh 2024-04-29 23:42 trunk
Commit 7045859339403bb5495d5ed8efe547dc0ec437a38cdb153447b06709ce3f0437
1 file changed +6 -41
+6 -41
--- src/checkin.c
+++ src/checkin.c
@@ -631,21 +631,16 @@
631631
const char *zLast, /* Last filename in the list to print */
632632
const char *zPrefix, /* Prefix so put before each output line */
633633
int nDir, /* Ignore this many characters of directory name */
634634
int treeFmt /* 1 = use Unicode symbols, 2 = use ASCII chars */
635635
){
636
- /* ASCII characters used for drawing a file hierarchy graph */
637
- const char *treeEntry = "|-- ";
638
- const char *treeLastE = "`-- ";
639
- const char *treeContu = "| ";
636
+ /* Unicode box-drawing characters: U+251C, U+2514, U+2502 */
637
+ const char *treeEntry = "\342\224\234\342\224\200\342\224\200 ";
638
+ const char *treeLastE = "\342\224\224\342\224\200\342\224\200 ";
639
+ const char *treeContu = "\342\224\202 ";
640640
const char *treeBlank = " ";
641
- if( treeFmt == 1 ){
642
- /* Unicode box-drawing characters: U+251C, U+2514, U+2502 */
643
- treeEntry = "\342\224\234\342\224\200\342\224\200 ";
644
- treeLastE = "\342\224\224\342\224\200\342\224\200 ";
645
- treeContu = "\342\224\202 ";
646
- }
641
+
647642
while( zIn<=zLast ){
648643
int i;
649644
for(i=nDir; zIn[i]!='\n' && zIn[i]!='/'; i++){}
650645
if( zIn[i]=='/' ){
651646
char *zSubPrefix;
@@ -787,18 +782,16 @@
787782
** path and name (case insensitive sort if -r). If neither --age nor -r
788783
** are used, -t sorts by modification time, otherwise by commit time.
789784
**
790785
** Options:
791786
** --age Show when each file was committed
792
-** -a|--ascii-tree Use ASCII characters when drawing the tree
793787
** --hash With -v, verify file status using hashing
794788
** rather than relying on file sizes and mtimes
795789
** -r VERSION The specific check-in to list
796790
** -R|--repository REPO Extract info from repository REPO
797791
** -t Sort output in time order
798792
** --tree Tree format
799
-** -u|--unicode-tree Use Unicode characters when drawing the tree
800793
** -v|--verbose Provide extra information about each file
801794
**
802795
** See also: [[changes]], [[extras]], [[status]], [[tree]]
803796
*/
804797
void ls_cmd(void){
@@ -805,12 +798,10 @@
805798
int vid;
806799
Stmt q;
807800
int verboseFlag;
808801
int showAge;
809802
int treeFmt;
810
- int asciiTree;
811
- int unicodeTree;
812803
int timeOrder;
813804
char *zOrderBy = "pathname";
814805
Blob where;
815806
int i;
816807
int useHash = 0;
@@ -826,19 +817,12 @@
826817
timeOrder = find_option("t","t",0)!=0;
827818
if( verboseFlag ){
828819
useHash = find_option("hash",0,0)!=0;
829820
}
830821
treeFmt = find_option("tree",0,0)!=0;
831
- asciiTree = find_option("ascii-tree","a",0)!=0;
832
- unicodeTree = find_option("unicode-tree","u",0)!=0;
833822
if( treeFmt ){
834823
if( zRev==0 ) zRev = "current";
835
-#ifdef _WIN32
836
- treeFmt = 2;
837
-#endif
838
- if( unicodeTree ) treeFmt = 1;
839
- if( asciiTree ) treeFmt = 2;
840824
}
841825
842826
if( zRev!=0 ){
843827
db_find_and_open_repository(0, 0);
844828
verify_all_options();
@@ -951,32 +935,22 @@
951935
** List all files in the current check-out in after the fashion of the
952936
** "tree" command. If PATHS is included, only the named files
953937
** (or their children if directories) are shown.
954938
**
955939
** Options:
956
-** -a|--ascii-tree Use ASCII characters when drawing the tree
957940
** -r VERSION The specific check-in to list
958941
** -R|--repository REPO Extract info from repository REPO
959
-** -u|--unicode-tree Use Unicode characters when drawing the tree
960942
**
961943
** See also: [[ls]]
962944
*/
963945
void tree_cmd(void){
964946
const char *zRev;
965
- int treeFmt = 1;
966
- int asciiTree = find_option("ascii-tree","a",0)!=0;
967
- int unicodeTree = find_option("unicode-tree","u",0)!=0;
968
-#ifdef _WIN32
969
- treeFmt = 2;
970
-#endif
971
- if( unicodeTree ) treeFmt = 1;
972
- if( asciiTree ) treeFmt = 2;
973947
zRev = find_option("r","r",1);
974948
if( zRev==0 ) zRev = "current";
975949
db_find_and_open_repository(0, 0);
976950
verify_all_options();
977
- ls_cmd_rev(zRev, 0, 0, 0, treeFmt);
951
+ ls_cmd_rev(zRev, 0, 0, 0, 1);
978952
}
979953
980954
/*
981955
** COMMAND: extras
982956
**
@@ -996,19 +970,17 @@
996970
** Pathnames are displayed according to the "relative-paths" setting,
997971
** unless overridden by the --abs-paths or --rel-paths options.
998972
**
999973
** Options:
1000974
** --abs-paths Display absolute pathnames
1001
-** -a|--ascii-tree Use ASCII characters when drawing the tree
1002975
** --case-sensitive BOOL Override case-sensitive setting
1003976
** --dotfiles Include files beginning with a dot (".")
1004977
** --header Identify the repository if there are extras
1005978
** --ignore CSG Ignore files matching patterns from the argument
1006979
** --rel-paths Display pathnames relative to the current working
1007980
** directory
1008981
** --tree Show output in the tree format
1009
-** -u|--unicode-tree Use Unicode characters when drawing the tree
1010982
**
1011983
** See also: [[changes]], [[clean]], [[status]]
1012984
*/
1013985
void extras_cmd(void){
1014986
Blob report = BLOB_INITIALIZER;
@@ -1015,12 +987,10 @@
1015987
const char *zIgnoreFlag = find_option("ignore",0,1);
1016988
unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
1017989
unsigned flags = C_EXTRA;
1018990
int showHdr = find_option("header",0,0)!=0;
1019991
int treeFmt = find_option("tree",0,0)!=0;
1020
- int asciiTree = find_option("ascii-tree","a",0)!=0;
1021
- int unicodeTree = find_option("unicode-tree","u",0)!=0;
1022992
Glob *pIgnore;
1023993
1024994
if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
1025995
db_must_be_within_tree();
1026996
@@ -1030,15 +1000,10 @@
10301000
10311001
if( db_get_boolean("dotfiles", 0) ) scanFlags |= SCAN_ALL;
10321002
10331003
if( treeFmt ){
10341004
flags &= ~C_RELPATH;
1035
-#ifdef _WIN32
1036
- treeFmt = 2;
1037
-#endif
1038
- if( unicodeTree ) treeFmt = 1;
1039
- if( asciiTree ) treeFmt = 2;
10401005
}
10411006
10421007
/* We should be done with options.. */
10431008
verify_all_options();
10441009
10451010
--- src/checkin.c
+++ src/checkin.c
@@ -631,21 +631,16 @@
631 const char *zLast, /* Last filename in the list to print */
632 const char *zPrefix, /* Prefix so put before each output line */
633 int nDir, /* Ignore this many characters of directory name */
634 int treeFmt /* 1 = use Unicode symbols, 2 = use ASCII chars */
635 ){
636 /* ASCII characters used for drawing a file hierarchy graph */
637 const char *treeEntry = "|-- ";
638 const char *treeLastE = "`-- ";
639 const char *treeContu = "| ";
640 const char *treeBlank = " ";
641 if( treeFmt == 1 ){
642 /* Unicode box-drawing characters: U+251C, U+2514, U+2502 */
643 treeEntry = "\342\224\234\342\224\200\342\224\200 ";
644 treeLastE = "\342\224\224\342\224\200\342\224\200 ";
645 treeContu = "\342\224\202 ";
646 }
647 while( zIn<=zLast ){
648 int i;
649 for(i=nDir; zIn[i]!='\n' && zIn[i]!='/'; i++){}
650 if( zIn[i]=='/' ){
651 char *zSubPrefix;
@@ -787,18 +782,16 @@
787 ** path and name (case insensitive sort if -r). If neither --age nor -r
788 ** are used, -t sorts by modification time, otherwise by commit time.
789 **
790 ** Options:
791 ** --age Show when each file was committed
792 ** -a|--ascii-tree Use ASCII characters when drawing the tree
793 ** --hash With -v, verify file status using hashing
794 ** rather than relying on file sizes and mtimes
795 ** -r VERSION The specific check-in to list
796 ** -R|--repository REPO Extract info from repository REPO
797 ** -t Sort output in time order
798 ** --tree Tree format
799 ** -u|--unicode-tree Use Unicode characters when drawing the tree
800 ** -v|--verbose Provide extra information about each file
801 **
802 ** See also: [[changes]], [[extras]], [[status]], [[tree]]
803 */
804 void ls_cmd(void){
@@ -805,12 +798,10 @@
805 int vid;
806 Stmt q;
807 int verboseFlag;
808 int showAge;
809 int treeFmt;
810 int asciiTree;
811 int unicodeTree;
812 int timeOrder;
813 char *zOrderBy = "pathname";
814 Blob where;
815 int i;
816 int useHash = 0;
@@ -826,19 +817,12 @@
826 timeOrder = find_option("t","t",0)!=0;
827 if( verboseFlag ){
828 useHash = find_option("hash",0,0)!=0;
829 }
830 treeFmt = find_option("tree",0,0)!=0;
831 asciiTree = find_option("ascii-tree","a",0)!=0;
832 unicodeTree = find_option("unicode-tree","u",0)!=0;
833 if( treeFmt ){
834 if( zRev==0 ) zRev = "current";
835 #ifdef _WIN32
836 treeFmt = 2;
837 #endif
838 if( unicodeTree ) treeFmt = 1;
839 if( asciiTree ) treeFmt = 2;
840 }
841
842 if( zRev!=0 ){
843 db_find_and_open_repository(0, 0);
844 verify_all_options();
@@ -951,32 +935,22 @@
951 ** List all files in the current check-out in after the fashion of the
952 ** "tree" command. If PATHS is included, only the named files
953 ** (or their children if directories) are shown.
954 **
955 ** Options:
956 ** -a|--ascii-tree Use ASCII characters when drawing the tree
957 ** -r VERSION The specific check-in to list
958 ** -R|--repository REPO Extract info from repository REPO
959 ** -u|--unicode-tree Use Unicode characters when drawing the tree
960 **
961 ** See also: [[ls]]
962 */
963 void tree_cmd(void){
964 const char *zRev;
965 int treeFmt = 1;
966 int asciiTree = find_option("ascii-tree","a",0)!=0;
967 int unicodeTree = find_option("unicode-tree","u",0)!=0;
968 #ifdef _WIN32
969 treeFmt = 2;
970 #endif
971 if( unicodeTree ) treeFmt = 1;
972 if( asciiTree ) treeFmt = 2;
973 zRev = find_option("r","r",1);
974 if( zRev==0 ) zRev = "current";
975 db_find_and_open_repository(0, 0);
976 verify_all_options();
977 ls_cmd_rev(zRev, 0, 0, 0, treeFmt);
978 }
979
980 /*
981 ** COMMAND: extras
982 **
@@ -996,19 +970,17 @@
996 ** Pathnames are displayed according to the "relative-paths" setting,
997 ** unless overridden by the --abs-paths or --rel-paths options.
998 **
999 ** Options:
1000 ** --abs-paths Display absolute pathnames
1001 ** -a|--ascii-tree Use ASCII characters when drawing the tree
1002 ** --case-sensitive BOOL Override case-sensitive setting
1003 ** --dotfiles Include files beginning with a dot (".")
1004 ** --header Identify the repository if there are extras
1005 ** --ignore CSG Ignore files matching patterns from the argument
1006 ** --rel-paths Display pathnames relative to the current working
1007 ** directory
1008 ** --tree Show output in the tree format
1009 ** -u|--unicode-tree Use Unicode characters when drawing the tree
1010 **
1011 ** See also: [[changes]], [[clean]], [[status]]
1012 */
1013 void extras_cmd(void){
1014 Blob report = BLOB_INITIALIZER;
@@ -1015,12 +987,10 @@
1015 const char *zIgnoreFlag = find_option("ignore",0,1);
1016 unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
1017 unsigned flags = C_EXTRA;
1018 int showHdr = find_option("header",0,0)!=0;
1019 int treeFmt = find_option("tree",0,0)!=0;
1020 int asciiTree = find_option("ascii-tree","a",0)!=0;
1021 int unicodeTree = find_option("unicode-tree","u",0)!=0;
1022 Glob *pIgnore;
1023
1024 if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
1025 db_must_be_within_tree();
1026
@@ -1030,15 +1000,10 @@
1030
1031 if( db_get_boolean("dotfiles", 0) ) scanFlags |= SCAN_ALL;
1032
1033 if( treeFmt ){
1034 flags &= ~C_RELPATH;
1035 #ifdef _WIN32
1036 treeFmt = 2;
1037 #endif
1038 if( unicodeTree ) treeFmt = 1;
1039 if( asciiTree ) treeFmt = 2;
1040 }
1041
1042 /* We should be done with options.. */
1043 verify_all_options();
1044
1045
--- src/checkin.c
+++ src/checkin.c
@@ -631,21 +631,16 @@
631 const char *zLast, /* Last filename in the list to print */
632 const char *zPrefix, /* Prefix so put before each output line */
633 int nDir, /* Ignore this many characters of directory name */
634 int treeFmt /* 1 = use Unicode symbols, 2 = use ASCII chars */
635 ){
636 /* Unicode box-drawing characters: U+251C, U+2514, U+2502 */
637 const char *treeEntry = "\342\224\234\342\224\200\342\224\200 ";
638 const char *treeLastE = "\342\224\224\342\224\200\342\224\200 ";
639 const char *treeContu = "\342\224\202 ";
640 const char *treeBlank = " ";
641
 
 
 
 
 
642 while( zIn<=zLast ){
643 int i;
644 for(i=nDir; zIn[i]!='\n' && zIn[i]!='/'; i++){}
645 if( zIn[i]=='/' ){
646 char *zSubPrefix;
@@ -787,18 +782,16 @@
782 ** path and name (case insensitive sort if -r). If neither --age nor -r
783 ** are used, -t sorts by modification time, otherwise by commit time.
784 **
785 ** Options:
786 ** --age Show when each file was committed
 
787 ** --hash With -v, verify file status using hashing
788 ** rather than relying on file sizes and mtimes
789 ** -r VERSION The specific check-in to list
790 ** -R|--repository REPO Extract info from repository REPO
791 ** -t Sort output in time order
792 ** --tree Tree format
 
793 ** -v|--verbose Provide extra information about each file
794 **
795 ** See also: [[changes]], [[extras]], [[status]], [[tree]]
796 */
797 void ls_cmd(void){
@@ -805,12 +798,10 @@
798 int vid;
799 Stmt q;
800 int verboseFlag;
801 int showAge;
802 int treeFmt;
 
 
803 int timeOrder;
804 char *zOrderBy = "pathname";
805 Blob where;
806 int i;
807 int useHash = 0;
@@ -826,19 +817,12 @@
817 timeOrder = find_option("t","t",0)!=0;
818 if( verboseFlag ){
819 useHash = find_option("hash",0,0)!=0;
820 }
821 treeFmt = find_option("tree",0,0)!=0;
 
 
822 if( treeFmt ){
823 if( zRev==0 ) zRev = "current";
 
 
 
 
 
824 }
825
826 if( zRev!=0 ){
827 db_find_and_open_repository(0, 0);
828 verify_all_options();
@@ -951,32 +935,22 @@
935 ** List all files in the current check-out in after the fashion of the
936 ** "tree" command. If PATHS is included, only the named files
937 ** (or their children if directories) are shown.
938 **
939 ** Options:
 
940 ** -r VERSION The specific check-in to list
941 ** -R|--repository REPO Extract info from repository REPO
 
942 **
943 ** See also: [[ls]]
944 */
945 void tree_cmd(void){
946 const char *zRev;
 
 
 
 
 
 
 
 
947 zRev = find_option("r","r",1);
948 if( zRev==0 ) zRev = "current";
949 db_find_and_open_repository(0, 0);
950 verify_all_options();
951 ls_cmd_rev(zRev, 0, 0, 0, 1);
952 }
953
954 /*
955 ** COMMAND: extras
956 **
@@ -996,19 +970,17 @@
970 ** Pathnames are displayed according to the "relative-paths" setting,
971 ** unless overridden by the --abs-paths or --rel-paths options.
972 **
973 ** Options:
974 ** --abs-paths Display absolute pathnames
 
975 ** --case-sensitive BOOL Override case-sensitive setting
976 ** --dotfiles Include files beginning with a dot (".")
977 ** --header Identify the repository if there are extras
978 ** --ignore CSG Ignore files matching patterns from the argument
979 ** --rel-paths Display pathnames relative to the current working
980 ** directory
981 ** --tree Show output in the tree format
 
982 **
983 ** See also: [[changes]], [[clean]], [[status]]
984 */
985 void extras_cmd(void){
986 Blob report = BLOB_INITIALIZER;
@@ -1015,12 +987,10 @@
987 const char *zIgnoreFlag = find_option("ignore",0,1);
988 unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
989 unsigned flags = C_EXTRA;
990 int showHdr = find_option("header",0,0)!=0;
991 int treeFmt = find_option("tree",0,0)!=0;
 
 
992 Glob *pIgnore;
993
994 if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
995 db_must_be_within_tree();
996
@@ -1030,15 +1000,10 @@
1000
1001 if( db_get_boolean("dotfiles", 0) ) scanFlags |= SCAN_ALL;
1002
1003 if( treeFmt ){
1004 flags &= ~C_RELPATH;
 
 
 
 
 
1005 }
1006
1007 /* We should be done with options.. */
1008 verify_all_options();
1009
1010

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button