Added clear screen function for linux and win32
This commit is contained in:
parent
860cd8cd81
commit
5878d588d8
5 changed files with 47 additions and 8 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -15,4 +15,5 @@ update_check.o
|
|||
man.o
|
||||
calc.o
|
||||
math_ext.o
|
||||
your-reality.o
|
||||
your-reality.o
|
||||
clear_screen.o
|
||||
12
main.c
12
main.c
|
|
@ -21,9 +21,10 @@
|
|||
#include "utils/sys_info.h"
|
||||
#include "utils/update_check.h"
|
||||
#include "utils/calc.h"
|
||||
#include "utils/clear_screen.h"
|
||||
|
||||
|
||||
#define VERSION "0.2.6"
|
||||
#define VERSION "0.3.1"
|
||||
|
||||
bool VER_CHECK_ON_START = true;
|
||||
bool DEV_MODE = false;
|
||||
|
|
@ -118,6 +119,7 @@ int main(int argc, char *argv[]){
|
|||
snprintf(buffer, sizeof(buffer), "Starting netbenixCMD (Version: %s)", VERSION);
|
||||
logger(buffer);
|
||||
log_Specs(); //Log system specs
|
||||
clearScreen(); //Clear the screen
|
||||
showLogo(); //Show the logo
|
||||
logger("Logo Displayed.");
|
||||
if(argc > 2){
|
||||
|
|
@ -129,19 +131,19 @@ int main(int argc, char *argv[]){
|
|||
//Check the startup args
|
||||
if(argc == 2){
|
||||
if(!strcmp(argv[1], "--help")){
|
||||
logger("Showing Help.");
|
||||
logger("Showing help.");
|
||||
outputHelp();
|
||||
exit(0);
|
||||
} else if (!strcmp(argv[1], "--gtk-test")){
|
||||
logger("Stating GTK Test.");
|
||||
logger("Stating GTK test.");
|
||||
createGTKTestWindow();
|
||||
exit(0);
|
||||
} else if (!strcmp(argv[1], "--sys-info")){
|
||||
logger("Showing System Information.");
|
||||
logger("Showing system information.");
|
||||
print_Specs();
|
||||
exit(0);
|
||||
} else if (!strcmp(argv[1], "--sql-test")){
|
||||
logger("Starting SQL Test.");
|
||||
logger("Starting SQL test.");
|
||||
testSQLConnection();
|
||||
exit(0);
|
||||
} else if (!strcmp(argv[1], "--no-version-check")){
|
||||
|
|
|
|||
6
makefile
6
makefile
|
|
@ -2,7 +2,7 @@ CC= gcc
|
|||
ARGS= -export-dynamic -ansi -std=gnu99
|
||||
CFLAGS= $(shell pkg-config --cflags gtk+-3.0) -I/usr/include/mysql
|
||||
LDLIBS= $(shell pkg-config --libs gtk+-3.0) -L/usr/lib/mysql -lmysqlclient -lm
|
||||
OBJ= main.o logo.o logger.o help.o sys_info.o gtk_test.o sql_test.o show_dir.o change_dir.o update_check.o man.o your-reality.o math_ext.o calc.o
|
||||
OBJ= main.o logo.o logger.o help.o sys_info.o gtk_test.o sql_test.o show_dir.o change_dir.o update_check.o man.o your-reality.o math_ext.o calc.o clear_screen.o
|
||||
netbenixCMD: $(OBJ)
|
||||
$(CC) $(CFLAGS) $(ARGS) -o netbenixCMD $(OBJ) $(LDLIBS)
|
||||
main.o: main.c
|
||||
|
|
@ -32,4 +32,6 @@ math_ext.o: etc/math_ext.c
|
|||
your-reality.o: etc/your-reality.c
|
||||
$(CC) $(CFLAGS) -c etc/your-reality.c
|
||||
calc.o: utils/calc.c
|
||||
$(CC) $(CFLAGS) -c utils/calc.c
|
||||
$(CC) $(CFLAGS) -c utils/calc.c
|
||||
clear_screen.o: utils/clear_screen.c
|
||||
$(CC) $(CFLAGS) -c utils/clear_screen.c
|
||||
28
utils/clear_screen.c
Normal file
28
utils/clear_screen.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include <stdio.h>
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#elif defined(__linux__)
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "clear_screen.h"
|
||||
|
||||
|
||||
void clearScreen(){
|
||||
#if defined(_WIN32)
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
int rows;
|
||||
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
|
||||
rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
|
||||
for(int i = 0; i < rows; i++){
|
||||
printf("\n");
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
struct winsize w;
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
||||
for(int i = 0; i < w.ws_row; i++){
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
6
utils/clear_screen.h
Normal file
6
utils/clear_screen.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef _CLEAR_SCREEN_H_
|
||||
#define _CLEAR_SCREEN_H_
|
||||
|
||||
void clearScreen();
|
||||
|
||||
#endif
|
||||
Reference in a new issue