Design Pattern Examples
Overview of object-oriented design patterns
cursor.c File Reference

Implementation of the setcursorposition() and getcursorposition() functions for manipulating the cursor position on Windows terminals. More...

#include <stdlib.h>
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include "cursor.h"
#include "split.h"
Include dependency graph for cursor.c:

Go to the source code of this file.

Functions

static void _disableInputEcho (void)
 Disable echoing of input and disable line input mode (where the Enter key must be entered to complete input).
 
static void _enableInputEcho (void)
 Enable echoing of input.
 
void disableinputecho (void)
 Disable echoing input until enableinputecho() is called.
 
void enableinputecho (void)
 Enable echoing input, which should be the default mode. Call this only after calling disableinputecho();.
 
void setcursorposition (int row, int column)
 Move the text cursor to the specified screen coordinates.
 
void getcursorposition (int *row, int *column)
 Retrieve the current cursor position in the console window.
 

Variables

static bool inputEchoDisabled = false
 
static struct termios oldt newt
 

Detailed Description

Implementation of the setcursorposition() and getcursorposition() functions for manipulating the cursor position on Windows terminals.

Definition in file cursor.c.

Function Documentation

◆ _disableInputEcho()

static void _disableInputEcho ( void  )
static

Disable echoing of input and disable line input mode (where the Enter key must be entered to complete input).

Definition at line 64 of file cursor.c.

References inputEchoDisabled, and newt.

Referenced by Helpers::disableinputecho(), disableinputecho(), getcursorposition(), and Helpers::getcursorposition().

◆ _enableInputEcho()

static void _enableInputEcho ( void  )
static

Enable echoing of input.

Definition at line 89 of file cursor.c.

References inputEchoDisabled.

Referenced by Helpers::enableinputecho(), enableinputecho(), getcursorposition(), and Helpers::getcursorposition().

◆ disableinputecho()

void disableinputecho ( void  )

Disable echoing input until enableinputecho() is called.

Definition at line 112 of file cursor.c.

References _disableInputEcho(), and inputEchoDisabled.

Referenced by Flyweight_Exercise().

◆ enableinputecho()

void enableinputecho ( void  )

Enable echoing input, which should be the default mode. Call this only after calling disableinputecho();.

Definition at line 123 of file cursor.c.

References _enableInputEcho(), and inputEchoDisabled.

Referenced by Flyweight_Exercise().

◆ getcursorposition()

void getcursorposition ( int *  row,
int *  column 
)

Retrieve the current cursor position in the console window.

Parameters
rowReturns the row index from the top, starting at 0.
columnReturns the column index from the left, starting at 0.

Definition at line 143 of file cursor.c.

References _disableInputEcho(), _enableInputEcho(), inputEchoDisabled, split(), SplitList_Clear(), SplitList::strings, and SplitList::strings_count.

Referenced by Flyweight_Exercise().

◆ setcursorposition()

void setcursorposition ( int  row,
int  column 
)

Move the text cursor to the specified screen coordinates.

Parameters
rowRow index from top, starting at 0.
columnColumn index from left, starting at 0

Definition at line 134 of file cursor.c.

Referenced by Flyweight_Exercise().

Variable Documentation

◆ inputEchoDisabled

◆ newt

struct termios oldt newt
static

Definition at line 26 of file cursor.c.

Referenced by _disableInputEcho().