Skip to content

Commit

Permalink
. 列目录时,目录名称高亮显示,有别于普通文件。
Browse files Browse the repository at this point in the history
. 显示包含空格的文件或目录时,不再显示转义符'\'。
. 录入包含空格的文件或目录时,可以使用转义符,也可以使用双引号。
  例如:/Program\ Files    或者    /“Program Files”
  • Loading branch information
yaya committed Mar 19, 2017
1 parent 00c37ea commit 90167b0
Show file tree
Hide file tree
Showing 17 changed files with 141 additions and 21 deletions.
6 changes: 6 additions & 0 deletions ChangeLog_chenall.txt
@@ -1,4 +1,10 @@
更新说明:
2017-03-19(yaya)
列目录时,目录名称高亮显示,有别于普通文件。
显示包含空格的文件或目录时,不再显示转义符'\'。
录入包含空格的文件或目录时,可以使用转义符,也可以使用双引号。
例如:/Program\ Files 或者 /“Program Files”

2017-03-06(yaya)
USB2.0 驱动更新。
支持“AMD SB700/SB710/SB750 主板”,支持“神舟q230b网络本”等。
Expand Down
6 changes: 6 additions & 0 deletions stage2/char_io.c
Expand Up @@ -2046,6 +2046,12 @@ nul_terminate (char *str)

