apps/graphics/pdcurs34: Integration of termcurses into pdcurses, plus pdcurses updates for multi-thread support
This commit is contained in:
parent
fcd15d8786
commit
73fc5eb199
@ -78,12 +78,6 @@
|
||||
|
||||
/* Internal macros for attributes */
|
||||
|
||||
#ifdef CONFIG_PDCURSES_CHTYPE_LONG
|
||||
# define PDC_COLOR_PAIRS 256
|
||||
#else
|
||||
# define PDC_COLOR_PAIRS 32
|
||||
#endif
|
||||
|
||||
#ifndef max
|
||||
# define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
@ -108,21 +102,17 @@ extern "C"
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
typedef struct /* Structure for ripped off lines */
|
||||
{
|
||||
int line;
|
||||
int (*init)(WINDOW *, int);
|
||||
} RIPPEDOFFLINE;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
EXTERN WINDOW *pdc_lastscr;
|
||||
EXTERN bool pdc_trace_on; /* Tracing flag */
|
||||
EXTERN bool pdc_color_started;
|
||||
EXTERN unsigned long pdc_key_modifiers;
|
||||
EXTERN MOUSE_STATUS pdc_mouse_status;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
|
@ -1,13 +1,14 @@
|
||||
/****************************************************************************
|
||||
* apps/graphics/pdcurses/term.h
|
||||
* Public Domain Curses
|
||||
*
|
||||
* PDCurses doesn't operate with terminfo, but we need these functions for
|
||||
* compatibility, to allow some things (notably, interface libraries for
|
||||
* other languages) to be compiled. Anyone who tries to actually _use_
|
||||
* them will be disappointed, since they only return ERR.
|
||||
* $Id: term.h,v 1.16 2008/07/13 16:08:16 wmcbrine Exp $
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2017, 2019 Gregory Nutt. All rights reserved.
|
||||
* Adapted by: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Adapted from the original public domain pdcurses by Gregory Nutt and
|
||||
@ -65,19 +66,22 @@ extern "C"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *_termname;
|
||||
FAR const char *_termname;
|
||||
} TERMINAL;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
EXTERN TERMINAL *cur_term;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
FAR void *pdc_alloc_terminal_ctx(void);
|
||||
int del_curterm(TERMINAL *);
|
||||
int putp(const char *);
|
||||
int restartterm(const char *, int, int *);
|
||||
|
@ -187,5 +187,11 @@ config PDCURSES_MOUSE
|
||||
select PDCURSES_HAVE_INPUT
|
||||
depends on MOUSE && !DISABLE_POLL && EXPERIMENTAL
|
||||
|
||||
config PDCURSES_TERMINPUT
|
||||
bool "Terminal Input"
|
||||
default y
|
||||
select PDCURSES_HAVE_INPUT
|
||||
depends on SYSTEM_TERMCURSES && !DISABLE_POLL
|
||||
|
||||
endmenu # Input Devices
|
||||
|
||||
|
@ -36,6 +36,10 @@
|
||||
CSRCS += pdcclip.c pdcdisp.c pdcgetsc.c pdckbd.c pdcscrn.c pdcsetsc.c
|
||||
CSRCS += pdcutil.c
|
||||
|
||||
ifneq ($(CONFIG_PDCURSES_MULTITHREAD),)
|
||||
CSRCS += pdcthread.c
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path nuttx
|
||||
VPATH += :nuttx
|
||||
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/graphics/pdcurs34/nuttx}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* apps/graphics/nuttx/pdcdisp.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2017, 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -40,6 +40,11 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
#include <system/termcurses.h>
|
||||
#endif
|
||||
|
||||
#include <graphics/curses.h>
|
||||
#include "pdcnuttx.h"
|
||||
|
||||
/****************************************************************************
|
||||
@ -552,6 +557,9 @@ static void PDC_putc(FAR struct pdc_fbstate_s *fbstate, int row, int col,
|
||||
#ifdef HAVE_BOLD_FONT
|
||||
bool bold = ((ch & A_BOLD) != 0);
|
||||
#endif
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
/* Clip */
|
||||
|
||||
@ -648,6 +656,259 @@ static void PDC_putc(FAR struct pdc_fbstate_s *fbstate, int row, int col,
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_gotoyx
|
||||
*
|
||||
* Description:
|
||||
* Move the physical cursor (as opposed to the logical cursor affected by
|
||||
* wmove()) to the given location. T his is called mainly from doupdate().
|
||||
* In general, this function need not compare the old location with the
|
||||
* new one, and should just move the cursor unconditionally.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
static void PDC_gotoyx_term(FAR SCREEN *sp, int row, int col)
|
||||
{
|
||||
FAR struct pdc_termscreen_s *termscreen = (FAR struct pdc_termscreen_s *)sp;
|
||||
FAR struct pdc_termstate_s *termstate;
|
||||
|
||||
termstate = &termscreen->termstate;
|
||||
termcurses_moveyx(termstate->tcurs, row, col);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_set_char_attrib_term
|
||||
*
|
||||
* Description:
|
||||
* Sets the specified character attributes.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
static void PDC_set_char_attrib_term(FAR struct pdc_termscreen_s *termscreen,
|
||||
chtype ch)
|
||||
{
|
||||
FAR struct pdc_termstate_s *termstate = &termscreen->termstate;
|
||||
struct termcurses_colors_s colors;
|
||||
short fg;
|
||||
short bg;
|
||||
long attrib;
|
||||
long term_attrib;
|
||||
|
||||
/* Handle the attributes */
|
||||
|
||||
#ifdef CONFIG_PDCURSES_CHTYPE_LONG
|
||||
attrib = ch & (A_BOLD | A_BLINK | A_UNDERLINE | A_INVIS);
|
||||
#else
|
||||
attrib = ch & (A_BOLD | A_BLINK);
|
||||
#endif
|
||||
|
||||
if (attrib != termstate->attrib)
|
||||
{
|
||||
/* Send the ioctl to set the attributes */
|
||||
|
||||
term_attrib = 0;
|
||||
if (attrib & A_BOLD)
|
||||
{
|
||||
term_attrib |= TCURS_ATTRIB_BOLD;
|
||||
}
|
||||
|
||||
if (attrib & A_BLINK)
|
||||
{
|
||||
term_attrib |= TCURS_ATTRIB_BLINK;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PDCURSES_CHTYPE_LONG
|
||||
if (attrib & A_UNDERLINE)
|
||||
{
|
||||
term_attrib |= TCURS_ATTRIB_UNDERLINE;
|
||||
}
|
||||
|
||||
if (attrib & A_INVIS)
|
||||
{
|
||||
term_attrib |= TCURS_ATTRIB_INVIS;
|
||||
}
|
||||
|
||||
termcurses_setattribute(termstate->tcurs, term_attrib);
|
||||
#endif
|
||||
|
||||
termstate->attrib = attrib;
|
||||
}
|
||||
|
||||
/* Get the character colors */
|
||||
|
||||
PDC_pair_content(PAIR_NUMBER(ch), &fg, &bg);
|
||||
|
||||
/* Handle the A_REVERSE attribute. */
|
||||
|
||||
if ((ch & A_REVERSE) != 0)
|
||||
{
|
||||
/* Swap the foreground and background colors if reversed */
|
||||
|
||||
short tmp = fg;
|
||||
fg = bg;
|
||||
bg = tmp;
|
||||
}
|
||||
|
||||
/* Set the color */
|
||||
|
||||
colors.color_mask = 0;
|
||||
|
||||
#ifdef PDCURSES_MONOCHROME
|
||||
if (fg != termstate->fg)
|
||||
{
|
||||
colors.fg_red = termstate->graylevel[fg];
|
||||
colors.fg_green = termstate->graylevel[fg];
|
||||
colors.fg_blue = termstate->graylevel[fg];
|
||||
colors.color_mask |= TCURS_COLOR_FG;
|
||||
}
|
||||
|
||||
if (bg != termstate->bg)
|
||||
{
|
||||
colors.bg_red = termstate->graylevel[bg];
|
||||
colors.bg_green = termstate->graylevel[bg];
|
||||
colors.bg_blue = termstate->graylevel[bg];
|
||||
colors.color_mask |= TCURS_COLOR_BG;
|
||||
}
|
||||
#else
|
||||
if (termstate->rgbcolor[fg].red != termstate->fg_red ||
|
||||
termstate->rgbcolor[fg].green != termstate->fg_green ||
|
||||
termstate->rgbcolor[fg].blue != termstate->fg_blue)
|
||||
{
|
||||
colors.fg_red = termstate->rgbcolor[fg].red;
|
||||
colors.fg_green = termstate->rgbcolor[fg].green;
|
||||
colors.fg_blue = termstate->rgbcolor[fg].blue;
|
||||
colors.color_mask |= TCURS_COLOR_FG;
|
||||
}
|
||||
|
||||
if (termstate->rgbcolor[bg].red != termstate->bg_red ||
|
||||
termstate->rgbcolor[bg].green != termstate->bg_green ||
|
||||
termstate->rgbcolor[bg].blue != termstate->bg_blue)
|
||||
{
|
||||
colors.bg_red = termstate->rgbcolor[bg].red;
|
||||
colors.bg_green = termstate->rgbcolor[bg].green;
|
||||
colors.bg_blue = termstate->rgbcolor[bg].blue;
|
||||
colors.color_mask |= TCURS_COLOR_BG;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (colors.color_mask)
|
||||
{
|
||||
/* Set selected colors with the terminal emulation */
|
||||
|
||||
termcurses_setcolors(termstate->tcurs, &colors);
|
||||
|
||||
/* Save a reference to the last colors sent */
|
||||
|
||||
termstate->fg_red = termstate->rgbcolor[fg].red;
|
||||
termstate->fg_green = termstate->rgbcolor[fg].green;
|
||||
termstate->fg_blue = termstate->rgbcolor[fg].blue;
|
||||
termstate->bg_red = termstate->rgbcolor[bg].red;
|
||||
termstate->bg_green = termstate->rgbcolor[bg].green;
|
||||
termstate->bg_blue = termstate->rgbcolor[bg].blue;
|
||||
}
|
||||
|
||||
}
|
||||
#endif /* CONFIG_SYSTEM_TERMCURSES */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_transform_line_term
|
||||
*
|
||||
* Description:
|
||||
* The core output routine. It takes len chtype entities from srcp (a
|
||||
* pointer into curscr) and renders them to the physical screen at line
|
||||
* lineno, column x. It must also translate characters 0-127 via acs_map[],
|
||||
* if they're flagged with A_ALTCHARSET in the attribute portion of the
|
||||
* chtype.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
static void PDC_transform_line_term(FAR SCREEN *sp, int lineno, int x,
|
||||
int len, FAR const chtype *srcp)
|
||||
{
|
||||
FAR struct pdc_termscreen_s *termscreen = (FAR struct pdc_termscreen_s *)sp;
|
||||
FAR struct pdc_termstate_s *termstate = &termscreen->termstate;
|
||||
int c;
|
||||
int i;
|
||||
char ch;
|
||||
char buffer[128];
|
||||
|
||||
/* Move to the specified line / col */
|
||||
|
||||
PDC_gotoyx_term(sp, lineno, x);
|
||||
|
||||
/* Loop through all characters to be displayed */
|
||||
|
||||
for (c = 0; c < len;)
|
||||
{
|
||||
/* Get the foreground and background colors of the character */
|
||||
|
||||
PDC_set_char_attrib_term(termscreen, *srcp);
|
||||
|
||||
/* Write next character(s) */
|
||||
|
||||
ch = *srcp;
|
||||
|
||||
#ifdef CONFIG_PDCURSES_CHTYPE_LONG
|
||||
/* Translate characters 0-127 via acs_map[], if they're flagged with
|
||||
* A_ALTCHARSET in the attribute portion of the chtype.
|
||||
*/
|
||||
|
||||
if (*srcp & A_ALTCHARSET && !(*srcp & 0xff80))
|
||||
{
|
||||
ch = acs_map[(*srcp) & 0x7f];
|
||||
}
|
||||
else
|
||||
{
|
||||
ch = *srcp & 0x7F;
|
||||
}
|
||||
#else
|
||||
ch = *srcp & 0x7F;
|
||||
#endif
|
||||
|
||||
buffer[0] = ch;
|
||||
|
||||
for (i = 1; i < sizeof(buffer) && c+i < len; i++)
|
||||
{
|
||||
/* Break if the attributes change */
|
||||
|
||||
if ((*(srcp + i) & A_ATTRIBUTES) != (*srcp & A_ATTRIBUTES))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PDCURSES_CHTYPE_LONG
|
||||
/* Translate characters 0-127 via acs_map[], if they're flagged with
|
||||
* A_ALTCHARSET in the attribute portion of the chtype.
|
||||
*/
|
||||
|
||||
if (*(srcp + i) & A_ALTCHARSET && !(*(srcp + i) & 0xff80))
|
||||
{
|
||||
ch = acs_map[(*(srcp+i)) & 0x7f];
|
||||
}
|
||||
else
|
||||
{
|
||||
ch = *(srcp + i) & 0x7F;
|
||||
}
|
||||
#else
|
||||
ch = *(srcp + i) & 0x7F;
|
||||
#endif
|
||||
|
||||
buffer[i] = ch;
|
||||
}
|
||||
|
||||
/* Update source pointer and write data */
|
||||
|
||||
srcp += i;
|
||||
c += i;
|
||||
write(termstate->out_fd, buffer, i);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_SYSTEM_TERMCURSES */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -665,6 +926,9 @@ static void PDC_putc(FAR struct pdc_fbstate_s *fbstate, int row, int col,
|
||||
|
||||
void PDC_gotoyx(int row, int col)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
int oldrow;
|
||||
@ -673,6 +937,14 @@ void PDC_gotoyx(int row, int col)
|
||||
|
||||
PDC_LOG(("PDC_gotoyx() - called: row %d col %d\n", row, col));
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
if (!graphic_screen)
|
||||
{
|
||||
PDC_gotoyx_term(SP, row, col);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
@ -710,6 +982,9 @@ void PDC_gotoyx(int row, int col)
|
||||
|
||||
void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
int nextx;
|
||||
@ -718,6 +993,16 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
|
||||
PDC_LOG(("PDC_transform_line() - called: lineno=%d x=%d len=%d\n",
|
||||
lineno, x, len));
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
if (!graphic_screen)
|
||||
{
|
||||
/* User terminal transformation routine */
|
||||
|
||||
PDC_transform_line_term(SP, lineno, x, len, srcp);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
|
@ -37,8 +37,77 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
#include <nuttx/termcurses.h>
|
||||
#endif
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include "pdcnuttx.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_get_columns_term
|
||||
*
|
||||
* Description:
|
||||
* Returns the size of the screen in columns. It's used in resize_term()
|
||||
* to set the new value of COLS. (Some existing implementations also call
|
||||
* it internally from PDC_scr_open(), but this is not required.)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
int PDC_get_columns_term(FAR SCREEN *sp)
|
||||
{
|
||||
FAR struct pdc_termscreen_s *termscreen = (FAR struct pdc_termscreen_s *)sp;
|
||||
FAR struct pdc_termstate_s *termstate = &termscreen->termstate;
|
||||
struct winsize winsz;
|
||||
int ret;
|
||||
|
||||
/* Call termcurses function to get window size */
|
||||
|
||||
ret =termcurses_getwinsize(termstate->tcurs, &winsz);
|
||||
if (ret == OK)
|
||||
{
|
||||
return winsz.ws_col;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_SYSTEM_TERMCURSES */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_get_rows
|
||||
*
|
||||
* Description:
|
||||
* Returns the size of the screen in rows. It's used in resize_term() to
|
||||
* set the new value of LINES. (Some existing implementations also call it
|
||||
* internally from PDC_scr_open(), but this is not required.)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
int PDC_get_rows_term(FAR SCREEN *sp)
|
||||
{
|
||||
FAR struct pdc_termscreen_s *termscreen = (FAR struct pdc_termscreen_s *)sp;
|
||||
FAR struct pdc_termstate_s *termstate = &termscreen->termstate;
|
||||
struct winsize winsz;
|
||||
int ret;
|
||||
|
||||
/* Call termcurses function to get window size */
|
||||
|
||||
ret =termcurses_getwinsize(termstate->tcurs, &winsz);
|
||||
if (ret == OK)
|
||||
{
|
||||
return winsz.ws_row;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_SYSTEM_TERMCURSES */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -55,9 +124,21 @@
|
||||
|
||||
int PDC_get_rows(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
if (!graphic_screen)
|
||||
{
|
||||
/* Call termcurses version of PDC_get_rows */
|
||||
|
||||
return PDC_get_rows_term(SP);
|
||||
}
|
||||
#endif
|
||||
|
||||
PDC_LOG(("PDC_get_rows() - called\n"));
|
||||
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
@ -78,11 +159,23 @@ int PDC_get_rows(void)
|
||||
|
||||
int PDC_get_columns(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
|
||||
PDC_LOG(("PDC_get_columns() - called\n"));
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
if (!graphic_screen)
|
||||
{
|
||||
/* Call termcurses version of PDC_get_cols */
|
||||
|
||||
return PDC_get_columns_term(SP);
|
||||
}
|
||||
#endif
|
||||
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
|
@ -37,7 +37,14 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/select.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "pdcnuttx.h"
|
||||
|
||||
@ -62,7 +69,9 @@
|
||||
* PDC_KEY_MODIFIER_NUMLOCK;
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
unsigned long pdc_key_modifiers;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@ -127,6 +136,9 @@ bool PDC_check_key(void)
|
||||
|
||||
#elif defined(CONFIG_PDCURSES_DJOYSTICK)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
djoy_buttonset_t newset;
|
||||
@ -144,6 +156,35 @@ bool PDC_check_key(void)
|
||||
return (fbstate->djlast ^ newset) != 0;
|
||||
}
|
||||
|
||||
#elif defined(CONFIG_PDCURSES_TERMINPUT)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
FAR struct pdc_termscreen_s *termscreen = (FAR struct pdc_termscreen_s *) SP;
|
||||
FAR struct pdc_termstate_s *termstate = &termscreen->termstate;
|
||||
int ret;
|
||||
fd_set rfds;
|
||||
struct timeval tv;
|
||||
|
||||
/* Watch stdin (fd 0) to see when it has input. */
|
||||
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(termstate->in_fd, &rfds);
|
||||
|
||||
/* Wait up to five seconds. */
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 0;
|
||||
|
||||
ret = select(1, &rfds, NULL, NULL, &tv);
|
||||
if (ret > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
@ -184,6 +225,9 @@ int PDC_get_key(void)
|
||||
|
||||
#elif defined(CONFIG_PDCURSES_DJOYSTICK)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
djoy_buttonset_t sample;
|
||||
@ -246,6 +290,25 @@ int PDC_get_key(void)
|
||||
return ERR;
|
||||
}
|
||||
|
||||
#elif defined(CONFIG_PDCURSES_TERMINPUT)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
FAR struct pdc_termscreen_s *termscreen = (FAR struct pdc_termscreen_s *)SP;
|
||||
FAR struct pdc_termstate_s *termstate = &termscreen->termstate;
|
||||
int specialkey;
|
||||
int keymodifiers;
|
||||
int keycode;
|
||||
|
||||
/* Call termcurses library routine to get keycode */
|
||||
|
||||
keycode = termcurses_getkeycode(termstate->tcurs, &specialkey, &keymodifiers);
|
||||
SP->key_code = specialkey;
|
||||
pdc_key_modifiers = keymodifiers;
|
||||
|
||||
return keycode;
|
||||
}
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
@ -263,13 +326,21 @@ int PDC_get_key(void)
|
||||
unsigned long PDC_get_input_fd(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_HAVE_INPUT
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
#ifdef CONFIG_PDCURSES_DJOYSTICK
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
#endif
|
||||
|
||||
PDC_LOG(("PDC_get_input_fd() - called\n"));
|
||||
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
if (!graphic_screen)
|
||||
{
|
||||
FAR struct pdc_termscreen_s *termscreen = (FAR struct pdc_termscreen_s *)SP;
|
||||
return termscreen->termstate.in_fd;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_PDCURSES_KEYBOARD)
|
||||
# warning Missing logic
|
||||
@ -279,9 +350,16 @@ unsigned long PDC_get_input_fd(void)
|
||||
# warning Missing logic
|
||||
return -1;
|
||||
|
||||
#else /* if defined(CONFIG_PDCURSES_DJOYSTICK) */
|
||||
#elif defined(CONFIG_PDCURSES_DJOYSTICK)
|
||||
PDC_LOG(("PDC_get_input_fd() - called\n"));
|
||||
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
return fbstate->djfd;
|
||||
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
#else
|
||||
PDC_LOG(("PDC_get_input_fd() - called: No input device\n"));
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* apps/graphics/nuttx/pdcnuttx.h
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2017, 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -51,6 +51,9 @@
|
||||
#include <nuttx/video/rgbcolors.h>
|
||||
|
||||
#include "curspriv.h"
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
#include <system/termcurses.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@ -289,6 +292,53 @@ struct pdc_fbscreen_s
|
||||
struct pdc_fbstate_s fbstate;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
|
||||
/* This structure provides the overall state of the termcurses device */
|
||||
|
||||
struct pdc_termstate_s
|
||||
{
|
||||
/* Terminal fd numbers (typcially 0 and 1) */
|
||||
|
||||
int out_fd;
|
||||
int in_fd;
|
||||
|
||||
/* Colors */
|
||||
|
||||
short fg_red;
|
||||
short fg_green;
|
||||
short fg_blue;
|
||||
short bg_red;
|
||||
short bg_green;
|
||||
short bg_blue;
|
||||
|
||||
#ifdef CONFIG_PDCURSES_CHTYPE_LONG
|
||||
long attrib;
|
||||
#else
|
||||
short attrib;
|
||||
#endif
|
||||
|
||||
struct pdc_colorpair_s colorpair[PDC_COLOR_PAIRS];
|
||||
#ifdef PDCURSES_MONOCHROME
|
||||
uint8_t greylevel[16];
|
||||
#else
|
||||
struct pdc_rgbcolor_s rgbcolor[16];
|
||||
#endif
|
||||
|
||||
FAR struct termcurses_s *tcurs;
|
||||
};
|
||||
|
||||
/* This structure contains the termstate structure and is a cast
|
||||
* compatible with type SCREEN.
|
||||
*/
|
||||
|
||||
struct pdc_termscreen_s
|
||||
{
|
||||
SCREEN screen;
|
||||
struct pdc_termstate_s termstate;
|
||||
};
|
||||
#endif /* CONFIG_SYSTEM_TERMCURSES */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
@ -45,9 +45,287 @@
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <graphics/curses.h>
|
||||
#include "pdcnuttx.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
bool graphic_screen = false;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_scr_free_term
|
||||
*
|
||||
* Description:
|
||||
* Frees the memory for SP allocated by PDC_scr_open(). Called by
|
||||
* delscreen().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
static void PDC_scr_free_term(FAR SCREEN *sp)
|
||||
{
|
||||
FAR struct pdc_termscreen_s *termscreen = (FAR struct pdc_termscreen_s *)sp;
|
||||
FAR struct pdc_termstate_s *termstate = &termscreen->termstate;
|
||||
|
||||
/* Deinitialize termcurses */
|
||||
|
||||
termcurses_deinitterm(termstate->tcurs);
|
||||
|
||||
/* Free the memory */
|
||||
|
||||
free(termscreen);
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
PDC_ctx_free();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_scr_open_term
|
||||
*
|
||||
* Description:
|
||||
* The platform-specific part of initscr(). It's actually called from
|
||||
* Xinitscr(); the arguments, if present, correspond to those used with
|
||||
* main(), and may be used to set the title of the terminal window, or for
|
||||
* other, platform-specific purposes. This opens a terminal type screen
|
||||
* backed by the NuttX termcurses interface.) PDC_scr_open() must allocate
|
||||
* memory for SP, and must initialize acs_map[] (unless it's preset) and
|
||||
* several members of SP, * including lines, cols, mouse_wait, orig_attr
|
||||
* (and if orig_attr is true, orig_fore and orig_back), mono, _restore and
|
||||
* _preserve.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
static int PDC_scr_open_term(int argc, char **argv)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
int ret;
|
||||
int i;
|
||||
struct winsize winsz;
|
||||
FAR struct pdc_termscreen_s *termscreen;
|
||||
FAR struct pdc_termstate_s *termstate;
|
||||
FAR char *term_type;
|
||||
|
||||
/* Determine the terminal type */
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
term_type = argv[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
term_type = NULL;
|
||||
}
|
||||
|
||||
/* Allocate the SP */
|
||||
|
||||
termscreen = (FAR struct pdc_termscreen_s *)
|
||||
zalloc(sizeof(struct pdc_termscreen_s));
|
||||
|
||||
if (termscreen == NULL)
|
||||
{
|
||||
PDC_LOG(("ERROR: Failed to allocate SP\n"));
|
||||
return ERR;
|
||||
}
|
||||
|
||||
termstate = &termscreen->termstate;
|
||||
|
||||
/* Try to initialize termcurses on stdout */
|
||||
|
||||
ret = termcurses_initterm(term_type, 0, 1, &termstate->tcurs);
|
||||
if (ret != OK)
|
||||
{
|
||||
PDC_LOG(("ERROR: Failed to initialize termcurses based SP\n"));
|
||||
free(termscreen);
|
||||
return ERR;
|
||||
}
|
||||
|
||||
/* Try to get the terminal size in rows / cols */
|
||||
|
||||
ret = termcurses_getwinsize(termstate->tcurs, &winsz);
|
||||
if (ret != OK)
|
||||
{
|
||||
PDC_LOG(("ERROR: Terminal termcurses driver doesn't support size reporting\n"));
|
||||
free(termscreen);
|
||||
return ERR;
|
||||
}
|
||||
|
||||
graphic_screen = false;
|
||||
SP = &termscreen->screen;
|
||||
SP->lines = winsz.ws_row;
|
||||
SP->cols = winsz.ws_col;
|
||||
termscreen->termstate.out_fd = 1;
|
||||
termscreen->termstate.in_fd = 0;
|
||||
termscreen->termstate.fg_red = 0xFFFE;
|
||||
termscreen->termstate.bg_red = 0xFFFE;
|
||||
termstate = &termscreen->termstate;
|
||||
|
||||
/* Setup initial RGB colors */
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
#ifdef PDCURSES_MONOCHROME
|
||||
uint8_t greylevel;
|
||||
|
||||
greylevel = (i & COLOR_RED) ? 0x40 : 0;
|
||||
greylevel += (i & COLOR_GREEN) ? 0x40 : 0;
|
||||
greylevel += (i & COLOR_BLUE) ? 0x40 : 0;
|
||||
|
||||
termstate->greylevel[i] = greylevel;
|
||||
termstate->greylevel[i+8] = greylevel | 0x3f;
|
||||
#else
|
||||
termstate->rgbcolor[i].red = (i & COLOR_RED) ? 0xc0 : 0;
|
||||
termstate->rgbcolor[i].green = (i & COLOR_GREEN) ? 0xc0 : 0;
|
||||
termstate->rgbcolor[i].blue = (i & COLOR_BLUE) ? 0xc0 : 0;
|
||||
|
||||
termstate->rgbcolor[i + 8].red = (i & COLOR_RED) ? 0xff : 0x40;
|
||||
termstate->rgbcolor[i + 8].green = (i & COLOR_GREEN) ? 0xff : 0x40;
|
||||
termstate->rgbcolor[i + 8].blue = (i & COLOR_BLUE) ? 0xff : 0x40;
|
||||
#endif
|
||||
}
|
||||
|
||||
COLORS = 16;
|
||||
|
||||
#ifdef CONFIG_PDCURSES_HAVE_INPUT
|
||||
ret = PDC_input_open(NULL);
|
||||
if (ret != OK)
|
||||
{
|
||||
/* Free the memory ... can't open input */
|
||||
|
||||
PDC_ctx_free();
|
||||
free(termscreen);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_SYSTEM_TERMCURSES */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_init_pair_term
|
||||
*
|
||||
* Description:
|
||||
* The core of init_pair(). This does all the work of that function, except
|
||||
* checking for values out of range. The values passed to this function
|
||||
* should be returned by a call to PDC_pair_content() with the same pair
|
||||
* number. PDC_transform_line() should use the specified colors when
|
||||
* rendering a chtype with the given pair number.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
static void PDC_init_pair_term(FAR SCREEN *sp, short pair, short fg, short bg)
|
||||
{
|
||||
FAR struct pdc_termscreen_s *termscreen = (FAR struct pdc_termscreen_s *)sp;
|
||||
|
||||
termscreen->termstate.colorpair[pair].fg = fg;
|
||||
termscreen->termstate.colorpair[pair].bg = bg;
|
||||
}
|
||||
#endif /* CONFIG_SYSTEM_TERMCURSES */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_init_color
|
||||
*
|
||||
* Description:
|
||||
* The core of init_color(). This does all the work of that function,
|
||||
* except checking for values out of range.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
int PDC_init_color_term(FAR SCREEN *sp, short color, short red, short green,
|
||||
short blue)
|
||||
{
|
||||
FAR struct pdc_termscreen_s *termscreen = (FAR struct pdc_termscreen_s *)sp;
|
||||
FAR struct pdc_termstate_s *termstate;
|
||||
|
||||
DEBUGASSERT(termscreen != NULL);
|
||||
termstate = &termscreen->termstate;
|
||||
|
||||
#ifdef PDCURSES_MONOCHROME
|
||||
greylevel = (DIVROUND(red * 255, 1000) +
|
||||
DIVROUND(green * 255, 1000) +
|
||||
DIVROUND(blue * 255, 1000)) / 3;
|
||||
termstate->greylevel[color] = (uint8_t)greylevel;
|
||||
#else
|
||||
termstate->rgbcolor[color].red = DIVROUND(red * 255, 1000);
|
||||
termstate->rgbcolor[color].green = DIVROUND(green * 255, 1000);
|
||||
termstate->rgbcolor[color].blue = DIVROUND(blue * 255, 1000);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif /* CONFIG_SYSTEM_TERMCURSES */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_color_content_term
|
||||
*
|
||||
* Description:
|
||||
* The core of color_content(). This does all the work of that function,
|
||||
* except checking for values out of range and null pointers.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
int PDC_color_content_term(FAR SCREEN *sp, short color,
|
||||
FAR short *red, FAR short *green, FAR short *blue)
|
||||
{
|
||||
FAR struct pdc_termscreen_s *termscreen = (FAR struct pdc_termscreen_s *)sp;
|
||||
FAR struct pdc_termstate_s *termstate;
|
||||
|
||||
DEBUGASSERT(termscreen != NULL);
|
||||
termstate = &termscreen->termstate;
|
||||
|
||||
#ifdef PDCURSES_MONOCHROME
|
||||
greylevel = DIVROUND(termstate->greylevel[color] * 1000, 255);
|
||||
*red = greylevel;
|
||||
*green = greylevel;
|
||||
*blue = greylevel;
|
||||
#else
|
||||
*red = DIVROUND(termstate->rgbcolor[color].red * 1000, 255);
|
||||
*green = DIVROUND(termstate->rgbcolor[color].green * 1000, 255);
|
||||
*blue = DIVROUND(termstate->rgbcolor[color].blue * 1000, 255);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif /* CONFIG_SYSTEM_TERMCURSES */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_pair_content_term
|
||||
*
|
||||
* Description:
|
||||
* The core of pair_content(). This does all the work of that function,
|
||||
* except checking for values out of range and null pointers.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
static int PDC_pair_content_term(FAR SCREEN *sp, short pair, short *fg, short *bg)
|
||||
{
|
||||
FAR struct pdc_termscreen_s *termscreen = (FAR struct pdc_termscreen_s *)sp;
|
||||
|
||||
*fg = termscreen->termstate.colorpair[pair].fg;
|
||||
*bg = termscreen->termstate.colorpair[pair].bg;
|
||||
return OK;
|
||||
}
|
||||
#endif /* CONFIG_SYSTEM_TERMCURSES */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -66,7 +344,19 @@
|
||||
|
||||
void PDC_scr_close(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("PDC_scr_close() - called\n"));
|
||||
|
||||
/* Ensure cursor is visible */
|
||||
|
||||
curs_set(1);
|
||||
attrset(COLOR_PAIR(0));
|
||||
|
||||
/* Delete the screen */
|
||||
|
||||
delscreen(SP);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -80,9 +370,21 @@ void PDC_scr_close(void)
|
||||
|
||||
void PDC_scr_free(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
if (!graphic_screen)
|
||||
{
|
||||
PDC_scr_free_term(SP);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
@ -92,6 +394,10 @@ void PDC_scr_free(void)
|
||||
#endif
|
||||
free(fbscreen);
|
||||
SP = NULL;
|
||||
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
PDC_ctx_free();
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -116,6 +422,12 @@ void PDC_scr_free(void)
|
||||
|
||||
int PDC_scr_open(int argc, char **argv)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
FAR char *env_display;
|
||||
#endif
|
||||
FAR struct pdc_fbscreen_s *fbscreen;
|
||||
FAR const struct nx_font_s *fontset;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
@ -126,6 +438,21 @@ int PDC_scr_open(int argc, char **argv)
|
||||
|
||||
PDC_LOG(("PDC_scr_open() - called\n"));
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
/* When termcurses is compiled in, we must allow opening terminal
|
||||
* type screens also. Check if the DISPLAY environment variable is
|
||||
* set to ":0" indicating we should open the graphic screen.
|
||||
*/
|
||||
|
||||
env_display = getenv("DISPLAY");
|
||||
if (!env_display || strcmp(env_display, ":0") != 0)
|
||||
{
|
||||
/* Perform terminal open operation */
|
||||
|
||||
return PDC_scr_open_term(argc, argv);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Allocate the global instance of SP */
|
||||
|
||||
fbscreen = (FAR struct pdc_fbscreen_s *)zalloc(sizeof(struct pdc_fbscreen_s));
|
||||
@ -137,6 +464,9 @@ int PDC_scr_open(int argc, char **argv)
|
||||
|
||||
SP = &fbscreen->screen;
|
||||
fbstate = &fbscreen->fbstate;
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
graphic_screen = true;
|
||||
#endif
|
||||
|
||||
/* Number of RGB colors/greyscale levels. This is the same as the
|
||||
* dimension of rgbcolor[] or greylevel[]).
|
||||
@ -456,11 +786,24 @@ void PDC_save_screen_mode(int i)
|
||||
|
||||
void PDC_init_pair(short pair, short fg, short bg)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
|
||||
PDC_LOG(("PDC_init_pair(). pair=%d, fg=%d, bg=%d\n", pair, fg, bg));
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
if (!graphic_screen)
|
||||
{
|
||||
/* Process as terminal mode screen */
|
||||
|
||||
PDC_init_pair_term(SP, pair, fg, bg);
|
||||
return;
|
||||
}
|
||||
#endif /* CONFIG_SYSTEM_TERMCURSES */
|
||||
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
@ -479,11 +822,23 @@ void PDC_init_pair(short pair, short fg, short bg)
|
||||
|
||||
int PDC_pair_content(short pair, short *fg, short *bg)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
|
||||
PDC_LOG(("PDC_pair_content(). pair=%d\n", pair));
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
if (!graphic_screen)
|
||||
{
|
||||
/* Process as terminal mode screen */
|
||||
|
||||
return PDC_pair_content_term(SP, pair, fg, bg);
|
||||
}
|
||||
#endif /* CONFIG_SYSTEM_TERMCURSES */
|
||||
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
@ -517,6 +872,9 @@ bool PDC_can_change_color(void)
|
||||
|
||||
int PDC_color_content(short color, short *red, short *green, short *blue)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
#ifdef PDCURSES_MONOCHROME
|
||||
@ -525,6 +883,15 @@ int PDC_color_content(short color, short *red, short *green, short *blue)
|
||||
|
||||
PDC_LOG(("PDC_init_color(). color=%d\n", color));
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
if (!graphic_screen)
|
||||
{
|
||||
/* Process as terminal mode screen */
|
||||
|
||||
return PDC_color_content_term(SP, color, red, green, blue);
|
||||
}
|
||||
#endif
|
||||
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
@ -553,6 +920,9 @@ int PDC_color_content(short color, short *red, short *green, short *blue)
|
||||
|
||||
int PDC_init_color(short color, short red, short green, short blue)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
#ifdef PDCURSES_MONOCHROME
|
||||
@ -562,6 +932,15 @@ int PDC_init_color(short color, short red, short green, short blue)
|
||||
PDC_LOG(("PDC_init_color(). color=%d, red=%d, green=%d, blue=%d\n",
|
||||
color, red, green, blue));
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
if (!graphic_screen)
|
||||
{
|
||||
/* Process as terminal mode screen */
|
||||
|
||||
return PDC_init_color_term(SP, color, red, green, blue);
|
||||
}
|
||||
#endif
|
||||
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* apps/graphics/nuttx/pdcsetsc.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2017, 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -40,6 +40,47 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "pdcnuttx.h"
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
#include <system/termcurses.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_curs_set_term
|
||||
*
|
||||
* Description:
|
||||
* Called from curs_set(). Changes the appearance of the cursor -- 0 turns
|
||||
* it off, 1 is normal (the terminal's default, if applicable, as
|
||||
* determined by SP->orig_cursor), and 2 is high visibility. The exact
|
||||
* appearance of these modes is not specified.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
static void PDC_curs_set_term(int visibility)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
FAR struct pdc_termscreen_s *termscreen = (FAR struct pdc_termscreen_s *)SP;
|
||||
FAR struct pdc_termstate_s *termstate = &termscreen->termstate;
|
||||
unsigned long attrib;
|
||||
|
||||
if (visibility)
|
||||
{
|
||||
attrib = TCURS_ATTRIB_CURS_SHOW;
|
||||
}
|
||||
else
|
||||
{
|
||||
attrib = TCURS_ATTRIB_CURS_HIDE;
|
||||
}
|
||||
|
||||
termcurses_setattribute(termstate->tcurs, attrib);
|
||||
}
|
||||
#endif /* CONFIG_SYSTEM_TERMCURSES */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -58,6 +99,9 @@
|
||||
|
||||
int PDC_curs_set(int visibility)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
|
||||
@ -79,6 +123,13 @@ int PDC_curs_set(int visibility)
|
||||
|
||||
SP->visibility = visibility;
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
if (!graphic_screen)
|
||||
{
|
||||
PDC_curs_set_term(visibility);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Redraw the cursor of the visiblity has change. For our purses 1 and 2
|
||||
* are currently treated the same.
|
||||
*/
|
||||
@ -122,6 +173,9 @@ void PDC_set_title(const char *title)
|
||||
|
||||
int PDC_set_blink(bool blinkon)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
COLORS = 16;
|
||||
return blinkon ? ERR : OK;
|
||||
}
|
||||
|
351
graphics/pdcurs34/nuttx/pdcthread.c
Normal file
351
graphics/pdcurs34/nuttx/pdcthread.c
Normal file
@ -0,0 +1,351 @@
|
||||
/****************************************************************************
|
||||
* apps/graphics/nuttx/pdcthread.c
|
||||
*
|
||||
* Copyright (C) 2018 Ken Pettit. All rights reserved.
|
||||
* Author: Ken Pettit <kpettit@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <semaphore.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include "pdcnuttx.h"
|
||||
#include "graphics/curses.h"
|
||||
|
||||
/* We are including a private header here because we want the scheduler
|
||||
* PIDHASH macros and don't want to copy them manually, just in case they
|
||||
* change in the future. Not sure this is a good design practice, but
|
||||
* at least it will track any changes to the PIDHASH macro.
|
||||
*/
|
||||
|
||||
#include "../sched/sched/sched.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static bool g_pdc_initialized = false;
|
||||
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD_HASH
|
||||
static FAR struct pdc_context_s *g_pdc_ctx_per_pid[CONFIG_MAX_TASKS];
|
||||
#else
|
||||
static sem_t g_pdc_thread_sem;
|
||||
|
||||
static FAR struct pdc_context_s *g_pdc_last_ctx = NULL;
|
||||
static FAR struct pdc_context_s *g_pdc_ctx_head = NULL;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_ctx_initialize
|
||||
*
|
||||
* Description:
|
||||
* This function initializes the variables used for managing PDC contexts.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void PDC_ctx_initialize(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD_HASH
|
||||
int x;
|
||||
|
||||
/* Initialize all task context pointers to NULL */
|
||||
|
||||
for (x = 0; x < CONFIG_MAX_TASKS; x++)
|
||||
{
|
||||
g_pdc_ctx_per_pid[x] = NULL;
|
||||
}
|
||||
|
||||
#else
|
||||
/* Initialize the semaphore */
|
||||
|
||||
sem_init(&g_pdc_thread_sem, 0, 1);
|
||||
#endif
|
||||
|
||||
g_pdc_initialized = true;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_ctx_new
|
||||
*
|
||||
* Description:
|
||||
* Allocate and initialize a new pdc_context_s structure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static FAR struct pdc_context_s *PDC_ctx_new(void)
|
||||
{
|
||||
FAR struct pdc_context_s *ctx;
|
||||
int pid;
|
||||
|
||||
/* Allocate a new structure */
|
||||
|
||||
ctx = (FAR struct pdc_context_s *)kmm_zalloc(sizeof(struct pdc_context_s));
|
||||
if (ctx == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Initialize the fields */
|
||||
|
||||
c_gindex = 1;
|
||||
TABSIZE = 8;
|
||||
COLOR_PAIRS = PDC_COLOR_PAIRS;
|
||||
ctx->panel_ctx = pdc_alloc_panel_ctx();
|
||||
ctx->term_ctx = pdc_alloc_term_ctx();
|
||||
|
||||
/* Get our PID */
|
||||
|
||||
pid = getpid();
|
||||
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD_HASH
|
||||
|
||||
pid = PIDHASH(pid);
|
||||
g_pdc_ctx_per_pid[pid] = ctx;
|
||||
|
||||
#else
|
||||
|
||||
/* Add this context to the linked list */
|
||||
|
||||
ctx->pid = pid;
|
||||
if (g_pdc_ctx_head == NULL)
|
||||
{
|
||||
/* We are the first in the list */
|
||||
|
||||
g_pdc_ctx_head = ctx;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Put ourselves as the first entry */
|
||||
|
||||
g_pdc_ctx_head->prev = ctx;
|
||||
ctx->next = g_pdc_ctx_head;
|
||||
g_pdc_ctx_head = ctx;
|
||||
}
|
||||
#endif /* CONFIG_PDCURSES_MULTITHREAD_HASH */
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_ctx
|
||||
*
|
||||
* Description:
|
||||
* Added pdcurses interface called from many functions to eliminate
|
||||
* global and static function variable usage. This function retuns a
|
||||
* task specific context / struct pointer to those variables instead,
|
||||
* allowing the pdcurses routines to be used by multiple tasks in a
|
||||
* FLAT build.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct pdc_context_s * PDC_ctx(void)
|
||||
{
|
||||
FAR struct pdc_context_s *ctx;
|
||||
int pid;
|
||||
|
||||
/* Ensure we are initialized */
|
||||
|
||||
if (!g_pdc_initialized)
|
||||
{
|
||||
PDC_ctx_initialize();
|
||||
}
|
||||
|
||||
/* Get our PID */
|
||||
|
||||
pid = getpid();
|
||||
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD_HASH
|
||||
|
||||
pid = PIDHASH(pid);
|
||||
ctx = g_pdc_ctx_per_pid[pid];
|
||||
|
||||
if (!ctx)
|
||||
{
|
||||
/* We must allocate and initialize a new context */
|
||||
|
||||
ctx = PDC_ctx_new();
|
||||
g_pdc_ctx_per_pid[pid] = ctx;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* Take the semaphore */
|
||||
|
||||
sem_wait(&g_pdc_thread_sem);
|
||||
|
||||
/* Test if the last context was ours */
|
||||
|
||||
if (g_pdc_last_ctx && g_pdc_last_ctx->pid == pid)
|
||||
{
|
||||
/* We found the context */
|
||||
|
||||
ctx = g_pdc_last_ctx;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Search the list */
|
||||
|
||||
ctx = g_pdc_ctx_head;
|
||||
while (ctx)
|
||||
{
|
||||
/* Test for match */
|
||||
|
||||
if (ctx->pid == pid)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
/* Advance to next item in list */
|
||||
|
||||
ctx = ctx->next;
|
||||
}
|
||||
|
||||
/* Test if context found */
|
||||
|
||||
if (ctx == NULL)
|
||||
{
|
||||
/* We must allocate and initialize a new context */
|
||||
|
||||
ctx = PDC_ctx_new();
|
||||
}
|
||||
}
|
||||
|
||||
/* Mark ourselves as the last context used and Post the semaphore */
|
||||
|
||||
g_pdc_last_ctx = ctx;
|
||||
sem_post(&g_pdc_thread_sem);
|
||||
#endif /* CONFIG_PDCURSES_MULTITHREAD_HASH */
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_ctx_free
|
||||
*
|
||||
* Description:
|
||||
* Free the PDC_ctx context associated with the current PID (and remove
|
||||
* it from the linked list).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void PDC_ctx_free(void)
|
||||
{
|
||||
FAR struct pdc_context_s *ctx;
|
||||
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD_HASH
|
||||
int pid;
|
||||
|
||||
/* Get a unique hash key from the PID */
|
||||
|
||||
pid = PIDHASH(getpid());
|
||||
ctx = g_pdc_ctx_per_pid[pid];
|
||||
|
||||
/* Free the context memory */
|
||||
|
||||
if (ctx != NULL)
|
||||
{
|
||||
free(ctx->panel_ctx);
|
||||
free(ctx->term_ctx);
|
||||
free(ctx);
|
||||
g_pdc_ctx_per_pid[pid] = NULL;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* Get a pointer to the context */
|
||||
|
||||
ctx = PDC_ctx();
|
||||
if (ctx == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Take the semaphore */
|
||||
|
||||
sem_wait(&g_pdc_thread_sem);
|
||||
|
||||
/* Remove ourselves from the linked list */
|
||||
|
||||
if (ctx == g_pdc_ctx_head)
|
||||
{
|
||||
/* Make our next the new head */
|
||||
|
||||
g_pdc_ctx_head = ctx->next;
|
||||
|
||||
/* Make the head prev pointer NULL */
|
||||
|
||||
if (g_pdc_ctx_head)
|
||||
{
|
||||
g_pdc_ctx_head->prev = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Make our next point to our prev */
|
||||
|
||||
if (ctx->next)
|
||||
{
|
||||
ctx->next->prev = ctx->prev;
|
||||
}
|
||||
|
||||
/* Make our prev point to our next */
|
||||
|
||||
if (ctx->prev)
|
||||
{
|
||||
ctx->prev->next = ctx->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* Release the semaphore */
|
||||
|
||||
sem_post(&g_pdc_thread_sem);
|
||||
|
||||
/* Free the memory */
|
||||
|
||||
free(ctx->panel_ctx);
|
||||
free(ctx->term_ctx);
|
||||
free(ctx);
|
||||
#endif /* CONFIG_PDCURSES_MULTITHREAD_HASH */
|
||||
}
|
@ -24,3 +24,11 @@ config PDCURSES_DEBUG
|
||||
config PDCURSES_PANEL_DEBUG
|
||||
bool "Enable special debug output for panels"
|
||||
default n
|
||||
|
||||
config PDCURSES_MULTITHREAD
|
||||
bool "Enable code for running pdcurses from multiple threads (removes global variables)."
|
||||
default n
|
||||
|
||||
config PDCURSES_MULTITHREAD_HASH
|
||||
bool "Use PID HASH lookup for thread specific pdcurses context data."
|
||||
default n
|
||||
|
@ -158,6 +158,9 @@ int waddch(WINDOW *win, const chtype ch)
|
||||
int x;
|
||||
int y;
|
||||
bool xlat;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("waddch() - called: win=%p ch=%x (text=%c attr=0x%x)\n",
|
||||
win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES));
|
||||
@ -356,6 +359,9 @@ int waddch(WINDOW *win, const chtype ch)
|
||||
|
||||
int addch(const chtype ch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("addch() - called: ch=%x\n", ch));
|
||||
|
||||
return waddch(stdscr, ch);
|
||||
@ -363,6 +369,9 @@ int addch(const chtype ch)
|
||||
|
||||
int mvaddch(int y, int x, const chtype ch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvaddch() - called: y=%d x=%d ch=%x\n", y, x, ch));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -387,6 +396,9 @@ int mvwaddch(WINDOW *win, int y, int x, const chtype ch)
|
||||
|
||||
int echochar(const chtype ch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("echochar() - called: ch=%x\n", ch));
|
||||
|
||||
return wechochar(stdscr, ch);
|
||||
@ -419,6 +431,9 @@ int waddrawch(WINDOW *win, chtype ch)
|
||||
|
||||
int addrawch(chtype ch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("addrawch() - called: ch=%x\n", ch));
|
||||
|
||||
return waddrawch(stdscr, ch);
|
||||
@ -426,6 +441,9 @@ int addrawch(chtype ch)
|
||||
|
||||
int mvaddrawch(int y, int x, chtype ch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvaddrawch() - called: y=%d x=%d ch=%d\n", y, x, ch));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -465,6 +483,9 @@ int add_wch(const cchar_t *wch)
|
||||
|
||||
int mvadd_wch(int y, int x, const cchar_t *wch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvaddch() - called: y=%d x=%d wch=%x\n", y, x, *wch));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
|
@ -164,6 +164,9 @@ int waddchnstr(WINDOW *win, const chtype *ch, int n)
|
||||
|
||||
int addchstr(const chtype *ch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("addchstr() - called\n"));
|
||||
|
||||
return waddchnstr(stdscr, ch, -1);
|
||||
@ -171,6 +174,9 @@ int addchstr(const chtype *ch)
|
||||
|
||||
int addchnstr(const chtype *ch, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("addchnstr() - called\n"));
|
||||
|
||||
return waddchnstr(stdscr, ch, n);
|
||||
@ -185,6 +191,9 @@ int waddchstr(WINDOW *win, const chtype *ch)
|
||||
|
||||
int mvaddchstr(int y, int x, const chtype *ch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvaddchstr() - called: y %d x %d\n", y, x));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -197,6 +206,9 @@ int mvaddchstr(int y, int x, const chtype *ch)
|
||||
|
||||
int mvaddchnstr(int y, int x, const chtype *ch, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvaddchnstr() - called: y %d x %d n %d\n", y, x, n));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -241,6 +253,9 @@ int wadd_wchnstr(WINDOW *win, const cchar_t *wch, int n)
|
||||
|
||||
int add_wchstr(const cchar_t *wch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("add_wchstr() - called\n"));
|
||||
|
||||
return wadd_wchnstr(stdscr, wch, -1);
|
||||
@ -248,6 +263,9 @@ int add_wchstr(const cchar_t *wch)
|
||||
|
||||
int add_wchnstr(const cchar_t *wch, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("add_wchnstr() - called\n"));
|
||||
|
||||
return wadd_wchnstr(stdscr, wch, n);
|
||||
@ -262,6 +280,9 @@ int wadd_wchstr(WINDOW *win, const cchar_t *wch)
|
||||
|
||||
int mvadd_wchstr(int y, int x, const cchar_t *wch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvadd_wchstr() - called: y %d x %d\n", y, x));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -274,6 +295,9 @@ int mvadd_wchstr(int y, int x, const cchar_t *wch)
|
||||
|
||||
int mvadd_wchnstr(int y, int x, const cchar_t *wch, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvadd_wchnstr() - called: y %d x %d n %d\n", y, x, n));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
|
@ -135,6 +135,9 @@ int waddnstr(WINDOW *win, const char *str, int n)
|
||||
|
||||
int addstr(const char *str)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("addstr() - called: string=\"%s\"\n", str));
|
||||
|
||||
return waddnstr(stdscr, str, -1);
|
||||
@ -142,6 +145,9 @@ int addstr(const char *str)
|
||||
|
||||
int addnstr(const char *str, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("addnstr() - called: string=\"%s\" n %d \n", str, n));
|
||||
|
||||
return waddnstr(stdscr, str, n);
|
||||
@ -156,6 +162,9 @@ int waddstr(WINDOW *win, const char *str)
|
||||
|
||||
int mvaddstr(int y, int x, const char *str)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvaddstr() - called: y %d x %d string=\"%s\"\n", y, x, str));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -168,6 +177,9 @@ int mvaddstr(int y, int x, const char *str)
|
||||
|
||||
int mvaddnstr(int y, int x, const char *str, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvaddnstr() - called: y %d x %d string=\"%s\" n %d \n",
|
||||
y, x, str, n));
|
||||
|
||||
@ -231,6 +243,9 @@ int waddnwstr(WINDOW *win, const wchar_t *wstr, int n)
|
||||
|
||||
int addwstr(const wchar_t *wstr)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("addwstr() - called\n"));
|
||||
|
||||
return waddnwstr(stdscr, wstr, -1);
|
||||
@ -238,6 +253,9 @@ int addwstr(const wchar_t *wstr)
|
||||
|
||||
int addnwstr(const wchar_t *wstr, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("addnwstr() - called\n"));
|
||||
|
||||
return waddnwstr(stdscr, wstr, n);
|
||||
@ -252,6 +270,9 @@ int waddwstr(WINDOW *win, const wchar_t *wstr)
|
||||
|
||||
int mvaddwstr(int y, int x, const wchar_t *wstr)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvaddstr() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -264,6 +285,9 @@ int mvaddwstr(int y, int x, const wchar_t *wstr)
|
||||
|
||||
int mvaddnwstr(int y, int x, const wchar_t *wstr, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvaddnstr() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
|
@ -154,6 +154,9 @@ int wattroff(WINDOW *win, chtype attrs)
|
||||
|
||||
int attroff(chtype attrs)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("attroff() - called\n"));
|
||||
|
||||
return wattroff(stdscr, attrs);
|
||||
@ -192,6 +195,9 @@ int wattron(WINDOW *win, chtype attrs)
|
||||
|
||||
int attron(chtype attrs)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("attron() - called\n"));
|
||||
|
||||
return wattron(stdscr, attrs);
|
||||
@ -213,6 +219,9 @@ int wattrset(WINDOW *win, chtype attrs)
|
||||
|
||||
int attrset(chtype attrs)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("attrset() - called\n"));
|
||||
|
||||
return wattrset(stdscr, attrs);
|
||||
@ -220,6 +229,9 @@ int attrset(chtype attrs)
|
||||
|
||||
int standend(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("standend() - called\n"));
|
||||
|
||||
return wattrset(stdscr, A_NORMAL);
|
||||
@ -227,6 +239,9 @@ int standend(void)
|
||||
|
||||
int standout(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("standout() - called\n"));
|
||||
|
||||
return wattrset(stdscr, A_STANDOUT);
|
||||
@ -267,6 +282,9 @@ int wcolor_set(WINDOW *win, short color_pair, void *opts)
|
||||
|
||||
int color_set(short color_pair, void *opts)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("color_set() - called\n"));
|
||||
|
||||
return wcolor_set(stdscr, color_pair, opts);
|
||||
@ -296,6 +314,9 @@ int wattr_get(WINDOW *win, attr_t *attrs, short *color_pair, void *opts)
|
||||
|
||||
int attr_get(attr_t *attrs, short *color_pair, void *opts)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("attr_get() - called\n"));
|
||||
|
||||
return wattr_get(stdscr, attrs, color_pair, opts);
|
||||
@ -310,6 +331,9 @@ int wattr_off(WINDOW *win, attr_t attrs, void *opts)
|
||||
|
||||
int attr_off(attr_t attrs, void *opts)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("attr_off() - called\n"));
|
||||
|
||||
return wattroff(stdscr, attrs);
|
||||
@ -324,6 +348,9 @@ int wattr_on(WINDOW *win, attr_t attrs, void *opts)
|
||||
|
||||
int attr_on(attr_t attrs, void *opts)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("attr_on() - called\n"));
|
||||
|
||||
return wattron(stdscr, attrs);
|
||||
@ -345,6 +372,9 @@ int wattr_set(WINDOW *win, attr_t attrs, short color_pair, void *opts)
|
||||
|
||||
int attr_set(attr_t attrs, short color_pair, void *opts)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("attr_get() - called\n"));
|
||||
|
||||
return wattr_set(stdscr, attrs, color_pair, opts);
|
||||
@ -394,6 +424,9 @@ int wchgat(WINDOW *win, int n, attr_t attr, short color, const void *opts)
|
||||
|
||||
int chgat(int n, attr_t attr, short color, const void *opts)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("chgat() - called\n"));
|
||||
|
||||
return wchgat(stdscr, n, attr, color, opts);
|
||||
@ -402,6 +435,9 @@ int chgat(int n, attr_t attr, short color, const void *opts)
|
||||
int mvchgat(int y, int x, int n, attr_t attr, short color, const void *opts)
|
||||
{
|
||||
PDC_LOG(("mvchgat() - called\n"));
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
{
|
||||
|
@ -72,6 +72,9 @@
|
||||
|
||||
int beep(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("beep() - called\n"));
|
||||
|
||||
if (SP->audible)
|
||||
@ -91,6 +94,9 @@ int flash(void)
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("flash() - called\n"));
|
||||
|
||||
|
@ -196,6 +196,9 @@ int wbkgd(WINDOW *win, chtype ch)
|
||||
|
||||
int bkgd(chtype ch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("bkgd() - called\n"));
|
||||
|
||||
return wbkgd(stdscr, ch);
|
||||
@ -218,6 +221,9 @@ void wbkgdset(WINDOW *win, chtype ch)
|
||||
|
||||
void bkgdset(chtype ch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("bkgdset() - called\n"));
|
||||
|
||||
wbkgdset(stdscr, ch);
|
||||
|
@ -237,6 +237,9 @@ int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs,
|
||||
int border(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl,
|
||||
chtype tr, chtype bl, chtype br)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("border() - called\n"));
|
||||
|
||||
return wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br);
|
||||
@ -290,6 +293,9 @@ int whline(WINDOW *win, chtype ch, int n)
|
||||
|
||||
int hline(chtype ch, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("hline() - called\n"));
|
||||
|
||||
return whline(stdscr, ch, n);
|
||||
@ -297,6 +303,9 @@ int hline(chtype ch, int n)
|
||||
|
||||
int mvhline(int y, int x, chtype ch, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvhline() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -358,6 +367,9 @@ int wvline(WINDOW *win, chtype ch, int n)
|
||||
|
||||
int vline(chtype ch, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("vline() - called\n"));
|
||||
|
||||
return wvline(stdscr, ch, n);
|
||||
@ -365,6 +377,9 @@ int vline(chtype ch, int n)
|
||||
|
||||
int mvvline(int y, int x, chtype ch, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvvline() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -403,6 +418,9 @@ int border_set(const cchar_t *ls, const cchar_t *rs, const cchar_t *ts,
|
||||
const cchar_t *bs, const cchar_t *tl, const cchar_t *tr,
|
||||
const cchar_t *bl, const cchar_t *br)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("border_set() - called\n"));
|
||||
|
||||
return wborder_set(stdscr, ls, rs, ts, bs, tl, tr, bl, br);
|
||||
@ -426,6 +444,9 @@ int whline_set(WINDOW *win, const cchar_t *wch, int n)
|
||||
|
||||
int hline_set(const cchar_t *wch, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("hline_set() - called\n"));
|
||||
|
||||
return whline_set(stdscr, wch, n);
|
||||
@ -433,6 +454,9 @@ int hline_set(const cchar_t *wch, int n)
|
||||
|
||||
int mvhline_set(int y, int x, const cchar_t *wch, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvhline_set() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -464,6 +488,9 @@ int wvline_set(WINDOW *win, const cchar_t *wch, int n)
|
||||
|
||||
int vline_set(const cchar_t *wch, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("vline_set() - called\n"));
|
||||
|
||||
return wvline_set(stdscr, wch, n);
|
||||
@ -471,6 +498,9 @@ int vline_set(const cchar_t *wch, int n)
|
||||
|
||||
int mvvline_set(int y, int x, const cchar_t *wch, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvvline_set() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
|
@ -128,6 +128,9 @@ int wclrtoeol(WINDOW *win)
|
||||
|
||||
int clrtoeol(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("clrtoeol() - called\n"));
|
||||
|
||||
return wclrtoeol(stdscr);
|
||||
@ -169,6 +172,9 @@ int wclrtobot(WINDOW *win)
|
||||
|
||||
int clrtobot(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("clrtobot() - called\n"));
|
||||
|
||||
return wclrtobot(stdscr);
|
||||
@ -188,6 +194,9 @@ int werase(WINDOW *win)
|
||||
|
||||
int erase(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("erase() - called\n"));
|
||||
|
||||
return werase(stdscr);
|
||||
@ -208,6 +217,9 @@ int wclear(WINDOW *win)
|
||||
|
||||
int clear(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("clear() - called\n"));
|
||||
|
||||
return wclear(stdscr);
|
||||
|
@ -135,10 +135,12 @@
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
int COLORS = 0;
|
||||
int COLOR_PAIRS = PDC_COLOR_PAIRS;
|
||||
|
||||
bool pdc_color_started = false;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@ -146,9 +148,11 @@ bool pdc_color_started = false;
|
||||
|
||||
/* pair_set[] tracks whether a pair has been set via init_pair() */
|
||||
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
static bool pair_set[PDC_COLOR_PAIRS];
|
||||
static bool default_colors = false;
|
||||
static short first_col = 0;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -156,6 +160,9 @@ static short first_col = 0;
|
||||
|
||||
int start_color(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("start_color() - called\n"));
|
||||
|
||||
if (SP->mono)
|
||||
@ -184,6 +191,10 @@ int start_color(void)
|
||||
|
||||
static void _normalize(short *fg, short *bg)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
if (*fg == -1)
|
||||
{
|
||||
*fg = SP->orig_attr ? SP->orig_fore : COLOR_WHITE;
|
||||
@ -197,6 +208,9 @@ static void _normalize(short *fg, short *bg)
|
||||
|
||||
int init_pair(short pair, short fg, short bg)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("init_pair() - called: pair %d fg %d bg %d\n", pair, fg, bg));
|
||||
|
||||
if (!pdc_color_started || pair < 1 || pair >= COLOR_PAIRS ||
|
||||
@ -230,6 +244,9 @@ int init_pair(short pair, short fg, short bg)
|
||||
|
||||
bool has_colors(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("has_colors() - called\n"));
|
||||
|
||||
return !(SP->mono);
|
||||
@ -237,6 +254,9 @@ bool has_colors(void)
|
||||
|
||||
int init_color(short color, short red, short green, short blue)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("init_color() - called\n"));
|
||||
|
||||
if (color < 0 || color >= COLORS || !PDC_can_change_color() ||
|
||||
@ -251,6 +271,9 @@ int init_color(short color, short red, short green, short blue)
|
||||
|
||||
int color_content(short color, short *red, short *green, short *blue)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("color_content() - called\n"));
|
||||
|
||||
if (color < 0 || color >= COLORS || !red || !green || !blue)
|
||||
@ -285,6 +308,9 @@ bool can_change_color(void)
|
||||
|
||||
int pair_content(short pair, short *fg, short *bg)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("pair_content() - called\n"));
|
||||
|
||||
if (pair < 0 || pair >= COLOR_PAIRS || !fg || !bg)
|
||||
@ -297,6 +323,9 @@ int pair_content(short pair, short *fg, short *bg)
|
||||
|
||||
int assume_default_colors(int f, int b)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("assume_default_colors() - called: f %d b %d\n", f, b));
|
||||
|
||||
if (f < -1 || f >= COLORS || b < -1 || b >= COLORS)
|
||||
@ -328,6 +357,9 @@ int assume_default_colors(int f, int b)
|
||||
|
||||
int use_default_colors(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("use_default_colors() - called\n"));
|
||||
|
||||
default_colors = true;
|
||||
@ -338,6 +370,9 @@ int use_default_colors(void)
|
||||
|
||||
int PDC_set_line_color(short color)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("PDC_set_line_color() - called: %d\n", color));
|
||||
|
||||
if (color < -1 || color >= COLORS)
|
||||
@ -354,6 +389,9 @@ void PDC_init_atrtab(void)
|
||||
int i;
|
||||
short fg;
|
||||
short bg;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
if (pdc_color_started && !default_colors)
|
||||
{
|
||||
|
@ -74,7 +74,9 @@
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
bool pdc_trace_on = false;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -83,6 +85,9 @@ bool pdc_trace_on = false;
|
||||
void PDC_debug(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
if (pdc_trace_on)
|
||||
{
|
||||
@ -94,6 +99,9 @@ void PDC_debug(const char *fmt, ...)
|
||||
|
||||
void traceon(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("traceon() - called\n"));
|
||||
|
||||
pdc_trace_on = true;
|
||||
@ -101,6 +109,9 @@ void traceon(void)
|
||||
|
||||
void traceoff(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("traceoff() - called\n"));
|
||||
|
||||
pdc_trace_on = false;
|
||||
|
@ -114,6 +114,9 @@ int wdelch(WINDOW *win)
|
||||
|
||||
int delch(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("delch() - called\n"));
|
||||
|
||||
return wdelch(stdscr);
|
||||
@ -121,6 +124,9 @@ int delch(void)
|
||||
|
||||
int mvdelch(int y, int x)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvdelch() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
|
@ -135,6 +135,9 @@ int wdeleteln(WINDOW *win)
|
||||
|
||||
int deleteln(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("deleteln() - called\n"));
|
||||
|
||||
return wdeleteln(stdscr);
|
||||
@ -142,6 +145,9 @@ int deleteln(void)
|
||||
|
||||
int mvdeleteln(int y, int x)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvdeleteln() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -202,6 +208,9 @@ int winsdelln(WINDOW *win, int n)
|
||||
|
||||
int insdelln(int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("insdelln() - called\n"));
|
||||
|
||||
return winsdelln(stdscr, n);
|
||||
@ -247,6 +256,9 @@ int winsertln(WINDOW *win)
|
||||
|
||||
int insertln(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("insertln() - called\n"));
|
||||
|
||||
return winsertln(stdscr);
|
||||
@ -254,6 +266,9 @@ int insertln(void)
|
||||
|
||||
int mvinsertln(int y, int x)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvinsertln() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
|
@ -122,17 +122,21 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
#define _INBUFSIZ 512 /* size of terminal input buffer */
|
||||
#define NUNGETCH 256 /* max # chars to ungetch() */
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
static int c_pindex = 0; /* putter index */
|
||||
static int c_gindex = 1; /* getter index */
|
||||
static int c_ungind = 0; /* ungetch() push index */
|
||||
static int c_ungch[NUNGETCH]; /* array of ungotten chars */
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@ -140,6 +144,9 @@ static int c_ungch[NUNGETCH]; /* array of ungotten chars */
|
||||
|
||||
static int _mouse_key(WINDOW *win)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
unsigned long mbe = SP->_trap_mbe;
|
||||
int key = KEY_MOUSE;
|
||||
int i;
|
||||
@ -216,8 +223,13 @@ static int _mouse_key(WINDOW *win)
|
||||
|
||||
int wgetch(WINDOW *win)
|
||||
{
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
static int buffer[_INBUFSIZ]; /* character buffer */
|
||||
#endif
|
||||
int key, waitcount;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("wgetch() - called\n"));
|
||||
|
||||
@ -271,7 +283,11 @@ int wgetch(WINDOW *win)
|
||||
|
||||
if ((!SP->raw_inp && !SP->cbreak) && (c_gindex < c_pindex))
|
||||
{
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
return buffer[c_gindex++];
|
||||
#else
|
||||
return c_buffer[c_gindex++];
|
||||
#endif
|
||||
}
|
||||
|
||||
/* prepare to buffer data */
|
||||
@ -370,20 +386,31 @@ int wgetch(WINDOW *win)
|
||||
}
|
||||
else if (c_pindex < _INBUFSIZ - 2)
|
||||
{
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
buffer[c_pindex++] = key;
|
||||
#else
|
||||
c_buffer[c_pindex++] = key;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* If we got a line */
|
||||
|
||||
if (key == '\n' || key == '\r')
|
||||
{
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
return buffer[c_gindex++];
|
||||
#else
|
||||
return c_buffer[c_gindex++];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int mvgetch(int y, int x)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvgetch() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -408,6 +435,9 @@ int mvwgetch(WINDOW *win, int y, int x)
|
||||
|
||||
int PDC_ungetch(int ch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("ungetch() - called\n"));
|
||||
|
||||
if (c_ungind >= NUNGETCH) /* Pushback stack full */
|
||||
@ -422,6 +452,9 @@ int PDC_ungetch(int ch)
|
||||
|
||||
int flushinp(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("flushinp() - called\n"));
|
||||
|
||||
PDC_flushinp();
|
||||
@ -435,6 +468,9 @@ int flushinp(void)
|
||||
|
||||
unsigned long PDC_get_key_modifiers(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("PDC_get_key_modifiers() - called\n"));
|
||||
|
||||
return pdc_key_modifiers;
|
||||
@ -442,6 +478,9 @@ unsigned long PDC_get_key_modifiers(void)
|
||||
|
||||
int PDC_save_key_modifiers(bool flag)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("PDC_save_key_modifiers() - called\n"));
|
||||
|
||||
SP->save_key_modifiers = flag;
|
||||
@ -450,6 +489,9 @@ int PDC_save_key_modifiers(bool flag)
|
||||
|
||||
int PDC_return_key_modifiers(bool flag)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("PDC_return_key_modifiers() - called\n"));
|
||||
|
||||
SP->return_key_modifiers = flag;
|
||||
@ -482,6 +524,9 @@ int wget_wch(WINDOW *win, wint_t *wch)
|
||||
|
||||
int get_wch(wint_t *wch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("get_wch() - called\n"));
|
||||
|
||||
return wget_wch(stdscr, wch);
|
||||
@ -489,6 +534,9 @@ int get_wch(wint_t *wch)
|
||||
|
||||
int mvget_wch(int y, int x, wint_t *wch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvget_wch() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
|
@ -138,6 +138,9 @@ int wgetnstr(WINDOW *win, char *str, int n)
|
||||
bool oldecho;
|
||||
bool oldcbreak;
|
||||
bool oldnodelay;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("wgetnstr() - called\n"));
|
||||
|
||||
@ -302,6 +305,9 @@ int wgetnstr(WINDOW *win, char *str, int n)
|
||||
|
||||
int getstr(char *str)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("getstr() - called\n"));
|
||||
|
||||
return wgetnstr(stdscr, str, MAXLINE);
|
||||
@ -316,6 +322,9 @@ int wgetstr(WINDOW *win, char *str)
|
||||
|
||||
int mvgetstr(int y, int x, char *str)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvgetstr() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -340,6 +349,9 @@ int mvwgetstr(WINDOW *win, int y, int x, char *str)
|
||||
|
||||
int getnstr(char *str, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("getnstr() - called\n"));
|
||||
|
||||
return wgetnstr(stdscr, str, n);
|
||||
@ -347,6 +359,9 @@ int getnstr(char *str, int n)
|
||||
|
||||
int mvgetnstr(int y, int x, char *str, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvgetnstr() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -382,6 +397,9 @@ int wgetn_wstr(WINDOW *win, wint_t *wstr, int n)
|
||||
bool oldecho;
|
||||
bool oldcbreak;
|
||||
bool oldnodelay;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("wgetn_wstr() - called\n"));
|
||||
|
||||
@ -543,6 +561,9 @@ int wgetn_wstr(WINDOW *win, wint_t *wstr, int n)
|
||||
|
||||
int get_wstr(wint_t *wstr)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("get_wstr() - called\n"));
|
||||
|
||||
return wgetn_wstr(stdscr, wstr, MAXLINE);
|
||||
@ -557,6 +578,9 @@ int wget_wstr(WINDOW *win, wint_t *wstr)
|
||||
|
||||
int mvget_wstr(int y, int x, wint_t *wstr)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvget_wstr() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -581,6 +605,9 @@ int mvwget_wstr(WINDOW *win, int y, int x, wint_t *wstr)
|
||||
|
||||
int getn_wstr(wint_t *wstr, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("getn_wstr() - called\n"));
|
||||
|
||||
return wgetn_wstr(stdscr, wstr, n);
|
||||
@ -588,6 +615,9 @@ int getn_wstr(wint_t *wstr, int n)
|
||||
|
||||
int mvgetn_wstr(int y, int x, wint_t *wstr, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvgetn_wstr() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
|
@ -169,6 +169,9 @@ int getmaxx(WINDOW *win)
|
||||
|
||||
int setsyx(int y, int x)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("setsyx() - called\n"));
|
||||
|
||||
if (y == -1 && x == -1)
|
||||
|
@ -97,6 +97,9 @@ chtype winch(WINDOW *win)
|
||||
|
||||
chtype inch(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("inch() - called\n"));
|
||||
|
||||
return winch(stdscr);
|
||||
@ -104,6 +107,9 @@ chtype inch(void)
|
||||
|
||||
chtype mvinch(int y, int x)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvinch() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -143,6 +149,9 @@ int win_wch(WINDOW *win, cchar_t *wcval)
|
||||
|
||||
int in_wch(cchar_t *wcval)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("in_wch() - called\n"));
|
||||
|
||||
return win_wch(stdscr, wcval);
|
||||
|
@ -127,6 +127,9 @@ int winchnstr(WINDOW *win, chtype *ch, int n)
|
||||
|
||||
int inchstr(chtype *ch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("inchstr() - called\n"));
|
||||
|
||||
return winchnstr(stdscr, ch, stdscr->_maxx - stdscr->_curx);
|
||||
@ -141,6 +144,9 @@ int winchstr(WINDOW *win, chtype *ch)
|
||||
|
||||
int mvinchstr(int y, int x, chtype *ch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvinchstr() - called: y %d x %d\n", y, x));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -165,6 +171,9 @@ int mvwinchstr(WINDOW *win, int y, int x, chtype *ch)
|
||||
|
||||
int inchnstr(chtype *ch, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("inchnstr() - called\n"));
|
||||
|
||||
return winchnstr(stdscr, ch, n);
|
||||
@ -172,6 +181,9 @@ int inchnstr(chtype *ch, int n)
|
||||
|
||||
int mvinchnstr(int y, int x, chtype *ch, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvinchnstr() - called: y %d x %d n %d\n", y, x, n));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -218,6 +230,9 @@ int win_wchstr(WINDOW *win, cchar_t *wch)
|
||||
|
||||
int mvin_wchstr(int y, int x, cchar_t *wch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvin_wchstr() - called: y %d x %d\n", y, x));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -242,6 +257,9 @@ int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wch)
|
||||
|
||||
int in_wchnstr(cchar_t *wch, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("in_wchnstr() - called\n"));
|
||||
|
||||
return win_wchnstr(stdscr, wch, n);
|
||||
@ -249,6 +267,9 @@ int in_wchnstr(cchar_t *wch, int n)
|
||||
|
||||
int mvin_wchnstr(int y, int x, cchar_t *wch, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvin_wchnstr() - called: y %d x %d n %d\n", y, x, n));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Public Domain Curses
|
||||
* RCSID("$Id: initscr.c,v 1.114 2008/07/13 16:08:18 wmcbrine Exp $")
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2017, 2019 Gregory Nutt. All rights reserved.
|
||||
* Adapted by: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Adapted from the original public domain pdcurses by Gregory Nutt and
|
||||
@ -131,10 +131,12 @@
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
char ttytype[128];
|
||||
|
||||
const char *_curses_notice = "PDCurses 3.4 - Public Domain 2008";
|
||||
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
|
||||
char ttytype[128];
|
||||
|
||||
SCREEN *SP = (SCREEN *) NULL; /* curses variables */
|
||||
WINDOW *curscr = (WINDOW *) NULL; /* the current screen image */
|
||||
WINDOW *stdscr = (WINDOW *) NULL; /* the default screen window */
|
||||
@ -149,6 +151,8 @@ MOUSE_STATUS Mouse_status, pdc_mouse_status;
|
||||
extern RIPPEDOFFLINE linesripped[5];
|
||||
extern char linesrippedoff;
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -156,6 +160,9 @@ extern char linesrippedoff;
|
||||
WINDOW *Xinitscr(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("Xinitscr() - called\n"));
|
||||
|
||||
@ -167,7 +174,7 @@ WINDOW *Xinitscr(int argc, char *argv[])
|
||||
if (PDC_scr_open(argc, argv) == ERR)
|
||||
{
|
||||
fprintf(stderr, "initscr(): Unable to create SP\n");
|
||||
exit(8);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SP->autocr = true; /* cr -> lf by default */
|
||||
@ -181,7 +188,7 @@ WINDOW *Xinitscr(int argc, char *argv[])
|
||||
SP->resized = false;
|
||||
SP->_trap_mbe = 0L;
|
||||
SP->_map_mbe_to_key = 0L;
|
||||
SP->linesrippedoff = 0;
|
||||
SP->linesrippedoffcnt = 0;
|
||||
SP->linesrippedoffontop = 0;
|
||||
SP->delaytenths = 0;
|
||||
SP->line_color = -1;
|
||||
@ -230,7 +237,7 @@ WINDOW *Xinitscr(int argc, char *argv[])
|
||||
SP->linesrippedoffontop++, 0), COLS);
|
||||
}
|
||||
|
||||
SP->linesrippedoff++;
|
||||
SP->linesrippedoffcnt++;
|
||||
LINES--;
|
||||
}
|
||||
|
||||
@ -284,6 +291,9 @@ WINDOW *initscr(void)
|
||||
|
||||
int endwin(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("endwin() - called\n"));
|
||||
|
||||
/* Allow temporary exit from curses using endwin() */
|
||||
@ -298,6 +308,9 @@ int endwin(void)
|
||||
|
||||
bool isendwin(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("isendwin() - called\n"));
|
||||
|
||||
return SP ? !(SP->alive) : false;
|
||||
@ -305,6 +318,9 @@ bool isendwin(void)
|
||||
|
||||
SCREEN *newterm(const char *type, FILE *outfd, FILE *infd)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("newterm() - called\n"));
|
||||
|
||||
return Xinitscr(0, NULL) ? SP : NULL;
|
||||
@ -312,6 +328,9 @@ SCREEN *newterm(const char *type, FILE *outfd, FILE *infd)
|
||||
|
||||
SCREEN *set_term(SCREEN *new)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("set_term() - called\n"));
|
||||
|
||||
/* We only support one screen */
|
||||
@ -321,6 +340,9 @@ SCREEN *set_term(SCREEN *new)
|
||||
|
||||
void delscreen(SCREEN *sp)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("delscreen() - called\n"));
|
||||
|
||||
if (sp != SP)
|
||||
@ -342,10 +364,20 @@ void delscreen(SCREEN *sp)
|
||||
PDC_scr_free(); /* Free SP and pdc_atrtab */
|
||||
|
||||
SP = (SCREEN *)NULL;
|
||||
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
|
||||
/* Free the context */
|
||||
|
||||
PDC_ctx_free();
|
||||
#endif
|
||||
}
|
||||
|
||||
int resize_term(int nlines, int ncols)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("resize_term() - called: nlines %d\n", nlines));
|
||||
|
||||
if (!stdscr || PDC_resize_screen(nlines, ncols) == ERR)
|
||||
@ -354,7 +386,7 @@ int resize_term(int nlines, int ncols)
|
||||
}
|
||||
|
||||
SP->lines = PDC_get_rows();
|
||||
LINES = SP->lines - SP->linesrippedoff - SP->slklines;
|
||||
LINES = SP->lines - SP->linesrippedoffcnt - SP->slklines;
|
||||
SP->cols = COLS = PDC_get_columns();
|
||||
|
||||
if (wresize(curscr, SP->lines, SP->cols) == ERR ||
|
||||
@ -387,6 +419,9 @@ int resize_term(int nlines, int ncols)
|
||||
|
||||
bool is_termresized(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("is_termresized() - called\n"));
|
||||
|
||||
return SP->resized;
|
||||
|
@ -157,6 +157,9 @@
|
||||
|
||||
int cbreak(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("cbreak() - called\n"));
|
||||
|
||||
SP->cbreak = true;
|
||||
@ -165,6 +168,9 @@ int cbreak(void)
|
||||
|
||||
int nocbreak(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("nocbreak() - called\n"));
|
||||
|
||||
SP->cbreak = false;
|
||||
@ -175,6 +181,9 @@ int nocbreak(void)
|
||||
|
||||
int echo(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("echo() - called\n"));
|
||||
|
||||
SP->echo = true;
|
||||
@ -183,6 +192,9 @@ int echo(void)
|
||||
|
||||
int noecho(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("noecho() - called\n"));
|
||||
|
||||
SP->echo = false;
|
||||
@ -191,6 +203,9 @@ int noecho(void)
|
||||
|
||||
int halfdelay(int tenths)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("halfdelay() - called\n"));
|
||||
|
||||
if (tenths < 1 || tenths > 255)
|
||||
@ -224,6 +239,9 @@ int keypad(WINDOW *win, bool bf)
|
||||
|
||||
int meta(WINDOW *win, bool bf)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("meta() - called\n"));
|
||||
|
||||
SP->raw_inp = bf;
|
||||
@ -232,6 +250,9 @@ int meta(WINDOW *win, bool bf)
|
||||
|
||||
int nl(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("nl() - called\n"));
|
||||
|
||||
SP->autocr = true;
|
||||
@ -240,6 +261,9 @@ int nl(void)
|
||||
|
||||
int nonl(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("nonl() - called\n"));
|
||||
|
||||
SP->autocr = false;
|
||||
@ -268,6 +292,9 @@ int notimeout(WINDOW *win, bool flag)
|
||||
|
||||
int raw(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("raw() - called\n"));
|
||||
|
||||
PDC_set_keyboard_binary(true);
|
||||
@ -277,6 +304,9 @@ int raw(void)
|
||||
|
||||
int noraw(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("noraw() - called\n"));
|
||||
|
||||
PDC_set_keyboard_binary(false);
|
||||
@ -337,6 +367,9 @@ void wtimeout(WINDOW *win, int delay)
|
||||
|
||||
void timeout(int delay)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("timeout() - called\n"));
|
||||
|
||||
wtimeout(stdscr, delay);
|
||||
|
@ -107,6 +107,9 @@ int winsch(WINDOW *win, chtype ch)
|
||||
bool xlat;
|
||||
int x;
|
||||
int y;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("winsch() - called: win=%p ch=%x (text=%c attr=0x%x)\n",
|
||||
win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES));
|
||||
@ -227,6 +230,9 @@ int winsch(WINDOW *win, chtype ch)
|
||||
|
||||
int insch(chtype ch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("insch() - called\n"));
|
||||
|
||||
return winsch(stdscr, ch);
|
||||
@ -234,6 +240,9 @@ int insch(chtype ch)
|
||||
|
||||
int mvinsch(int y, int x, chtype ch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvinsch() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -272,6 +281,9 @@ int winsrawch(WINDOW *win, chtype ch)
|
||||
|
||||
int insrawch(chtype ch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("insrawch() - called\n"));
|
||||
|
||||
return winsrawch(stdscr, ch);
|
||||
@ -279,6 +291,9 @@ int insrawch(chtype ch)
|
||||
|
||||
int mvinsrawch(int y, int x, chtype ch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvinsrawch() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -311,6 +326,9 @@ int wins_wch(WINDOW *win, const cchar_t *wch)
|
||||
|
||||
int ins_wch(const cchar_t *wch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("ins_wch() - called\n"));
|
||||
|
||||
return wins_wch(stdscr, wch);
|
||||
@ -318,6 +336,9 @@ int ins_wch(const cchar_t *wch)
|
||||
|
||||
int mvins_wch(int y, int x, const cchar_t *wch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvins_wch() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
|
@ -172,6 +172,9 @@ int winsnstr(WINDOW *win, const char *str, int n)
|
||||
|
||||
int insstr(const char *str)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("insstr() - called: string=\"%s\"\n", str));
|
||||
|
||||
return winsnstr(stdscr, str, -1);
|
||||
@ -186,6 +189,9 @@ int winsstr(WINDOW *win, const char *str)
|
||||
|
||||
int mvinsstr(int y, int x, const char *str)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvinsstr() - called: y %d x %d string=\"%s\"\n", y, x, str));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -210,6 +216,9 @@ int mvwinsstr(WINDOW *win, int y, int x, const char *str)
|
||||
|
||||
int insnstr(const char *str, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("insnstr() - called: string=\"%s\" n %d \n", str, n));
|
||||
|
||||
return winsnstr(stdscr, str, n);
|
||||
@ -217,6 +226,9 @@ int insnstr(const char *str, int n)
|
||||
|
||||
int mvinsnstr(int y, int x, const char *str, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvinsnstr() - called: y %d x %d string=\"%s\" n %d \n",
|
||||
y, x, str, n));
|
||||
|
||||
@ -277,6 +289,9 @@ int wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
|
||||
|
||||
int ins_wstr(const wchar_t *wstr)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("ins_wstr() - called\n"));
|
||||
|
||||
return wins_nwstr(stdscr, wstr, -1);
|
||||
@ -291,6 +306,9 @@ int wins_wstr(WINDOW *win, const wchar_t *wstr)
|
||||
|
||||
int mvins_wstr(int y, int x, const wchar_t *wstr)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvins_wstr() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -315,6 +333,9 @@ int mvwins_wstr(WINDOW *win, int y, int x, const wchar_t *wstr)
|
||||
|
||||
int ins_nwstr(const wchar_t *wstr, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("ins_nwstr() - called\n"));
|
||||
|
||||
return wins_nwstr(stdscr, wstr, n);
|
||||
@ -322,6 +343,9 @@ int ins_nwstr(const wchar_t *wstr, int n)
|
||||
|
||||
int mvins_nwstr(int y, int x, const wchar_t *wstr, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvinsnstr() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
|
@ -147,6 +147,9 @@ int winnstr(WINDOW *win, char *str, int n)
|
||||
|
||||
int instr(char *str)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("instr() - called: string=\"%s\"\n", str));
|
||||
|
||||
return (ERR == winnstr(stdscr, str, stdscr->_maxx)) ? ERR : OK;
|
||||
@ -161,6 +164,9 @@ int winstr(WINDOW *win, char *str)
|
||||
|
||||
int mvinstr(int y, int x, char *str)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvinstr() - called: y %d x %d \n", y, x));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -185,6 +191,9 @@ int mvwinstr(WINDOW *win, int y, int x, char *str)
|
||||
|
||||
int innstr(char *str, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("innstr() - called: n %d \n", n));
|
||||
|
||||
return winnstr(stdscr, str, n);
|
||||
@ -192,6 +201,9 @@ int innstr(char *str, int n)
|
||||
|
||||
int mvinnstr(int y, int x, char *str, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvinnstr() - called: y %d x %d n %d \n", y, x, n));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -245,6 +257,9 @@ int winnwstr(WINDOW *win, wchar_t *wstr, int n)
|
||||
|
||||
int inwstr(wchar_t *wstr)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("inwstr() - called\n"));
|
||||
|
||||
return (ERR == winnwstr(stdscr, wstr, stdscr->_maxx)) ? ERR : OK;
|
||||
@ -259,6 +274,9 @@ int winwstr(WINDOW *win, wchar_t *wstr)
|
||||
|
||||
int mvinwstr(int y, int x, wchar_t *wstr)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvinwstr() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
@ -283,6 +301,9 @@ int mvwinwstr(WINDOW *win, int y, int x, wchar_t *wstr)
|
||||
|
||||
int innwstr(wchar_t *wstr, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("innwstr() - called\n"));
|
||||
|
||||
return winnwstr(stdscr, wstr, n);
|
||||
@ -290,6 +311,9 @@ int innwstr(wchar_t *wstr, int n)
|
||||
|
||||
int mvinnwstr(int y, int x, wchar_t *wstr, int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvinnstr() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
|
@ -135,18 +135,18 @@ enum
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
RIPPEDOFFLINE linesripped[5];
|
||||
char linesrippedoff = 0;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static struct cttyset
|
||||
{
|
||||
bool been_set;
|
||||
SCREEN saved;
|
||||
} ctty[3];
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
static struct cttyset ctty[3];
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@ -154,6 +154,9 @@ static struct cttyset
|
||||
|
||||
static void _save_mode(int i)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
ctty[i].been_set = true;
|
||||
|
||||
memcpy(&(ctty[i].saved), SP, sizeof(SCREEN));
|
||||
@ -163,6 +166,9 @@ static void _save_mode(int i)
|
||||
|
||||
static int _restore_mode(int i)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
if (ctty[i].been_set == true)
|
||||
{
|
||||
memcpy(SP, &(ctty[i].saved), sizeof(SCREEN));
|
||||
@ -238,6 +244,9 @@ int savetty(void)
|
||||
int curs_set(int visibility)
|
||||
{
|
||||
int ret_vis;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("curs_set() - called: visibility=%d\n", visibility));
|
||||
|
||||
@ -274,6 +283,9 @@ int napms(int ms)
|
||||
|
||||
int ripoffline(int line, int (*init) (WINDOW *, int))
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("ripoffline() - called: line=%d\n", line));
|
||||
|
||||
if (linesrippedoff < 5 && line && init)
|
||||
|
@ -192,7 +192,9 @@
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
static bool ungot = false;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -200,6 +202,9 @@ static bool ungot = false;
|
||||
|
||||
int mouse_set(unsigned long mbe)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mouse_set() - called: event %x\n", mbe));
|
||||
|
||||
SP->_trap_mbe = mbe;
|
||||
@ -208,6 +213,9 @@ int mouse_set(unsigned long mbe)
|
||||
|
||||
int mouse_on(unsigned long mbe)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mouse_on() - called: event %x\n", mbe));
|
||||
|
||||
SP->_trap_mbe |= mbe;
|
||||
@ -216,6 +224,9 @@ int mouse_on(unsigned long mbe)
|
||||
|
||||
int mouse_off(unsigned long mbe)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mouse_off() - called: event %x\n", mbe));
|
||||
|
||||
SP->_trap_mbe &= ~mbe;
|
||||
@ -224,6 +235,9 @@ int mouse_off(unsigned long mbe)
|
||||
|
||||
int map_button(unsigned long button)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("map_button() - called: button %x\n", button));
|
||||
|
||||
/* This does nothing at the moment */
|
||||
@ -234,6 +248,9 @@ int map_button(unsigned long button)
|
||||
|
||||
int request_mouse_pos(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("request_mouse_pos() - called\n"));
|
||||
|
||||
Mouse_status = pdc_mouse_status;
|
||||
@ -242,6 +259,9 @@ int request_mouse_pos(void)
|
||||
|
||||
void wmouse_position(WINDOW *win, int *y, int *x)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("wmouse_position() - called\n"));
|
||||
|
||||
if (win && wenclose(win, MOUSE_Y_POS, MOUSE_X_POS))
|
||||
@ -272,6 +292,9 @@ void wmouse_position(WINDOW *win, int *y, int *x)
|
||||
|
||||
unsigned long getmouse(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("getmouse() - called\n"));
|
||||
|
||||
return SP->_trap_mbe;
|
||||
@ -279,6 +302,9 @@ unsigned long getmouse(void)
|
||||
|
||||
unsigned long getbmap(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("getbmap() - called\n"));
|
||||
|
||||
return SP->_map_mbe_to_key;
|
||||
@ -288,6 +314,9 @@ unsigned long getbmap(void)
|
||||
|
||||
int mouseinterval(int wait)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
int old_wait;
|
||||
|
||||
PDC_LOG(("mouseinterval() - called: %d\n", wait));
|
||||
@ -355,6 +384,9 @@ bool wmouse_trafo(const WINDOW *win, int *y, int *x, bool to_screen)
|
||||
|
||||
bool mouse_trafo(int *y, int *x, bool to_screen)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mouse_trafo() - called\n"));
|
||||
|
||||
return wmouse_trafo(stdscr, y, x, to_screen);
|
||||
@ -362,6 +394,9 @@ bool mouse_trafo(int *y, int *x, bool to_screen)
|
||||
|
||||
mmask_t mousemask(mmask_t mask, mmask_t * oldmask)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mousemask() - called\n"));
|
||||
|
||||
if (oldmask)
|
||||
@ -380,6 +415,9 @@ mmask_t mousemask(mmask_t mask, mmask_t * oldmask)
|
||||
int nc_getmouse(MEVENT * event)
|
||||
{
|
||||
int i;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
mmask_t bstate = 0;
|
||||
|
||||
PDC_LOG(("nc_getmouse() - called\n"));
|
||||
@ -461,6 +499,9 @@ int ungetmouse(MEVENT * event)
|
||||
{
|
||||
int i;
|
||||
unsigned long bstate;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("ungetmouse() - called\n"));
|
||||
|
||||
|
@ -70,6 +70,9 @@
|
||||
|
||||
int move(int y, int x)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("move() - called: y=%d x=%d\n", y, x));
|
||||
|
||||
if (!stdscr || x < 0 || y < 0 || x >= stdscr->_maxx || y >= stdscr->_maxy)
|
||||
|
@ -157,6 +157,9 @@ int leaveok(WINDOW *win, bool bf)
|
||||
|
||||
int setscrreg(int top, int bottom)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("setscrreg() - called: top %d bottom %d\n", top, bottom));
|
||||
|
||||
return wsetscrreg(stdscr, top, bottom);
|
||||
@ -195,6 +198,9 @@ int scrollok(WINDOW *win, bool bf)
|
||||
|
||||
int raw_output(bool bf)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("raw_output() - called\n"));
|
||||
|
||||
SP->raw_out = bf;
|
||||
|
@ -177,7 +177,7 @@ static int _copy_win(const WINDOW *src_w, WINDOW *dst_w, int src_tr,
|
||||
int overlay(const WINDOW *src_w, WINDOW *dst_w)
|
||||
{
|
||||
int first_line;
|
||||
int first_col;
|
||||
int first_c;
|
||||
int last_line;
|
||||
int last_col;
|
||||
int src_start_x;
|
||||
@ -194,7 +194,7 @@ int overlay(const WINDOW *src_w, WINDOW *dst_w)
|
||||
return ERR;
|
||||
}
|
||||
|
||||
first_col = max(dst_w->_begx, src_w->_begx);
|
||||
first_c = max(dst_w->_begx, src_w->_begx);
|
||||
first_line = max(dst_w->_begy, src_w->_begy);
|
||||
|
||||
last_col = min(src_w->_begx + src_w->_maxx, dst_w->_begx + dst_w->_maxx);
|
||||
@ -204,14 +204,14 @@ int overlay(const WINDOW *src_w, WINDOW *dst_w)
|
||||
|
||||
/* If no overlapping region, do nothing */
|
||||
|
||||
if ((last_col < first_col) || (last_line < first_line))
|
||||
if ((last_col < first_c) || (last_line < first_line))
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* Size of overlapping region */
|
||||
|
||||
xdiff = last_col - first_col;
|
||||
xdiff = last_col - first_c;
|
||||
ydiff = last_line - first_line;
|
||||
|
||||
if (src_w->_begx <= dst_w->_begx)
|
||||
@ -244,7 +244,7 @@ int overlay(const WINDOW *src_w, WINDOW *dst_w)
|
||||
int overwrite(const WINDOW *src_w, WINDOW *dst_w)
|
||||
{
|
||||
int first_line;
|
||||
int first_col;
|
||||
int first_c;
|
||||
int last_line;
|
||||
int last_col;
|
||||
int src_start_x;
|
||||
@ -261,7 +261,7 @@ int overwrite(const WINDOW *src_w, WINDOW *dst_w)
|
||||
return ERR;
|
||||
}
|
||||
|
||||
first_col = max(dst_w->_begx, src_w->_begx);
|
||||
first_c = max(dst_w->_begx, src_w->_begx);
|
||||
first_line = max(dst_w->_begy, src_w->_begy);
|
||||
|
||||
last_col = min(src_w->_begx + src_w->_maxx, dst_w->_begx + dst_w->_maxx);
|
||||
@ -271,14 +271,14 @@ int overwrite(const WINDOW *src_w, WINDOW *dst_w)
|
||||
|
||||
/* If no overlapping region, do nothing */
|
||||
|
||||
if ((last_col < first_col) || (last_line < first_line))
|
||||
if ((last_col < first_c) || (last_line < first_line))
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* Size of overlapping region */
|
||||
|
||||
xdiff = last_col - first_col;
|
||||
xdiff = last_col - first_c;
|
||||
ydiff = last_line - first_line;
|
||||
|
||||
if (src_w->_begx <= dst_w->_begx)
|
||||
@ -319,6 +319,9 @@ int copywin(const WINDOW *src_w, WINDOW *dst_w, int src_tr, int src_tc,
|
||||
int dst_cols;
|
||||
int min_rows;
|
||||
int min_cols;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("copywin() - called\n"));
|
||||
|
||||
|
@ -111,12 +111,14 @@
|
||||
|
||||
/* Save values for pechochar() */
|
||||
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
static int save_pminrow;
|
||||
static int save_pmincol;
|
||||
static int save_sminrow;
|
||||
static int save_smincol;
|
||||
static int save_smaxrow;
|
||||
static int save_smaxcol;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -125,6 +127,9 @@ static int save_smaxcol;
|
||||
WINDOW *newpad(int nlines, int ncols)
|
||||
{
|
||||
WINDOW *win;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("newpad() - called: lines=%d cols=%d\n", nlines, ncols));
|
||||
|
||||
@ -155,6 +160,9 @@ WINDOW *subpad(WINDOW *orig, int nlines, int ncols, int begy, int begx)
|
||||
int i;
|
||||
int j = begy;
|
||||
int k = begx;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("subpad() - called: lines=%d cols=%d begy=%d begx=%d\n",
|
||||
nlines, ncols, begy, begx));
|
||||
@ -238,6 +246,9 @@ int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1, int sy2,
|
||||
int num_cols;
|
||||
int sline = sy1;
|
||||
int pline = py;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("pnoutrefresh() - called\n"));
|
||||
|
||||
@ -322,6 +333,9 @@ int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1, int sy2,
|
||||
|
||||
int pechochar(WINDOW *pad, chtype ch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("pechochar() - called\n"));
|
||||
|
||||
if (waddch(pad, ch) == ERR)
|
||||
@ -336,6 +350,9 @@ int pechochar(WINDOW *pad, chtype ch)
|
||||
#ifdef CONFIG_PDCURSES_WIDE
|
||||
int pecho_wchar(WINDOW *pad, const cchar_t *wch)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("pecho_wchar() - called\n"));
|
||||
|
||||
if (!wch || (waddch(pad, *wch) == ERR))
|
||||
|
@ -165,9 +165,25 @@
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
PANEL *_bottom_panel = (PANEL *) 0;
|
||||
PANEL *_top_panel = (PANEL *) 0;
|
||||
PANEL _stdscr_pseudo_panel = { (WINDOW *) 0 };
|
||||
#else
|
||||
typedef struct panel_ctx_s
|
||||
{
|
||||
PANEL *bottom_panel;
|
||||
PANEL *top_panel;
|
||||
PANEL stdscr_pseudo_panel;
|
||||
} PANEL_CTX;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
void *pdc_alloc_panel_ctx()
|
||||
{
|
||||
return (void *) zalloc(sizeof(struct panel_ctx_s));
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@ -267,6 +283,9 @@ static void _override(PANEL *pan, int show)
|
||||
int y;
|
||||
PANEL *pan2;
|
||||
PANELOBS *tobs = pan->obscure; /* "this" one */
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
if (show == 1)
|
||||
{
|
||||
@ -306,6 +325,9 @@ static void _override(PANEL *pan, int show)
|
||||
|
||||
static void _calculate_obscure(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PANEL *pan, *pan2;
|
||||
PANELOBS *tobs; /* "this" one */
|
||||
PANELOBS *lobs; /* last one */
|
||||
@ -359,6 +381,9 @@ static void _calculate_obscure(void)
|
||||
|
||||
static bool _panel_is_linked(const PANEL *pan)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PANEL *pan2 = _bottom_panel;
|
||||
|
||||
while (pan2)
|
||||
@ -378,6 +403,9 @@ static bool _panel_is_linked(const PANEL *pan)
|
||||
|
||||
static void _panel_link_top(PANEL *pan)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
#ifdef CONFIG_PDCURSES_PANEL_DEBUG
|
||||
dstack("<lt%d>", 1, pan);
|
||||
if (_panel_is_linked(pan))
|
||||
@ -410,6 +438,9 @@ static void _panel_link_top(PANEL *pan)
|
||||
|
||||
static void _panel_link_bottom(PANEL *pan)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
#ifdef CONFIG_PDCURSES_PANEL_DEBUG
|
||||
dstack("<lb%d>", 1, pan);
|
||||
if (_panel_is_linked(pan))
|
||||
@ -440,6 +471,9 @@ static void _panel_link_bottom(PANEL *pan)
|
||||
|
||||
static void _panel_unlink(PANEL *pan)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PANEL *prev;
|
||||
PANEL *next;
|
||||
|
||||
@ -495,6 +529,9 @@ static void _panel_unlink(PANEL *pan)
|
||||
|
||||
int bottom_panel(PANEL *pan)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
if (!pan)
|
||||
{
|
||||
return ERR;
|
||||
@ -587,6 +624,9 @@ int move_panel(PANEL *pan, int starty, int startx)
|
||||
PANEL *new_panel(WINDOW *win)
|
||||
{
|
||||
PANEL *pan = malloc(sizeof(PANEL));
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
if (!_stdscr_pseudo_panel.win)
|
||||
{
|
||||
@ -625,11 +665,17 @@ PANEL *new_panel(WINDOW *win)
|
||||
|
||||
PANEL *panel_above(const PANEL *pan)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
return pan ? pan->above : _bottom_panel;
|
||||
}
|
||||
|
||||
PANEL *panel_below(const PANEL *pan)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
return pan ? pan->below : _top_panel;
|
||||
}
|
||||
|
||||
@ -696,6 +742,9 @@ int set_panel_userptr(PANEL *pan, const void *uptr)
|
||||
|
||||
int show_panel(PANEL *pan)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
if (!pan)
|
||||
{
|
||||
return ERR;
|
||||
@ -723,6 +772,9 @@ int top_panel(PANEL *pan)
|
||||
void update_panels(void)
|
||||
{
|
||||
PANEL *pan;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("update_panels() - called\n"));
|
||||
|
||||
|
@ -94,6 +94,9 @@ int printw(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int retval;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("printw() - called\n"));
|
||||
|
||||
@ -122,6 +125,9 @@ int mvprintw(int y, int x, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int retval;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("mvprintw() - called\n"));
|
||||
|
||||
|
@ -103,6 +103,9 @@ int wnoutrefresh(WINDOW *win)
|
||||
int begy;
|
||||
int i;
|
||||
int j;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("wnoutrefresh() - called: win=%p\n", win));
|
||||
|
||||
@ -184,6 +187,9 @@ int doupdate(void)
|
||||
{
|
||||
int y;
|
||||
bool clearall;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("doupdate() - called\n"));
|
||||
|
||||
@ -289,6 +295,9 @@ int doupdate(void)
|
||||
int wrefresh(WINDOW *win)
|
||||
{
|
||||
bool save_clear;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("wrefresh() - called\n"));
|
||||
|
||||
@ -318,6 +327,9 @@ int wrefresh(WINDOW *win)
|
||||
|
||||
int refresh(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("refresh() - called\n"));
|
||||
|
||||
return wrefresh(stdscr);
|
||||
|
@ -96,6 +96,9 @@ int scanw(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int retval;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("scanw() - called\n"));
|
||||
|
||||
@ -124,6 +127,9 @@ int mvscanw(int y, int x, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int retval;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("mvscanw() - called\n"));
|
||||
|
||||
|
@ -214,6 +214,9 @@ WINDOW *getwin(FILE *filep)
|
||||
int scr_dump(const char *filename)
|
||||
{
|
||||
FILE *filep;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("scr_dump() - called: filename %s\n", filename));
|
||||
|
||||
@ -237,6 +240,9 @@ int scr_init(const char *filename)
|
||||
int scr_restore(const char *filename)
|
||||
{
|
||||
FILE *filep;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("scr_restore() - called: filename %s\n", filename));
|
||||
|
||||
|
@ -137,6 +137,9 @@ int wscrl(WINDOW *win, int n)
|
||||
|
||||
int scrl(int n)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("scrl() - called\n"));
|
||||
|
||||
return wscrl(stdscr, n);
|
||||
|
@ -133,19 +133,15 @@ enum
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
static int label_length = 0;
|
||||
static int labels = 0;
|
||||
static int label_fmt = 0;
|
||||
static int label_line = 0;
|
||||
static bool hidden = false;
|
||||
|
||||
static struct SLK
|
||||
{
|
||||
chtype label[32];
|
||||
int len;
|
||||
int format;
|
||||
int start_col;
|
||||
} *slk = (struct SLK *)NULL;
|
||||
static struct SLK *slk = (struct SLK *)NULL;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -165,6 +161,9 @@ static struct SLK
|
||||
|
||||
int slk_init(int fmt)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("slk_init() - called\n"));
|
||||
|
||||
if (SP)
|
||||
@ -216,6 +215,9 @@ static void _drawone(int num)
|
||||
int col;
|
||||
int slen;
|
||||
int i;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
if (hidden)
|
||||
{
|
||||
@ -258,6 +260,9 @@ static void _drawone(int num)
|
||||
|
||||
static void _redraw(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
int i;
|
||||
|
||||
for (i = 0; i < labels; ++i)
|
||||
@ -281,6 +286,9 @@ int slk_set(int labnum, const char *label, int justify)
|
||||
PDC_mbstowcs(wlabel, label, 31);
|
||||
return slk_wset(labnum, wlabel, justify);
|
||||
#else
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("slk_set() - called\n"));
|
||||
|
||||
if (labnum < 1 || labnum > labels || justify < 0 || justify > 2)
|
||||
@ -350,6 +358,9 @@ int slk_refresh(void)
|
||||
|
||||
int slk_noutrefresh(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("slk_noutrefresh() - called\n"));
|
||||
|
||||
return wnoutrefresh(SP->slk_winptr);
|
||||
@ -357,7 +368,11 @@ int slk_noutrefresh(void)
|
||||
|
||||
char *slk_label(int labnum)
|
||||
{
|
||||
static char temp[33];
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#else
|
||||
static char slk_temp2[33];
|
||||
#endif
|
||||
#ifdef CONFIG_PDCURSES_WIDE
|
||||
wchar_t *wtemp = slk_wlabel(labnum);
|
||||
|
||||
@ -375,17 +390,20 @@ char *slk_label(int labnum)
|
||||
|
||||
for (i = 0, p = slk[labnum - 1].label; *p; i++)
|
||||
{
|
||||
temp[i] = *p++;
|
||||
slk_temp2[i] = *p++;
|
||||
}
|
||||
|
||||
temp[i] = '\0';
|
||||
slk_temp2[i] = '\0';
|
||||
#endif
|
||||
|
||||
return temp;
|
||||
return slk_temp2;
|
||||
}
|
||||
|
||||
int slk_clear(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("slk_clear() - called\n"));
|
||||
|
||||
hidden = true;
|
||||
@ -395,6 +413,9 @@ int slk_clear(void)
|
||||
|
||||
int slk_restore(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("slk_restore() - called\n"));
|
||||
|
||||
hidden = false;
|
||||
@ -404,6 +425,9 @@ int slk_restore(void)
|
||||
|
||||
int slk_touch(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("slk_touch() - called\n"));
|
||||
|
||||
return touchwin(SP->slk_winptr);
|
||||
@ -412,6 +436,9 @@ int slk_touch(void)
|
||||
int slk_attron(const chtype attrs)
|
||||
{
|
||||
int rc;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("slk_attron() - called\n"));
|
||||
|
||||
@ -430,6 +457,9 @@ int slk_attr_on(const attr_t attrs, void *opts)
|
||||
int slk_attroff(const chtype attrs)
|
||||
{
|
||||
int rc;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("slk_attroff() - called\n"));
|
||||
|
||||
@ -448,6 +478,9 @@ int slk_attr_off(const attr_t attrs, void *opts)
|
||||
int slk_attrset(const chtype attrs)
|
||||
{
|
||||
int rc;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("slk_attrset() - called\n"));
|
||||
|
||||
@ -459,6 +492,9 @@ int slk_attrset(const chtype attrs)
|
||||
int slk_color(short color_pair)
|
||||
{
|
||||
int rc;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("slk_color() - called\n"));
|
||||
|
||||
@ -477,6 +513,9 @@ int slk_attr_set(const attr_t attrs, short color_pair, void *opts)
|
||||
static void _slk_calc(void)
|
||||
{
|
||||
int i, center, col = 0;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
label_length = COLS / labels;
|
||||
|
||||
if (label_length > 31)
|
||||
@ -570,6 +609,9 @@ static void _slk_calc(void)
|
||||
|
||||
void PDC_slk_initialize(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
if (slk)
|
||||
{
|
||||
if (label_fmt == 3)
|
||||
@ -621,6 +663,9 @@ void PDC_slk_initialize(void)
|
||||
|
||||
void PDC_slk_free(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
if (slk)
|
||||
{
|
||||
if (SP->slk_winptr)
|
||||
@ -643,6 +688,9 @@ void PDC_slk_free(void)
|
||||
int PDC_mouse_in_slk(int y, int x)
|
||||
{
|
||||
int i;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("PDC_mouse_in_slk() - called: y->%d x->%d\n", y, x));
|
||||
|
||||
@ -669,6 +717,10 @@ int PDC_mouse_in_slk(int y, int x)
|
||||
#ifdef CONFIG_PDCURSES_WIDE
|
||||
int slk_wset(int labnum, const wchar_t *label, int justify)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("slk_wset() - called\n"));
|
||||
|
||||
if (labnum < 1 || labnum > labels || justify < 0 || justify > 2)
|
||||
@ -729,7 +781,11 @@ int slk_wset(int labnum, const wchar_t *label, int justify)
|
||||
|
||||
wchar_t *slk_wlabel(int labnum)
|
||||
{
|
||||
static wchar_t temp[33];
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#else
|
||||
static wchar_t slk_temp[33];
|
||||
#endif
|
||||
chtype *p;
|
||||
int i;
|
||||
|
||||
@ -742,10 +798,10 @@ wchar_t *slk_wlabel(int labnum)
|
||||
|
||||
for (i = 0, p = slk[labnum - 1].label; *p; i++)
|
||||
{
|
||||
temp[i] = *p++;
|
||||
slk_temp[i] = *p++;
|
||||
}
|
||||
|
||||
temp[i] = '\0';
|
||||
return temp;
|
||||
slk_temp[i] = '\0';
|
||||
return slk_temp;
|
||||
}
|
||||
#endif
|
||||
|
@ -149,6 +149,9 @@ char killchar(void)
|
||||
|
||||
char *longname(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("longname() - called\n"));
|
||||
|
||||
return ttytype + 9; /* skip "pdcurses|" */
|
||||
@ -156,6 +159,9 @@ char *longname(void)
|
||||
|
||||
chtype termattrs(void)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
chtype temp = A_BLINK | A_BOLD | A_INVIS | A_REVERSE | A_UNDERLINE;
|
||||
|
||||
/* note: blink is bold background on some platforms */
|
||||
|
@ -81,6 +81,7 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "term.h"
|
||||
#include "curspriv.h"
|
||||
|
||||
@ -88,14 +89,26 @@
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD
|
||||
TERMINAL *cur_term = NULL;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
void *pdc_alloc_term_ctx(void)
|
||||
{
|
||||
return (void *) zalloc(sizeof(TERMINAL));
|
||||
}
|
||||
#endif
|
||||
|
||||
int mvcur(int oldrow, int oldcol, int newrow, int newcol)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvcur() - called: oldrow %d oldcol %d newrow %d newcol %d\n",
|
||||
oldrow, oldcol, newrow, newcol));
|
||||
|
||||
|
@ -126,7 +126,11 @@
|
||||
|
||||
char *unctrl(chtype c)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#else
|
||||
static char strbuf[3] = { 0, 0, 0 };
|
||||
#endif
|
||||
|
||||
chtype ic;
|
||||
|
||||
@ -218,7 +222,11 @@ int setcchar(cchar_t *wcval, const wchar_t *wch, const attr_t attrs,
|
||||
|
||||
wchar_t *wunctrl(cchar_t *wc)
|
||||
{
|
||||
static wchar_t strbuf[3] = { 0, 0, 0 };
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#else
|
||||
static wchar_t strbuf2[3] = { 0, 0, 0 };
|
||||
#endif
|
||||
|
||||
cchar_t ic;
|
||||
|
||||
@ -228,23 +236,23 @@ wchar_t *wunctrl(cchar_t *wc)
|
||||
|
||||
if (ic >= 0x20 && ic != 0x7f) /* normal characters */
|
||||
{
|
||||
strbuf[0] = (wchar_t) ic;
|
||||
strbuf[1] = L'\0';
|
||||
strbuf2[0] = (wchar_t) ic;
|
||||
strbuf2[1] = L'\0';
|
||||
return strbuf;
|
||||
}
|
||||
|
||||
strbuf[0] = '^'; /* '^' prefix */
|
||||
strbuf2[0] = '^'; /* '^' prefix */
|
||||
|
||||
if (ic == 0x7f) /* 0x7f == DEL */
|
||||
{
|
||||
strbuf[1] = '?';
|
||||
strbuf2[1] = '?';
|
||||
}
|
||||
else /* other control */
|
||||
{
|
||||
strbuf[1] = (wchar_t) (ic + '@');
|
||||
strbuf2[1] = (wchar_t) (ic + '@');
|
||||
}
|
||||
|
||||
return strbuf;
|
||||
return strbuf2;
|
||||
}
|
||||
|
||||
int PDC_mbtowc(wchar_t *pwc, const char *s, size_t n)
|
||||
|
@ -176,6 +176,9 @@
|
||||
WINDOW *PDC_makenew(int nlines, int ncols, int begy, int begx)
|
||||
{
|
||||
WINDOW *win;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("PDC_makenew() - called: lines %d cols %d begy %d begx %d\n",
|
||||
nlines, ncols, begy, begx));
|
||||
@ -288,6 +291,9 @@ void PDC_sync(WINDOW *win)
|
||||
WINDOW *newwin(int nlines, int ncols, int begy, int begx)
|
||||
{
|
||||
WINDOW *win;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("newwin() - called:lines=%d cols=%d begy=%d begx=%d\n",
|
||||
nlines, ncols, begy, begx));
|
||||
@ -346,6 +352,9 @@ int delwin(WINDOW *win)
|
||||
|
||||
int mvwin(WINDOW *win, int y, int x)
|
||||
{
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
PDC_LOG(("mvwin() - called\n"));
|
||||
|
||||
if (!win || (y + win->_maxy > LINES || y < 0) ||
|
||||
@ -525,6 +534,9 @@ WINDOW *resize_window(WINDOW *win, int nlines, int ncols)
|
||||
int new_begx;
|
||||
int new_begy;
|
||||
int i;
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
FAR struct pdc_context_s *ctx = PDC_ctx();
|
||||
#endif
|
||||
|
||||
PDC_LOG(("resize_window() - called: nlines %d ncols %d\n", nlines, ncols));
|
||||
|
||||
|
@ -55,6 +55,8 @@
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define PDC_RGB 1
|
||||
|
||||
#ifdef CONFIG_PDCURSES_WIDE
|
||||
# include <wchar.h>
|
||||
#endif
|
||||
@ -77,6 +79,12 @@
|
||||
# define OK 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PDCURSES_CHTYPE_LONG
|
||||
# define PDC_COLOR_PAIRS 256
|
||||
#else
|
||||
# define PDC_COLOR_PAIRS 32
|
||||
#endif
|
||||
|
||||
#define BUTTON_RELEASED 0x0000
|
||||
#define BUTTON_PRESSED 0x0001
|
||||
#define BUTTON_CLICKED 0x0002
|
||||
@ -683,8 +691,33 @@
|
||||
#define KEY_SUP 0x223 /* Shifted up arrow */
|
||||
#define KEY_SDOWN 0x224 /* Shifted down arrow */
|
||||
|
||||
#define ALT_PLUS 0x225 /* alt-+ key */
|
||||
#define ALT_PERIOD 0x226 /* alt-. key */
|
||||
#define ALT_QUESTION 0x227 /* alt-? key */
|
||||
#define ALT_LBRACE 0x228 /* alt-{ key */
|
||||
#define ALT_RBRACE 0x229 /* alt-} key */
|
||||
#define ALT_COLON 0x22a /* alt-: key */
|
||||
#define ALT_TICK 0x22b /* alt-' key */
|
||||
#define ALT_QUOTE 0x22c /* alt-" key */
|
||||
#define ALT_LESS 0x22d /* alt-< key */
|
||||
#define ALT_GREATER 0x22e /* alt-> key */
|
||||
#define ALT_UNDERSCORE 0x22f /* alt-_ key */
|
||||
#define ALT_VBAR 0x230 /* alt-| key */
|
||||
#define ALT_EXCL 0x231 /* alt-! key */
|
||||
#define ALT_AT 0x232 /* alt-@ key */
|
||||
#define ALT_POUND 0x233 /* alt-# key */
|
||||
#define ALT_DOLLAR 0x234 /* alt-$ key */
|
||||
#define ALT_PERCENT 0x235 /* alt-% key */
|
||||
#define ALT_CARET 0x236 /* alt-^ key */
|
||||
#define ALT_AMP 0x237 /* alt-& key */
|
||||
#define ALT_STAR 0x238 /* alt-* key */
|
||||
#define ALT_LPAREN 0x239 /* alt-( key */
|
||||
#define ALT_RPAREN 0x23a /* alt-) key */
|
||||
|
||||
#define ALT_SPACE 0x23b /* alt-space key */
|
||||
|
||||
#define KEY_MIN KEY_BREAK /* Minimum curses key value */
|
||||
#define KEY_MAX KEY_SDOWN /* Maximum curses key */
|
||||
#define KEY_MAX ALT_SPACE /* Maximum curses key */
|
||||
|
||||
#define KEY_F(n) (KEY_F0 + (n))
|
||||
|
||||
@ -833,7 +866,7 @@ typedef struct
|
||||
* order to count it as a click */
|
||||
int slklines; /* lines in use by slk_init() */
|
||||
WINDOW *slk_winptr; /* window for slk */
|
||||
int linesrippedoff; /* lines ripped off via ripoffline() */
|
||||
int linesrippedoffcnt; /* lines ripped off via ripoffline() */
|
||||
int linesrippedoffontop; /* lines ripped off on
|
||||
* top via ripoffline() */
|
||||
int delaytenths; /* 1/10ths second to wait block
|
||||
@ -851,10 +884,154 @@ typedef struct
|
||||
short line_color; /* color of line attributes - default -1 */
|
||||
} SCREEN;
|
||||
|
||||
typedef struct /* Structure for ripped off lines */
|
||||
{
|
||||
int line;
|
||||
int (*init)(WINDOW *, int);
|
||||
} RIPPEDOFFLINE;
|
||||
|
||||
struct SLK
|
||||
{
|
||||
chtype label[32];
|
||||
int len;
|
||||
int format;
|
||||
int start_col;
|
||||
};
|
||||
|
||||
struct cttyset
|
||||
{
|
||||
bool been_set;
|
||||
SCREEN saved;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PDCURSES_MULTITHREAD
|
||||
|
||||
#define _INBUFSIZ 512 /* size of terminal input buffer */
|
||||
#define NUNGETCH 256 /* max # chars to ungetch() */
|
||||
|
||||
struct pdc_context_s
|
||||
{
|
||||
#ifndef CONFIG_PDCURSES_MULTITHREAD_HASH
|
||||
int pid;
|
||||
FAR struct pdc_context_s *next;
|
||||
FAR struct pdc_context_s *prev;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
bool graphic_screen;
|
||||
#endif
|
||||
uint8_t pdc_color_started;
|
||||
uint8_t default_colors;
|
||||
uint8_t hidden;
|
||||
uint8_t ungot;
|
||||
uint8_t pair_set[PDC_COLOR_PAIRS];
|
||||
short LINES; /* terminal height */
|
||||
short COLS; /* terminal width */
|
||||
WINDOW *stdscr; /* the default screen window */
|
||||
WINDOW *curscr; /* the current screen image */
|
||||
WINDOW *pdc_lastscr;
|
||||
SCREEN *SP; /* curses variables */
|
||||
MOUSE_STATUS Mouse_status;
|
||||
MOUSE_STATUS pdc_mouse_status;
|
||||
unsigned long pdc_key_modifiers;
|
||||
char ttytype[64]; /* terminal name/description */
|
||||
int COLORS;
|
||||
short COLOR_PAIRS;
|
||||
short TABSIZE;
|
||||
short first_col;
|
||||
short c_pindex; /* putter index */
|
||||
short c_gindex; /* getter index */
|
||||
short c_ungind; /* ungetch() push index */
|
||||
short c_ungch[NUNGETCH]; /* array of ungotten chars */
|
||||
short c_buffer[_INBUFSIZ]; /* character buffer */
|
||||
RIPPEDOFFLINE linesripped[5];
|
||||
short linesrippedoff;
|
||||
short label_length;
|
||||
short labels;
|
||||
short label_fmt;
|
||||
int label_line;
|
||||
struct SLK *slk;
|
||||
short save_pminrow;
|
||||
short save_pmincol;
|
||||
short save_sminrow;
|
||||
short save_smincol;
|
||||
short save_smaxrow;
|
||||
short save_smaxcol;
|
||||
uint8_t pdc_trace_on; /* Tracing flag */
|
||||
char strbuf[3];
|
||||
char strbuf2[3];
|
||||
struct cttyset ctty[3];
|
||||
void *panel_ctx;
|
||||
void *term_ctx;
|
||||
char slk_temp[33];
|
||||
char slk_temp2[33];
|
||||
};
|
||||
|
||||
FAR struct pdc_context_s * PDC_ctx(void);
|
||||
void PDC_ctx_free(void);
|
||||
|
||||
#define LINES ctx->LINES
|
||||
#define COLS ctx->COLS
|
||||
#define stdscr ctx->stdscr
|
||||
#define curscr ctx->curscr
|
||||
#define pdc_lastscr ctx->pdc_lastscr
|
||||
#define SP ctx->SP
|
||||
#define Mouse_status ctx->Mouse_status
|
||||
#define pdc_mouse_status ctx->pdc_mouse_status
|
||||
#define COLORS ctx->COLORS
|
||||
#define COLOR_PAIRS ctx->COLOR_PAIRS
|
||||
#define TABSIZE ctx->TABSIZE
|
||||
#define ttytype ctx->ttytype
|
||||
#define pdc_color_started ctx->pdc_color_started
|
||||
#define pair_set ctx->pair_set
|
||||
#define default_colors ctx->default_colors
|
||||
#define first_col ctx->first_col
|
||||
#define pdc_trace_on ctx->pdc_trace_on
|
||||
#define pdc_key_modifiers ctx->pdc_key_modifiers
|
||||
#define c_pindex ctx->c_pindex
|
||||
#define c_gindex ctx->c_gindex
|
||||
#define c_ungind ctx->c_ungind
|
||||
#define c_ungch ctx->c_ungch
|
||||
#define c_ungch ctx->c_ungch
|
||||
#define c_buffer ctx->c_buffer
|
||||
#define linesripped ctx->linesripped
|
||||
#define linesrippedoff ctx->linesrippedoff
|
||||
#define label_length ctx->label_length
|
||||
#define labels ctx->labels
|
||||
#define label_fmt ctx->label_fmt
|
||||
#define label_line ctx->label_line
|
||||
#define hidden ctx->hidden
|
||||
#define slk ctx->slk
|
||||
#define slk_temp ctx->slk_temp
|
||||
#define slk_temp2 ctx->slk_temp2
|
||||
#define ctty ctx->ctty
|
||||
#define ungot ctx->ungot
|
||||
#define strbuf ctx->strbuf
|
||||
#define strbuf2 ctx->strbuf2
|
||||
#define save_pminrow ctx->save_pminrow
|
||||
#define save_pmincol ctx->save_pmincol
|
||||
#define save_sminrow ctx->save_sminrow
|
||||
#define save_smincol ctx->save_smincol
|
||||
#define save_smaxrow ctx->save_smaxrow
|
||||
#define save_smaxcol ctx->save_smaxcol
|
||||
#define _bottom_panel ((PANEL_CTX *)(ctx->panel_ctx))->bottom_panel
|
||||
#define _top_panel ((PANEL_CTX *)(ctx->panel_ctx))->top_panel
|
||||
#define _stdscr_pseudo_panel ((PANEL_CTX *)(ctx->panel_ctx))->stdscr_pseudo_panel
|
||||
#define cur_term ((TERMINAL_CTX *)(ctx->term_ctx))->cur_term
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
#define graphic_screen ctx->graphic_screen
|
||||
#endif
|
||||
|
||||
void* pdc_alloc_panel_ctx(void);
|
||||
void* pdc_alloc_term_ctx(void);
|
||||
|
||||
#else
|
||||
|
||||
EXTERN int LINES; /* terminal height */
|
||||
EXTERN int COLS; /* terminal width */
|
||||
EXTERN WINDOW *stdscr; /* the default screen window */
|
||||
@ -864,9 +1041,16 @@ EXTERN MOUSE_STATUS Mouse_status;
|
||||
EXTERN int COLORS;
|
||||
EXTERN int COLOR_PAIRS;
|
||||
EXTERN int TABSIZE;
|
||||
EXTERN chtype acs_map[]; /* alternate character set map */
|
||||
EXTERN char ttytype[]; /* terminal name/description */
|
||||
|
||||
#ifdef CONFIG_SYSTEM_TERMCURSES
|
||||
EXTERN bool graphic_screen;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
EXTERN chtype acs_map[]; /* alternate character set map */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
237
include/system/termcurses.h
Normal file
237
include/system/termcurses.h
Normal file
@ -0,0 +1,237 @@
|
||||
/********************************************************************************************
|
||||
* apps/include/system/termcurses.h
|
||||
*
|
||||
* Copyright (C) 2018 Ken Pettit. All rights reserved.
|
||||
* Author: Ken Pettit <pettitkd@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_SYSTEM_TERMCURSES_H
|
||||
#define __APPS_INCLUDE_SYSTEM_TERMCURSES_H
|
||||
|
||||
/********************************************************************************************
|
||||
* Included Files
|
||||
********************************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
|
||||
/********************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
********************************************************************************************/
|
||||
|
||||
#define TCURS_CLEAR_SCREEN 1
|
||||
#define TCURS_CLEAR_LINE 2
|
||||
#define TCURS_CLEAR_EOS 3
|
||||
#define TCURS_CLEAR_EOL 4
|
||||
|
||||
#define TCURS_MOVE_UP 1
|
||||
#define TCURS_MOVE_DOWN 2
|
||||
#define TCURS_MOVE_LEFT 3
|
||||
#define TCURS_MOVE_RIGHT 4
|
||||
#define TCURS_MOVE_YX 5
|
||||
#define TCURS_MOVE_TO_ROW 6
|
||||
#define TCURS_MOVE_TO_COL 7
|
||||
|
||||
#define TCURS_COLOR_FG 0x01
|
||||
#define TCURS_COLOR_BG 0x02
|
||||
|
||||
#define TCURS_ATTRIB_BLINK 0x0001
|
||||
#define TCURS_ATTRIB_BOLD 0x0002
|
||||
#define TCURS_ATTRIB_UNDERLINE 0x0004
|
||||
#define TCURS_ATTRIB_INVIS 0x0008
|
||||
#define TCURS_ATTRIB_CURS_HIDE 0x0010
|
||||
#define TCURS_ATTRIB_CURS_SHOW 0x0020
|
||||
|
||||
/********************************************************************************************
|
||||
* Public Type Definitions
|
||||
********************************************************************************************/
|
||||
|
||||
/* Used with TTY ioctls */
|
||||
|
||||
struct tcurses_ioctl_s
|
||||
{
|
||||
uint16_t tc_row; /* Cursor row */
|
||||
uint16_t tc_col; /* Cursor col */
|
||||
};
|
||||
|
||||
struct termcurses_dev_s;
|
||||
struct termcurses_s;
|
||||
struct termcurses_colors_s;
|
||||
|
||||
struct termcurses_ops_s
|
||||
{
|
||||
/* Initialize a new instance bound to a file */
|
||||
|
||||
CODE FAR struct termcurses_s * (*init)(int in_fd, int out_fd);
|
||||
|
||||
/* Clear operations (screen, line, EOS, EOL) */
|
||||
|
||||
CODE int (*clear)(FAR struct termcurses_s *dev, int type);
|
||||
|
||||
/* Cursor Move operations */
|
||||
|
||||
CODE int (*move)(FAR struct termcurses_s *dev, int type, int col, int row);
|
||||
|
||||
/* Get terminal size in row/col dimensions */
|
||||
|
||||
CODE int (*getwinsize)(FAR struct termcurses_s *dev, FAR struct winsize *winsz);
|
||||
|
||||
/* Set fg/bg colors */
|
||||
|
||||
CODE int (*setcolors)(FAR struct termcurses_s *dev,
|
||||
FAR struct termcurses_colors_s *colors);
|
||||
|
||||
/* Set display attributes */
|
||||
|
||||
CODE int (*setattrib)(FAR struct termcurses_s *dev, unsigned long attributes);
|
||||
|
||||
/* Get a keycode value */
|
||||
|
||||
CODE int (*getkeycode)(FAR struct termcurses_s *dev, int *specialkey, int *keymodifers);
|
||||
};
|
||||
|
||||
struct termcurses_dev_s
|
||||
{
|
||||
FAR const struct termcurses_ops_s *ops;
|
||||
FAR struct termcurses_dev_s *next;
|
||||
FAR const char *name;
|
||||
};
|
||||
|
||||
struct termcurses_s
|
||||
{
|
||||
FAR struct termcurses_dev_s *dev;
|
||||
FAR struct file *filep;
|
||||
};
|
||||
|
||||
struct termcurses_colors_s
|
||||
{
|
||||
uint8_t color_mask;
|
||||
uint8_t fg_red;
|
||||
uint8_t fg_green;
|
||||
uint8_t fg_blue;
|
||||
uint8_t bg_red;
|
||||
uint8_t bg_green;
|
||||
uint8_t bg_blue;
|
||||
};
|
||||
|
||||
/********************************************************************************************
|
||||
* Public Function Prototypes
|
||||
********************************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/********************************************************************************************
|
||||
* termcurses_initterm:
|
||||
*
|
||||
* Finds a termcurses_s device based on terminal type string and initialize
|
||||
* a new context for device control.
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
int termcurses_initterm(FAR const char *term_type, int in_fd, int out_fd,
|
||||
FAR struct termcurses_s **dev);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: termcurses_deinitterm
|
||||
*
|
||||
* Description:
|
||||
* Free all space for the termcurses terminal and perform any specific
|
||||
* de-initialization tasks.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
int termcurses_deinitterm(FAR struct termcurses_s *dev);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: termcurses_moveyx
|
||||
*
|
||||
* Description:
|
||||
* Configure output text to render in the specified fg/bg colors.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
int termcurses_moveyx(FAR struct termcurses_s *term, int row, int col);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: termcurses_setattribute
|
||||
*
|
||||
* Description:
|
||||
* Configure output text to render in the specified fg/bg colors.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
int termcurses_setattribute(FAR struct termcurses_s *term, unsigned long attrib);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: termcurses_setcolors
|
||||
*
|
||||
* Description:
|
||||
* Configure output text to render in the specified fg/bg colors.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
int termcurses_setcolors(FAR struct termcurses_s *term,
|
||||
FAR struct termcurses_colors_s *colors);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: termcurses_getwinsize
|
||||
*
|
||||
* Description:
|
||||
* Determines the size of the terminal screen in terms of character rows and cols.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
int termcurses_getwinsize(FAR struct termcurses_s *term, FAR struct winsize *winsz);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: termcurses_getkeycode
|
||||
*
|
||||
* Description:
|
||||
* Get a translated key code from the terminal input.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
int termcurses_getkeycode(FAR struct termcurses_s *term, FAR int *specialkey,
|
||||
FAR int *keymodifiers);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_INCLUDE_SYSTEM_TERMCURSES_H */
|
Loading…
x
Reference in New Issue
Block a user