1 /************************************************************************
3 * voxelands - 3d voxel world sandbox game
4 * Copyright (C) Lisa 'darkrose' Milne 2016 <lisa@ltmnet.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>
18 ************************************************************************/
24 void sys_console_print(char* str
, int newline
)
28 void sys_console_printf(char* fmt
, ...)
32 void sys_console_init()
36 void sys_console_exit()
42 /* at present this is just an over-complicated printf
43 * it should become an interective shell for dealing with the server */
49 #include <sys/ioctl.h>
51 /* add a single line of text to the system console */
52 static void sys_console_addline(char* str
)
57 /* print text to the system console */
58 void sys_console_print(char* str
, int newline
)
70 ioctl(STDIN_FILENO
, TIOCGSIZE
, &ts
);
75 ioctl(STDIN_FILENO
, TIOCGWINSZ
, &ts
);
88 e
= utf8_strchr(b
,'\n',NULL
);
100 l
= utf8_strlen(buff
);
103 l
= utf8_offset(buff
,i
);
110 if (strlen(b
) > max
) {
114 l
= utf8_strlen(buff
);
117 l
= utf8_offset(buff
,i
);
126 sys_console_addline(buff
);
130 /* print formatted text to the system console */
131 void sys_console_printf(char* fmt
, ...)
141 if (vsnprintf(buff
, 1024, fmt
, ap
) >= 1024) {
148 sys_console_print(buff
, 0);
151 void sys_console_init()
153 sys_console_print("\n\n",0);
154 sys_console_print("___ ___ __\n",0);
155 sys_console_print("\\ \\ / /______ __ ____ | | ___ ____ ___ ______\n",0);
156 sys_console_print(" \\ \\/ / _ \\ \\/ // __ \\| |/ _ \\ / \\| \\/ ___/\n",0);
157 sys_console_print(" \\ /| |_| | \\ ___/| | _ \\ | \\ | |___ \\\n",0);
158 sys_console_print(" \\ / \\___ >_/\\ > __ >__|_/ \\ >__| /___/____ >\n",0);
159 sys_console_print(" \\/ \\/ \\/ \\/ \\/ \\/ \\/\n",0);
160 sys_console_printf("\nVersion: %s\n",VERSION
);
163 void sys_console_exit()