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.
Commit
7045859339403bb5495d5ed8efe547dc0ec437a38cdb153447b06709ce3f0437
Parent
b705d756cf645ec…
1 file changed
+6
-41
+6
-41
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -631,21 +631,16 @@ | ||
| 631 | 631 | const char *zLast, /* Last filename in the list to print */ |
| 632 | 632 | const char *zPrefix, /* Prefix so put before each output line */ |
| 633 | 633 | int nDir, /* Ignore this many characters of directory name */ |
| 634 | 634 | int treeFmt /* 1 = use Unicode symbols, 2 = use ASCII chars */ |
| 635 | 635 | ){ |
| 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 "; | |
| 640 | 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 | - } | |
| 641 | + | |
| 647 | 642 | while( zIn<=zLast ){ |
| 648 | 643 | int i; |
| 649 | 644 | for(i=nDir; zIn[i]!='\n' && zIn[i]!='/'; i++){} |
| 650 | 645 | if( zIn[i]=='/' ){ |
| 651 | 646 | char *zSubPrefix; |
| @@ -787,18 +782,16 @@ | ||
| 787 | 782 | ** path and name (case insensitive sort if -r). If neither --age nor -r |
| 788 | 783 | ** are used, -t sorts by modification time, otherwise by commit time. |
| 789 | 784 | ** |
| 790 | 785 | ** Options: |
| 791 | 786 | ** --age Show when each file was committed |
| 792 | -** -a|--ascii-tree Use ASCII characters when drawing the tree | |
| 793 | 787 | ** --hash With -v, verify file status using hashing |
| 794 | 788 | ** rather than relying on file sizes and mtimes |
| 795 | 789 | ** -r VERSION The specific check-in to list |
| 796 | 790 | ** -R|--repository REPO Extract info from repository REPO |
| 797 | 791 | ** -t Sort output in time order |
| 798 | 792 | ** --tree Tree format |
| 799 | -** -u|--unicode-tree Use Unicode characters when drawing the tree | |
| 800 | 793 | ** -v|--verbose Provide extra information about each file |
| 801 | 794 | ** |
| 802 | 795 | ** See also: [[changes]], [[extras]], [[status]], [[tree]] |
| 803 | 796 | */ |
| 804 | 797 | void ls_cmd(void){ |
| @@ -805,12 +798,10 @@ | ||
| 805 | 798 | int vid; |
| 806 | 799 | Stmt q; |
| 807 | 800 | int verboseFlag; |
| 808 | 801 | int showAge; |
| 809 | 802 | int treeFmt; |
| 810 | - int asciiTree; | |
| 811 | - int unicodeTree; | |
| 812 | 803 | int timeOrder; |
| 813 | 804 | char *zOrderBy = "pathname"; |
| 814 | 805 | Blob where; |
| 815 | 806 | int i; |
| 816 | 807 | int useHash = 0; |
| @@ -826,19 +817,12 @@ | ||
| 826 | 817 | timeOrder = find_option("t","t",0)!=0; |
| 827 | 818 | if( verboseFlag ){ |
| 828 | 819 | useHash = find_option("hash",0,0)!=0; |
| 829 | 820 | } |
| 830 | 821 | 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 | 822 | if( treeFmt ){ |
| 834 | 823 | if( zRev==0 ) zRev = "current"; |
| 835 | -#ifdef _WIN32 | |
| 836 | - treeFmt = 2; | |
| 837 | -#endif | |
| 838 | - if( unicodeTree ) treeFmt = 1; | |
| 839 | - if( asciiTree ) treeFmt = 2; | |
| 840 | 824 | } |
| 841 | 825 | |
| 842 | 826 | if( zRev!=0 ){ |
| 843 | 827 | db_find_and_open_repository(0, 0); |
| 844 | 828 | verify_all_options(); |
| @@ -951,32 +935,22 @@ | ||
| 951 | 935 | ** List all files in the current check-out in after the fashion of the |
| 952 | 936 | ** "tree" command. If PATHS is included, only the named files |
| 953 | 937 | ** (or their children if directories) are shown. |
| 954 | 938 | ** |
| 955 | 939 | ** Options: |
| 956 | -** -a|--ascii-tree Use ASCII characters when drawing the tree | |
| 957 | 940 | ** -r VERSION The specific check-in to list |
| 958 | 941 | ** -R|--repository REPO Extract info from repository REPO |
| 959 | -** -u|--unicode-tree Use Unicode characters when drawing the tree | |
| 960 | 942 | ** |
| 961 | 943 | ** See also: [[ls]] |
| 962 | 944 | */ |
| 963 | 945 | void tree_cmd(void){ |
| 964 | 946 | 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 | 947 | zRev = find_option("r","r",1); |
| 974 | 948 | if( zRev==0 ) zRev = "current"; |
| 975 | 949 | db_find_and_open_repository(0, 0); |
| 976 | 950 | verify_all_options(); |
| 977 | - ls_cmd_rev(zRev, 0, 0, 0, treeFmt); | |
| 951 | + ls_cmd_rev(zRev, 0, 0, 0, 1); | |
| 978 | 952 | } |
| 979 | 953 | |
| 980 | 954 | /* |
| 981 | 955 | ** COMMAND: extras |
| 982 | 956 | ** |
| @@ -996,19 +970,17 @@ | ||
| 996 | 970 | ** Pathnames are displayed according to the "relative-paths" setting, |
| 997 | 971 | ** unless overridden by the --abs-paths or --rel-paths options. |
| 998 | 972 | ** |
| 999 | 973 | ** Options: |
| 1000 | 974 | ** --abs-paths Display absolute pathnames |
| 1001 | -** -a|--ascii-tree Use ASCII characters when drawing the tree | |
| 1002 | 975 | ** --case-sensitive BOOL Override case-sensitive setting |
| 1003 | 976 | ** --dotfiles Include files beginning with a dot (".") |
| 1004 | 977 | ** --header Identify the repository if there are extras |
| 1005 | 978 | ** --ignore CSG Ignore files matching patterns from the argument |
| 1006 | 979 | ** --rel-paths Display pathnames relative to the current working |
| 1007 | 980 | ** directory |
| 1008 | 981 | ** --tree Show output in the tree format |
| 1009 | -** -u|--unicode-tree Use Unicode characters when drawing the tree | |
| 1010 | 982 | ** |
| 1011 | 983 | ** See also: [[changes]], [[clean]], [[status]] |
| 1012 | 984 | */ |
| 1013 | 985 | void extras_cmd(void){ |
| 1014 | 986 | Blob report = BLOB_INITIALIZER; |
| @@ -1015,12 +987,10 @@ | ||
| 1015 | 987 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 1016 | 988 | unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0; |
| 1017 | 989 | unsigned flags = C_EXTRA; |
| 1018 | 990 | int showHdr = find_option("header",0,0)!=0; |
| 1019 | 991 | 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 | 992 | Glob *pIgnore; |
| 1023 | 993 | |
| 1024 | 994 | if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP; |
| 1025 | 995 | db_must_be_within_tree(); |
| 1026 | 996 | |
| @@ -1030,15 +1000,10 @@ | ||
| 1030 | 1000 | |
| 1031 | 1001 | if( db_get_boolean("dotfiles", 0) ) scanFlags |= SCAN_ALL; |
| 1032 | 1002 | |
| 1033 | 1003 | if( treeFmt ){ |
| 1034 | 1004 | flags &= ~C_RELPATH; |
| 1035 | -#ifdef _WIN32 | |
| 1036 | - treeFmt = 2; | |
| 1037 | -#endif | |
| 1038 | - if( unicodeTree ) treeFmt = 1; | |
| 1039 | - if( asciiTree ) treeFmt = 2; | |
| 1040 | 1005 | } |
| 1041 | 1006 | |
| 1042 | 1007 | /* We should be done with options.. */ |
| 1043 | 1008 | verify_all_options(); |
| 1044 | 1009 | |
| 1045 | 1010 |
| --- 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 |