summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorKarol Baraniecki <karol@baraniecki.eu>2023-03-12 09:46:58 +0100
committerAndrew Kaster <andrewdkaster@gmail.com>2023-04-25 01:54:53 -0600
commit119dc042ab9f53db10d91052003af8e126277431 (patch)
tree87855831a2411f12de0fc7188ea29a4858064f7c /Userland
parent71cc35ae40a2c3e62357b5d96b789f491b119ea7 (diff)
downloadserenity-119dc042ab9f53db10d91052003af8e126277431.zip
cal: Mark the current day as inverted text
...instead of putting a star `*` next to it. This makes `cal`s output much prettier, and gets rid of one FIXME. :^) Don't use the escape sequence from the deleted FIXME - \e[30;47m would set the background to white and foreground to black - which presumably wouldn't do much on a light-theme terminal. Instead use \e[7m which sets the color as "inverted".
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Utilities/cal.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/Userland/Utilities/cal.cpp b/Userland/Utilities/cal.cpp
index cd73381f87..7340d6cd0d 100644
--- a/Userland/Utilities/cal.cpp
+++ b/Userland/Utilities/cal.cpp
@@ -13,6 +13,9 @@
#include <LibMain/Main.h>
#include <time.h>
+#define ANSI_INVERT_OUTPUT "\e[7m"
+#define ANSI_RESET_OUTPUT "\e[0m"
+
int const line_width = 70;
int const line_count = 8;
int const column_width = 22;
@@ -41,9 +44,7 @@ static ErrorOr<Vector<String>> month_lines_to_print(int month, int year)
row.append(" "sv);
} else {
if (year == current_year && month == current_month && day_to_print == current_day) {
- // FIXME: To replicate Unix cal it would be better to use "\x1b[30;47m%2d\x1b[0m " in here instead of *.
- // However, doing that messes up the layout.
- row.appendff("{:02}*", day_to_print);
+ row.appendff(ANSI_INVERT_OUTPUT "{:02}" ANSI_RESET_OUTPUT " ", day_to_print);
} else {
row.appendff("{:02} ", day_to_print);
}