while ((ch = *str) && ! grub_isspace (ch))
{
if (ch == '"')
{
str++;
while (*str != '"')
str++;
}
if (ch == '\\')
{
str++;
Expand Down
2 changes: 1 addition & 1 deletion stage2/console.c
Expand Up @@ -45,7 +45,7 @@ static unsigned long long console_color_64bit[COLOR_STATE_MAX] = {
/* represents the user defined colors for normal text */
[COLOR_STATE_NORMAL] = 0xAAAAAA,
/* represents the user defined colors for highlighted text */
[COLOR_STATE_HIGHLIGHT] = 0xAAAAAA00000000ULL,
[COLOR_STATE_HIGHLIGHT] = 0xFFFFFF, //0xAAAAAA00000000ULL,
/* represents the user defined colors for help text */
[COLOR_STATE_HELPTEXT] = 0xAAAAAA,
/* represents the user defined colors for heading line */
Expand Down
24 changes: 20 additions & 4 deletions stage2/disk_io.c
Expand Up @@ -215,14 +215,18 @@ unicode_to_utf8 (unsigned short *filename, unsigned char *utf8, unsigned long n)
{
if (uni <= 0x007F)
{
#if 0
if (uni != ' ')
#endif
utf8[k++] = uni;
#if 0
else
{
/* quote the SPACE with a backslash */
utf8[k++] = '\\';
utf8[k++] = uni;
}
#endif
}
else if (uni <= 0x07FF)
{
Expand Down Expand Up @@ -1644,13 +1648,25 @@ static int set_filename(char *filename)
{
char ch = nul_terminate(filename);
int i = grub_strlen(filename);
filename[i] = ch;
int j = grub_strlen(saved_dir);
int k;

if (i >= sizeof(open_filename) || (relative_path && grub_strlen(saved_dir)+i >= sizeof(open_filename)))
return !(errnum = ERR_WONT_FIT);

if (relative_path)
grub_sprintf (open_filename, "%s%.*s", saved_dir, i,filename);
else
grub_sprintf (open_filename, "%.*s", i,filename);
grub_sprintf (open_filename, "%s", saved_dir);

for (k = 0; filename[k]; k++)
{
if (filename[k] == '"' || filename[k] == '\\' )
continue;
else
open_filename[j++] = filename[k];
}
open_filename[j] = 0;
filename[i] = ch;

return 1;
}

Expand Down
22 changes: 20 additions & 2 deletions stage2/fsys_ext2fs.c
Expand Up @@ -35,6 +35,7 @@
#include "shared.h"
#include "filesys.h"
#include "iamath.h"
#include "term.h"

static int mapblock1, mapblock2;

Expand Down Expand Up @@ -1003,14 +1004,16 @@ ext2fs_dir (char *dirname)
//len = 0;
//while (dirname[len] && !isspace (dirname[len]))
// len++;
for (len = 0; (ch = dirname[len]) && !isspace (ch); len++)
for (len = 0; (ch = dirname[len]) /*&& !isspace (ch)*/; len++)
{
#if 0
if (ch == '\\')
{
len++;
if (! (ch = dirname[len]))
break;
}
#endif
}

/* Get the symlink size. */
Expand Down Expand Up @@ -1111,14 +1114,16 @@ ext2fs_dir (char *dirname)
/* skip to next slash or end of filename (space) */
// for (rest = dirname; (ch = *rest) && !isspace (ch) && ch != '/';
// rest++);
for (rest = dirname; (ch = *rest) && !isspace (ch) && ch != '/'; rest++)
for (rest = dirname; (ch = *rest) /*&& !isspace (ch)*/ && ch != '/'; rest++)
{
#if 0
if (ch == '\\')
{
rest++;
if (! (ch = *rest))
break;
}
#endif
}

/* look through this directory and find the next filename component */
Expand Down Expand Up @@ -1204,8 +1209,10 @@ ext2fs_dir (char *dirname)
{
if (! (ch1 = dp->name[j]))
break;
#if 0
if (ch1 == ' ')
tmp_name[k++] = '\\';
#endif
tmp_name[k++] = ch1;
}
tmp_name[k] = 0;
Expand All @@ -1218,7 +1225,18 @@ ext2fs_dir (char *dirname)
{
if (print_possibilities > 0)
print_possibilities = -print_possibilities;
unsigned long long clo64 = current_color_64bit;
unsigned long clo = current_color;
if (dp->file_type == 2)
{
if (current_term->setcolorstate)
current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
current_color_64bit &= 0x0000000000ffffff;
current_color &= 0xf;
}
print_a_completion (tmp_name, 0);
current_color_64bit = clo64;
current_color = clo;
if (*tmp_name != 0x2e)
empty = 1;
}
Expand Down
17 changes: 15 additions & 2 deletions stage2/fsys_fat.c
Expand Up @@ -23,6 +23,7 @@
#include "filesys.h"
#include "iamath.h"
#include "fat.h"
#include "term.h"

struct fat_superblock
{
Expand Down Expand Up @@ -556,15 +557,16 @@ fat_dir (char *dirname)
filemax = MAXINT;

/* check if the dirname ends in a slash(saved in CH) and end it in a NULL */
//for (rest = dirname; (ch = *rest) && !isspace (ch) && ch != '/'; rest++);
for (rest = dirname; (ch = *rest) && !isspace (ch) && ch != '/'; rest++)
for (rest = dirname; (ch = *rest) /*&& !isspace (ch)*/ && ch != '/'; rest++)
{
#if 0
if (ch == '\\')
{
rest++;
if (! (ch = *rest))
break;
}
#endif
}

*rest = 0;
Expand Down Expand Up @@ -763,7 +765,18 @@ fat_dir (char *dirname)
{
if (print_possibilities > 0)
print_possibilities = -print_possibilities;
unsigned long long clo64 = current_color_64bit;
unsigned long clo = current_color;
if ((FAT_SUPER->fat_type == 64 && exfat_attrib & 0x10) || (FAT_SUPER->fat_type != 64 && FAT_DIRENTRY_ATTRIB (dir_buf) & 0x10))
{
if (current_term->setcolorstate)
current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
current_color_64bit &= 0x0000000000ffffff;
current_color &= 0xf;
}
print_a_completion ((char *)utf8, 1);
current_color_64bit = clo64;
current_color = clo;
if (*(char *)utf8 != 0x2e)
empty = 1;
}
Expand Down
2 changes: 2 additions & 0 deletions stage2/fsys_fb.c
Expand Up @@ -430,8 +430,10 @@ int fb_dir (char *dirname)
// if (! (ch1 = cur_file->name[j]))
if (! (ch1 = cur_file->name[j+((ver_min==6)?0:4)]))
break;
#if 0
if (ch1 == ' ')
tmp_name[k++] = '\\';
#endif
tmp_name[k++] = ch1;
}
tmp_name[k] = 0;
Expand Down
6 changes: 5 additions & 1 deletion stage2/fsys_ffs.c
Expand Up @@ -693,14 +693,16 @@ ffs_dir (char *dirname)
}

//for (rest = dirname; (ch = *rest) && !isspace (ch) && ch != '/'; rest++);
for (rest = dirname; (ch = *rest) && !isspace (ch) && ch != '/'; rest++)
for (rest = dirname; (ch = *rest) /*&& !isspace (ch)*/ && ch != '/'; rest++)
{
#if 0
if (ch == '\\')
{
rest++;
if (! (ch = *rest))
break;
}
#endif
}

*rest = 0;
Expand Down Expand Up @@ -747,8 +749,10 @@ ffs_dir (char *dirname)
{
if (! (ch1 = dp->d_name[j]))
break;
#if 0
if (ch1 == ' ')
tmp_name[k++] = '\\';
#endif
tmp_name[k++] = ch1;
}
tmp_name[k] = 0;
Expand Down
17 changes: 16 additions & 1 deletion stage2/fsys_iso9660.c
Expand Up @@ -34,6 +34,7 @@
#include "shared.h"
#include "filesys.h"
#include "iso9660.h"
#include "term.h"

/* iso9660 super-block data in memory */
struct iso_sb_info {
Expand Down Expand Up @@ -266,11 +267,13 @@ iso9660_dir (char *dirname)
// ;
for (ch = tmp_name;*dirname;++dirname)
{
#if 0
if (*dirname == '\\')
{
*ch++ = *dirname++;
*ch++ = *dirname++;
}
#endif
if (/*isspace(*dirname) || */*dirname == '/')
break;
if (ch - tmp_name >= 255 || !(*ch = *dirname))
Expand Down Expand Up @@ -516,6 +519,7 @@ iso9660_dir (char *dirname)
filemax = MAXINT;
for (j = 0, k = 0;j < name_len;)
{
#if 0
if (name[j] == '\\')
{
tmp_name1[k++] = name[j++];
Expand All @@ -529,6 +533,7 @@ iso9660_dir (char *dirname)
tmp_name1[k++] = name[j++];
}
else
#endif
tmp_name1[k++] = name[j++];
}
tmp_name1[k] = 0;
Expand Down Expand Up @@ -605,8 +610,18 @@ iso9660_dir (char *dirname)
// tmp_name1[k++] = ch1;
// }
// tmp_name1[k] = 0;

unsigned long long clo64 = current_color_64bit;
unsigned long clo = current_color;
if (file_type == ISO_DIRECTORY)
{
if (current_term->setcolorstate)
current_term->setcolorstate (COLOR_STATE_HIGHLIGHT);
current_color_64bit &= 0x0000000000ffffff;
current_color &= 0xf;
}
print_a_completion (tmp_name1, 0);
current_color_64bit = clo64;
current_color = clo;
}
}
// } /* for */
Expand Down
4 changes: 3 additions & 1 deletion stage2/fsys_jfs.c
Expand Up @@ -353,14 +353,16 @@ jfs_dir (char *dirname)
for (; *dirname == '/'; dirname++);

//for (rest = dirname; (ch = *rest) && !isspace (ch) && ch != '/'; rest++);
for (rest = dirname; (ch = *rest) && !isspace (ch) && ch != '/'; rest++)
for (rest = dirname; (ch = *rest) /*&& !isspace (ch)*/ && ch != '/'; rest++)
{
#if 0
if (ch == '\\')
{
rest++;
if (! (ch = *rest))
break;
}
#endif
}

*rest = 0;
Expand Down
10 changes: 8 additions & 2 deletions stage2/fsys_minix.c
Expand Up @@ -370,14 +370,16 @@ minix_dir (char *dirname)
//len = 0;
//while (dirname[len] && !isspace (dirname[len]))
// len++;
for (len = 0; (ch = dirname[len]) && !isspace (ch); len++)
for (len = 0; (ch = dirname[len]) /*&& !isspace (ch)*/; len++)
{
#if 0
if (ch == '\\')
{
len++;
if (! (ch = dirname[len]))
break;
}
#endif
}

/* Get the symlink size. */
Expand Down Expand Up @@ -454,14 +456,16 @@ minix_dir (char *dirname)
/* skip to next slash or end of filename (space) */
// for (rest = dirname; (ch = *rest) && !isspace (ch) && ch != '/';
// rest++);
for (rest = dirname; (ch = *rest) && !isspace (ch) && ch != '/'; rest++)
for (rest = dirname; (ch = *rest) /*&& !isspace (ch)*/ && ch != '/'; rest++)
{
#if 0
if (ch == '\\')
{
rest++;
if (! (ch = *rest))
break;
}
#endif
}

/* look through this directory and find the next filename component */
Expand Down Expand Up @@ -536,8 +540,10 @@ minix_dir (char *dirname)
{
if (! (ch1 = dp->name[j]))
break;
#if 0
if (ch1 == ' ')
tmp_name[k++] = '\\';
#endif
tmp_name[k++] = ch1;
}
tmp_name[k] = 0;
Expand Down

0 comments on commit 90167b0

Please sign in to comment.