}
return len + ((int)strlen(str) - (int)mbstowcs(NULL, str, 0));
}
+
+void cursortocolumn(int column)
+{
+ printf("\033[%dG", column);
+}
+
+void cursorhide(void)
+{
+ printf("\033[?25l");
+}
+
+void cursorshow(void)
+{
+ printf("\033[?25h");
+}
+
+void eraseline(void)
+{
+ printf("\033[2K");
+}
uint32_t getunitdivider(int unit, int index);
char *getratestring(float rate, int len, int declen, int unit);
int getpadding(int len, char *str);
+void cursortocolumn(int column);
+void cursorhide(void);
+void cursorshow(void);
+void eraseline(void);
#endif
sleep(sampletime-((sampletime/3)*3));
}
- len=strlen(buffer)+3;
-
- for (i=0;i<len;i++) {
- printf("\b \b");
- }
+ cursortocolumn(1);
+ eraseline();
/* read those values again... */
if (!getifinfo(iface)) {
exit(EXIT_FAILURE);
}
+ cursorhide();
+
/* loop until user gets bored */
while (intsignal==0) {
/* read those values again... */
if (!getifinfo(iface)) {
+ cursorshow();
printf("Error: Interface \"%s\" not available, exiting.\n", iface);
exit(EXIT_FAILURE);
}
if (debug) {
printf("\nlinelen: %d\n", len);
} else {
- for (i=0;i<len;i++) {
- printf("\b \b");
- }
- fflush(stdout);
+ cursortocolumn(1);
+ eraseline();
}
}
if (cfg.ostyle!=4) {
}
timespent = (uint64_t)time(NULL) - timespent - timeslept;
+ cursorshow();
printf("\n\n");