Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 55dbbaf

Browse files
Refactor icons.
Signed-off-by: Eric Wang <skygragon@gmail.com>
1 parent 0ba7666 commit 55dbbaf

File tree

7 files changed

+43
-35
lines changed

7 files changed

+43
-35
lines changed

‎icons/ascii.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
"like": "*",
55
"unlike": " ",
66
"lock": "$",
7-
"none": " "
7+
"empty": " ",
8+
"ac": "O",
9+
"notac": "X",
10+
"none": "o"
811
}

‎icons/default.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
"like": "",
55
"unlike": "",
66
"lock": "🔒",
7-
"none": " "
7+
"empty": " ",
8+
"ac": "",
9+
"notac": "",
10+
"none": ""
811
}

‎icons/win7.json‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33
"no": "×ばつ",
44
"like": "",
55
"unlike": " ",
6-
"lock": "$"
6+
"lock": "$",
7+
"empty": " ",
8+
"ac": "O",
9+
"notac": "X",
10+
"none": "o"
711
}

‎lib/commands/list.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ cmd.handler = function(argv) {
6868
if (problem.starred) ++stat.starred;
6969

7070
log.printf('%s %s %s [%3d] %-60s %-6s (%.2f %%)',
71-
(problem.starred ? chalk.yellow(icon.like) : icon.none),
72-
(problem.locked ? chalk.red(icon.lock) : icon.none),
71+
(problem.starred ? chalk.yellow(icon.like) : icon.empty),
72+
(problem.locked ? chalk.red(icon.lock) : icon.empty),
7373
h.prettyState(problem.state),
7474
problem.fid,
7575
problem.name,

‎lib/commands/show.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function showProblem(problem, argv) {
140140
}
141141

142142
log.printf('[%d] %s %s', problem.fid, problem.name,
143-
(problem.starred ? chalk.yellow(icon.like) : icon.none));
143+
(problem.starred ? chalk.yellow(icon.like) : icon.empty));
144144
log.info();
145145
log.info(chalk.underline(problem.link));
146146
if (argv.extra) {

‎lib/commands/stat.js‎

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var sprintf = require('sprintf-js').sprintf;
44
var _ = require('underscore');
55

66
var chalk = require('../chalk');
7+
var icon = require('../icon');
78
var log = require('../log');
89
var core = require('../core');
910
var session = require('../session');
@@ -79,18 +80,12 @@ function showProgress(problems) {
7980
printLine('Hard', stats.hard.ac, stats.hard.all);
8081
}
8182

82-
const CHARS = {
83-
ac: h.isWindows() ? 'O ' : '▣ ',
84-
notac: h.isWindows() ? 'X ' : '▤ ',
85-
none: h.isWindows() ? 'o ' : '⬚ ',
86-
};
87-
8883
function showGraph(problems) {
8984
const ICONS = {
90-
ac: chalk.green(CHARS.ac),
91-
notac: chalk.red(CHARS.notac),
92-
none: chalk.gray(CHARS.none),
93-
empty: ' '
85+
ac: chalk.green(icon.ac),
86+
notac: chalk.red(icon.notac),
87+
none: chalk.gray(icon.none),
88+
empty: icon.empty
9489
};
9590

9691
// row header is 4 bytes
@@ -101,9 +96,9 @@ function showGraph(problems) {
10196
if (groups > 5) groups = 5;
10297

10398
const header = _.range(groups)
104-
.map(x => sprintf('%5d%18d', x * 10 + 1, x * 10 + 10))
99+
.map(x => sprintf('%4d%18d', x * 10 + 1, x * 10 + 10))
105100
.join('');
106-
log.info(' ' + header);
101+
log.info(' ' + header);
107102

108103
const graph = [];
109104
for (let problem of problems)
@@ -112,33 +107,33 @@ function showGraph(problems) {
112107
let line = [sprintf(' %03d', 0)];
113108
for (let i = 1, n = graph.length; i <= n; ++i) {
114109
// padding before group
115-
if (i % 10 === 1) line.push(' ');
110+
if (i % 10 === 1) line.push(' ');
116111

117112
line.push(graph[i] || ICONS.empty);
118113

119114
// time to start new row
120115
if (i % (10 * groups) === 0 || i === n) {
121-
log.info(line.join(''));
116+
log.info(line.join(''));
122117
line = [sprintf(' %03d', i)];
123118
}
124119
}
125120

126121
log.info();
127122
log.printf('%7s%s%3s%s%3s%s',
128-
' ', ICONS.ac + chalk.green(' Accepted'),
129-
' ', ICONS.notac + chalk.red(' Not Accepted'),
130-
' ', ICONS.none + ' Remaining');
123+
' ', ICONS.ac + chalk.green(' Accepted'),
124+
' ', ICONS.notac + chalk.red(' Not Accepted'),
125+
' ', ICONS.none + ' Remaining');
131126
}
132127

133128
function showCal() {
134129
const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
135130
const WEEKDAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
136131
const ICONS = [
137-
CHARS.none,
138-
chalk.sprint(CHARS.ac,'#ffffcc'),
139-
chalk.sprint(CHARS.ac,'#ccff66'),
140-
chalk.sprint(CHARS.ac,'#66cc33'),
141-
chalk.sprint(CHARS.ac,'#00ff00')
132+
icon.none,
133+
chalk.white(icon.ac),
134+
chalk.green(icon.ac),
135+
chalk.yellow(icon.ac),
136+
chalk.red(icon.ac)
142137
];
143138

144139
const N_MONTHS = 12;
@@ -192,15 +187,15 @@ function showCal() {
192187
if (idx === 0 && d.month() % 2) icon = chalk.gray(icon);
193188
line.push(icon);
194189
}
195-
log.info(line.join(''));
190+
log.info(line.join(''));
196191
}
197192

198193
log.info();
199-
log.printf('%7s%s%3s%s%3s%s%3s%s',
200-
' ', ICONS[1] + ' 1~5',
201-
' ', ICONS[2] + ' 6~10',
202-
' ', ICONS[3] + ' 11~15',
203-
' ', ICONS[4] + ' 16+');
194+
log.printf('%8s%s%3s%s%3s%s%3s%s',
195+
' ', ICONS[1] + ' 1~5',
196+
' ', ICONS[2] + ' 6~10',
197+
' ', ICONS[3] + ' 11~15',
198+
' ', ICONS[4] + ' 16+');
204199
}
205200

206201
cmd.handler = function(argv) {

‎lib/icon.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ const icons = {
99
like: '★',
1010
unlike: '☆',
1111
lock: '🔒',
12-
none: ' ',
12+
empty: ' ',
13+
ac: '▣',
14+
notac: '▤',
15+
none: '⬚',
1316

1417
themes: new Map()
1518
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /