Nspire I/O  3.0
 All Data Structures Files Functions Pages
Functions | Variables
console.c File Reference
#include "nspireio.h"
#include <os.h>

Functions

void nio_grid_puts (const int offset_x, const int offset_y, const int x, const int y, const char *str, const char bgColor, const char textColor)
 
void nio_grid_putc (const int offset_x, const int offset_y, const int x, const int y, const char ch, const char bgColor, const char textColor)
 
void nio_use_stdio (void)
 
void nio_free_stdio (void)
 
void nio_load (const char *path, nio_console *c)
 
void nio_save (const char *path, const nio_console *c)
 
void nio_set_default (nio_console *c)
 
char nio_getch (nio_console *c)
 
void nio_init (nio_console *c, const int size_x, const int size_y, const int offset_x, const int offset_y, const char background_color, const char foreground_color, const BOOL drawing_enabled)
 
int nio_fflush (nio_console *c)
 
void nio_clear (nio_console *c)
 
void nio_scroll (nio_console *c)
 
void nio_csl_drawchar (nio_console *c, const int pos_x, const int pos_y)
 
void nio_csl_savechar (nio_console *c, const char ch, const int pos_x, const int pos_y)
 
char nio_fputc (char ch, nio_console *c)
 
char nio_putchar (const char ch)
 
int nio_fputs (const char *str, nio_console *c)
 
int nio_puts (const char *str)
 
int nio_fprintf (nio_console *c, const char *format,...)
 
int nio_printf (const char *format,...)
 
void nio_perror (const char *str)
 
void nio_color (nio_console *c, const char background_color, const char foreground_color)
 
void nio_drawing_enabled (nio_console *c, const BOOL enable_drawing)
 
char nio_fgetc (nio_console *c)
 
char nio_getchar (void)
 
char * nio_fgets (char *str, int num, nio_console *c)
 
char * nio_gets (char *str)
 
void nio_free (nio_console *c)
 

Variables

nio_consolenio_default = NULL
 
BOOL shift = FALSE
 
BOOL caps = FALSE
 
BOOL ctrl = FALSE
 

Detailed Description

Author
Julian Mackeben aka compu compu.nosp@m.juck.nosp@m.el@go.nosp@m.ogle.nosp@m.mail..nosp@m.com
Version
3.0

LICENSE

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

DESCRIPTION

Console functions

Function Documentation

void nio_clear ( nio_console c)

Clears a console.

Parameters
cConsole
void nio_color ( nio_console c,
const char  background_color,
const char  foreground_color 
)

Sets the background- and text color of a console. Possible values are 0-15.

Parameters
cConsole
background_colorBackground color
foreground_colorText color
void nio_csl_drawchar ( nio_console c,
const int  pos_x,
const int  pos_y 
)

Draws a char from the console to the screen. For internal use.

Parameters
cConsole
pos_xx position
pos_yy position
void nio_csl_savechar ( nio_console c,
const char  ch,
const int  pos_x,
const int  pos_y 
)

Saves a char in a console without drawing it. For internal use.

Parameters
cConsole
chChar
pos_xx position
pos_yy position
void nio_drawing_enabled ( nio_console c,
const BOOL  enable_drawing 
)

Changes the drawing behavior of a console.

Parameters
cConsole
enable_drawingIf this is true, a console will automatically be updated if text is written to it.
int nio_fflush ( nio_console c)

See fflush

Note
This is useful for consoles with enable_drawing set to false. Using this function will result in the console being drawn.
char nio_fgetc ( nio_console c)

See fgetc

char* nio_fgets ( char *  str,
int  num,
nio_console c 
)

See fgets

Todo:
Do not ignore num
int nio_fprintf ( nio_console c,
const char *  format,
  ... 
)

See fprintf

char nio_fputc ( char  ch,
nio_console c 
)

See fputc

int nio_fputs ( const char *  str,
nio_console c 
)

See fputs

void nio_free ( nio_console c)

Uninitializes a console. This should always be called before the program ends.

Parameters
cConsole
void nio_free_stdio ( void  )

For use with NIO_REPLACE_STDIO. Use at the end of your program.

char nio_getch ( nio_console c)

Immediately gets a char from the keyboard. For internal use.

Parameters
cConsole
Returns
Char
char nio_getchar ( void  )

See getchar

char* nio_gets ( char *  str)

See gets

void nio_grid_putc ( const int  offset_x,
const int  offset_y,
const int  x,
const int  y,
const char  ch,
const char  bgColor,
const char  textColor 
)

Draws a char to the screen on the given position. For internal use.

Parameters
offset_xx offset in px
offset_yy offset in px
xx position in columns (px*6)
yy position in rows (px*8)
cChar
bgColorBackground color
textColortext color
void nio_grid_puts ( const int  offset_x,
const int  offset_y,
const int  x,
const int  y,
const char *  str,
const char  bgColor,
const char  textColor 
)

Draws a string to the screen on the given position. For internal use.

Parameters
offset_xx offset in px
offset_yy offset in px
xx position in columns (px*6)
yy position in rows (px*8)
strString
bgColorBackground color
textColortext color
void nio_init ( nio_console c,
const int  size_x,
const int  size_y,
const int  offset_x,
const int  offset_y,
const char  background_color,
const char  foreground_color,
const BOOL  drawing_enabled 
)

Initializes a console.

Parameters
cConsole
size_xconsole width
size_yconsole height
offset_xx position
offset_yy position
background_colorBackground color
foreground_colorText color
drawing_enabledSee nio_enable_drawing()
void nio_load ( const char *  path,
nio_console c 
)

Loads a console from a file on flash storage.

Parameters
pathFile path
cConsole
void nio_perror ( const char *  str)

See perror

int nio_printf ( const char *  format,
  ... 
)

See printf

char nio_putchar ( const char  ch)

See putchar

int nio_puts ( const char *  str)

See puts

void nio_save ( const char *  path,
const nio_console c 
)

Saves a console to a file in flash storage.

Parameters
pathFile path
cConsole
void nio_scroll ( nio_console c)

Scrolls a console one line down.

Parameters
cConsole
void nio_set_default ( nio_console c)

Sets a default console that will be used for all functions without console argument, e.g. nio_puts()

Parameters
cConsole
void nio_use_stdio ( void  )

For use with NIO_REPLACE_STDIO. Use at the beginning of your program.