Kaynağa Gözat

vcc: more pretty! message time

intirain 4 yıl önce
ebeveyn
işleme
33d62834df
4 değiştirilmiş dosya ile 19 ekleme ve 7 silme
  1. 3 3
      Makefile
  2. 1 0
      include/vcc/pretty.h
  3. 2 2
      include/vcc/version.h
  4. 13 2
      pretty.c

+ 3 - 3
Makefile

@@ -1,7 +1,7 @@
 VCCD_MAJOR 		= 1
-VCCD_MINOR 		= 2
-VCCD_PATCH 		= 1
-VCCD_STR 		= -release 
+VCCD_MINOR 		= 3
+VCCD_PATCH 		= 0
+VCCD_STR 		= -rc 
 
 VCCD_COMPILE_TIME 	= $(shell date)
 VCCD_COMPILE_BY 	= $(shell whoami)

+ 1 - 0
include/vcc/pretty.h

@@ -65,6 +65,7 @@ struct theme {
 			sysusername, 
 			msg, 
 			sysmsg, 
+			time, 
 			errmsg, 
 			helpcmd, 
 			helpmsg;

+ 2 - 2
include/vcc/version.h

@@ -1,2 +1,2 @@
-#define VCCD_VERSION "vccd 1.2.1 Sun Mar 20 12:09:23 CST 2022 root"
-#define VCCD_SYMVER "vcc 1.2.1-release "
+#define VCCD_VERSION "vccd 1.3.0 2022年 03月 20日 星期日 17:05:54 CST root"
+#define VCCD_SYMVER "vcc 1.3.0-rc "

+ 13 - 2
pretty.c

@@ -21,6 +21,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <sys/times.h>
 
 #include <vcc/vcc.h>
 #include <vcc/version.h>
@@ -51,6 +52,12 @@ struct theme theme_def = {
 		.bg = BG_BLACK, 
 		.mode = MODE_HIGHLIGHT
 	}, 
+
+	.time = {
+		.fg = FG_YELLOW, 
+		.bg = BG_BLACK, 
+		.mode = MODE_HIGHLIGHT
+	}, 
 	
 	.errmsg = {
 		.fg = FG_RED, 
@@ -77,6 +84,7 @@ struct theme *current_theme = &theme_def;
 #define curr_sysusername 	(&current_theme->sysusername)
 #define curr_msg 		(&current_theme->msg)
 #define curr_sysmsg 		(&current_theme->sysmsg)
+#define curr_time 		(&current_theme->time)
 #define curr_errmsg 		(&current_theme->errmsg)
 #define curr_helpcmd 		(&current_theme->helpcmd)
 #define curr_helpmsg 		(&current_theme->helpmsg)
@@ -85,14 +93,17 @@ struct theme *current_theme = &theme_def;
 int pretty_new_msg(char *usrname, char *buf) {
 	ansi_csi_st(stdout, MODE_HIGHLIGHT, FG_BLACK, BG_BLACK);
 
+	setcolor(stdout, curr_time);
+	printf("\r[%ld] ", times(NULL));
+
 	if (unlikely(!strcmp(usrname, "system"))) {
 		setcolor(stdout, curr_sysusername);
-		printf("\rsystem");
+		printf("system");
 	}
 
 	else {
 		setcolor(stdout, curr_usrname);
-		printf("\r%s", usrname);
+		printf("%s", usrname);
 	}
 
 	ansi_csi_ed(stdout);