jaffarCommon
Loading...
Searching...
No Matches
Functions | Variables
ncurses.hpp File Reference

Contains common functions related to output and logging using NCurses. More...

#include "../string.hpp"
#include <ncurses.h>
#include <stdarg.h>
#include <stdexcept>
#include <stdio.h>
#include <unistd.h>
Include dependency graph for ncurses.hpp:

Go to the source code of this file.

Functions

template<typename... Args>
__JAFFAR_COMMON__INLINE__ void jaffarCommon::logger::log (const char *f, Args... args)
 
__JAFFAR_COMMON__INLINE__ int jaffarCommon::logger::kbhit ()
 
__JAFFAR_COMMON__INLINE__ int jaffarCommon::logger::waitForKeyPress ()
 
__JAFFAR_COMMON__INLINE__ int jaffarCommon::logger::getKeyPress ()
 
__JAFFAR_COMMON__INLINE__ void jaffarCommon::logger::initializeTerminal ()
 
__JAFFAR_COMMON__INLINE__ void jaffarCommon::logger::clearTerminal ()
 
__JAFFAR_COMMON__INLINE__ void jaffarCommon::logger::finalizeTerminal ()
 
__JAFFAR_COMMON__INLINE__ void jaffarCommon::logger::refreshTerminal ()
 

Variables

static bool jaffarCommon::logger::_useNCurses = false
 

Detailed Description

Contains common functions related to output and logging using NCurses.

Function Documentation

◆ clearTerminal()

__JAFFAR_COMMON__INLINE__ void jaffarCommon::logger::clearTerminal ( )

Clears the NCurses terminal

◆ finalizeTerminal()

__JAFFAR_COMMON__INLINE__ void jaffarCommon::logger::finalizeTerminal ( )

Finalizes the NCurses terminal

◆ getKeyPress()

__JAFFAR_COMMON__INLINE__ int jaffarCommon::logger::getKeyPress ( )

Returns any pending key pressed.

Note
This function returns immediately
Returns
Which key was pressed, the macro ERR if no key was pressed

◆ initializeTerminal()

__JAFFAR_COMMON__INLINE__ void jaffarCommon::logger::initializeTerminal ( )

Initializes the NCurses terminal

◆ kbhit()

__JAFFAR_COMMON__INLINE__ int jaffarCommon::logger::kbhit ( )

Function to check the keyboard buffer for whether there have been any keypress

Note
Taken from https://github.com/ajpaulson/learning-ncurses/blob/master/kbhit.c
Returns
True, if a key was hit; False, otherwise

◆ log()

template<typename... Args>
__JAFFAR_COMMON__INLINE__ void jaffarCommon::logger::log ( const char *  f,
Args...  args 
)

Prints the specified formatted string to the NCurses or normal terminal, as configured

Parameters
[in]fThe formatted string
[in]argsThe arguments to the formatted string

◆ refreshTerminal()

__JAFFAR_COMMON__INLINE__ void jaffarCommon::logger::refreshTerminal ( )

Refreshes the NCurses terminal. This is necessary after every logging operation to update the screen.

◆ waitForKeyPress()

__JAFFAR_COMMON__INLINE__ int jaffarCommon::logger::waitForKeyPress ( )

Stalls execution until a key is pressed. It will only return upon the first key press and will report which key it was

Note
This function employs active polling so should be used sparringly
Returns
Which key was pressed

Variable Documentation

◆ _useNCurses

bool jaffarCommon::logger::_useNCurses = false
static

A global setting to store whether NCurses or the normal terminal should be used