unix_console.c File Reference

console functions for *nix ports More...

#include "../../common/common.h"
#include "../system.h"
#include <unistd.h>
#include <signal.h>
#include <termios.h>
#include <fcntl.h>
#include <sys/time.h>
Include dependency graph for unix_console.c:

Go to the source code of this file.

Data Structures

struct  consoleHistory_t

Defines

#define CON_HISTORY   32

Functions

static void CON_FlushIn (void)
 Flush stdin, I suspect some terminals are sending a LOT of shit.
static void Sys_TTYDeleteCharacter (void)
 Output a backspace.
static void Sys_TTYConsoleHide (void)
 Clear the display of the line currently edited bring cursor back to beginning of line.
static void Sys_TTYConsoleShow (void)
 Show the current line.
static void Sys_TTYConsoleHistoryAdd (consoleHistory_t *field)
static consoleHistory_tSys_TTYConsoleHistoryPrevious (void)
static consoleHistory_tSys_TTYConsoleHistoryNext (void)
static void Sys_TTYConsoleSigCont (int signum)
 Reinitialize console input after receiving SIGCONT, as on Linux the terminal seems to lose all set attributes if user did CTRL+Z and then does fg again.
void Sys_ShowConsole (qboolean show)
void Sys_ConsoleShutdown (void)
 Shutdown the console.
static void Sys_TTYConsoleHistoryClear (consoleHistory_t *edit)
static qboolean Sys_IsATTY (void)
void Sys_ConsoleInit (void)
 Initialize the console input (tty mode if possible).
const char * Sys_ConsoleInput (void)
void Sys_ConsoleOutput (const char *string)

Variables

static qboolean stdinActive
static qboolean ttyConsoleActivated = qfalse
static int TTY_erase
static int TTY_eof
static struct termios TTY_tc
static consoleHistory_t ttyConsoleHistory
static consoleHistory_t ttyEditLines [CON_HISTORY]
static int histCurrent = -1
static int histCount = 0

Detailed Description

console functions for *nix ports

Definition in file unix_console.c.


Define Documentation

#define CON_HISTORY   32

Definition at line 53 of file unix_console.c.

Referenced by Sys_TTYConsoleHistoryNext().


Function Documentation

static void CON_FlushIn ( void   )  [static]

Flush stdin, I suspect some terminals are sending a LOT of shit.

Todo:
relevant?

Definition at line 61 of file unix_console.c.

References key.

Referenced by Sys_ConsoleInput().

void Sys_ConsoleInit ( void   ) 

Initialize the console input (tty mode if possible).

Definition at line 225 of file unix_console.c.

References Com_Printf(), qfalse, qtrue, stdinActive, Sys_IsATTY(), Sys_TTYConsoleHistoryClear(), Sys_TTYConsoleSigCont(), TTY_eof, TTY_erase, TTY_tc, and ttyConsoleActivated.

const char* Sys_ConsoleInput ( void   ) 
void Sys_ConsoleOutput ( const char *  string  ) 
Note:
if the user is editing a line when something gets printed to the early console then it won't look good so we provide CON_Hide and CON_Show to be called before and after a stdout or stderr output

Definition at line 399 of file unix_console.c.

References COLORED_GREEN, qfalse, qtrue, and Sys_ShowConsole().

void Sys_ConsoleShutdown ( void   ) 

Shutdown the console.

Note:
Never exit without calling this, or your terminal will be left in a pretty bad state

Definition at line 200 of file unix_console.c.

References Sys_TTYDeleteCharacter(), TTY_tc, and ttyConsoleActivated.

static qboolean Sys_IsATTY ( void   )  [static]

Definition at line 216 of file unix_console.c.

Referenced by Sys_ConsoleInit().

void Sys_ShowConsole ( qboolean  show  ) 

Definition at line 177 of file unix_console.c.

References Sys_TTYConsoleHide(), Sys_TTYConsoleShow(), and ttyConsoleActivated.

static void Sys_TTYConsoleHide ( void   )  [static]

Clear the display of the line currently edited bring cursor back to beginning of line.

Definition at line 91 of file unix_console.c.

References consoleHistory_t::cursor, i, and Sys_TTYDeleteCharacter().

Referenced by Sys_ShowConsole().

static void Sys_TTYConsoleHistoryAdd ( consoleHistory_t field  )  [static]

Definition at line 116 of file unix_console.c.

References histCount, histCurrent, i, and lengthof.

Referenced by Sys_ConsoleInput().

static void Sys_TTYConsoleHistoryClear ( consoleHistory_t edit  )  [static]

Definition at line 211 of file unix_console.c.

Referenced by Sys_ConsoleInit(), and Sys_ConsoleInput().

static consoleHistory_t* Sys_TTYConsoleHistoryNext ( void   )  [static]

Definition at line 153 of file unix_console.c.

References CON_HISTORY, histCount, and histCurrent.

Referenced by Sys_ConsoleInput().

static consoleHistory_t* Sys_TTYConsoleHistoryPrevious ( void   )  [static]

Definition at line 136 of file unix_console.c.

References histCount, histCurrent, and lengthof.

Referenced by Sys_ConsoleInput().

static void Sys_TTYConsoleShow ( void   )  [static]

Show the current line.

Todo:
need to position the cursor if needed?

Definition at line 105 of file unix_console.c.

References consoleHistory_t::buffer, consoleHistory_t::cursor, and i.

Referenced by Sys_ShowConsole().

static void Sys_TTYConsoleSigCont ( int  signum  )  [static]

Reinitialize console input after receiving SIGCONT, as on Linux the terminal seems to lose all set attributes if user did CTRL+Z and then does fg again.

Definition at line 172 of file unix_console.c.

References Sys_ConsoleInit().

Referenced by Sys_ConsoleInit().

static void Sys_TTYDeleteCharacter ( void   )  [static]

Output a backspace.

Note:
it seems on some terminals just sending '' is not enough so instead we send "\b \b"
Todo:
there may be a way to find out if '' alone would work though

Definition at line 74 of file unix_console.c.

References key.

Referenced by Sys_ConsoleInput(), Sys_ConsoleShutdown(), and Sys_TTYConsoleHide().


Variable Documentation

int histCount = 0 [static]
int histCurrent = -1 [static]

Definition at line 39 of file unix_console.c.

Referenced by Sys_ConsoleInit(), and Sys_ConsoleInput().

int TTY_eof [static]

Definition at line 45 of file unix_console.c.

Referenced by Sys_ConsoleInit().

int TTY_erase [static]

Definition at line 44 of file unix_console.c.

Referenced by Sys_ConsoleInit(), and Sys_ConsoleInput().

struct termios TTY_tc [static]

Definition at line 47 of file unix_console.c.

Referenced by Sys_ConsoleInit(), and Sys_ConsoleShutdown().

qboolean ttyConsoleActivated = qfalse [static]

Definition at line 49 of file unix_console.c.

consoleHistory_t ttyEditLines[CON_HISTORY] [static]

Definition at line 54 of file unix_console.c.


Generated by  doxygen 1.6.2