Logo Search packages:      
Sourcecode: kaya version File versions  Download package

cursesw_glue.cc

/* Chris Morris 26 June 2005, based on curses_glue.cc by Edwin Brady
   and released under the same license */

#include "cursesw_glue.h"
#include "locale.h"
#include <ncursesw/ncurses.h>

bool testerr(int x) {
    return x == ERR;
}

void docbreak() { cbreak(); }
void donocbreak() { nocbreak(); }
void doecho() { echo(); }
void donoecho() { noecho(); }
void donl() { nl(); }
void dononl() { nonl(); }
void doraw() { raw(); }
void donoraw() { noraw(); }

WINDOW* getstdscr() {
    return stdscr;
}

void dointrflush(void* v, bool bf) {
    intrflush((WINDOW*)v,bf);
}

WINDOW* doinitscr() {
  setlocale(LC_ALL,"");
  return initscr();
}

void dokeypad(void* v, bool bf) {
    keypad((WINDOW*)v,bf);
}

void dometa(void* v, bool bf) {
    meta((WINDOW*)v,bf);
}

void donodelay(void* v, bool bf) {
    nodelay((WINDOW*)v,bf);
}

void donotimeout(void* v, bool bf) {
    notimeout((WINDOW*)v,bf);
}

void dorefresh() {
    refresh();
}

void dowrefresh(void* win) {
//    char buf[50];
//    sprintf(buf,"Refreshing %d",win);
//    addstr(buf);
    wrefresh((WINDOW*)win);
}

void dowmove(void* w, int y, int x) {
    wmove((WINDOW*)w,y,x);
}

void domove(int y, int x) {
    move(y,x);
}


void doaddstr(char * s)
{
    addstr(s);
}

void dowaddstr(void* w, char * s)
{
    waddstr((WINDOW*)w, s);
}

int mkAtt(KayaValue v)
{
    int tag = KayaUnionGetTag(v);
    switch(tag) {
    case 0:
      return A_NORMAL; 
      break;
    case 1:
      return A_STANDOUT;
      break;
    case 2:
      return A_UNDERLINE;
      break;
    case 3:
      return A_REVERSE;
      break;
    case 4:
      return A_BLINK;
      break;
    case 5:
      return A_DIM;
      break;
    case 6:
      return A_BOLD;
      break;
    case 7:
      return A_PROTECT;
      break;
    case 8:
      return A_INVIS;
      break;
    case 9:
      return A_ALTCHARSET;
      break;
    case 10:
      return A_CHARTEXT;
      break;
    case 11:
      return COLOR_PAIR(KayaGetInt(KayaUnionGetArg(v,0)));
      break;
    }
}

int att_to_int(KayaArray attribs)
{
    int a=0;
    for(int i=0;i<KayaArraySize(attribs);i++) {
      KayaValue x = KayaArrayLookup(attribs,i);
      a = a | (mkAtt(x));
    }
    return a;
}

int doattron(KayaArray attribs)
{
    return attron(att_to_int(attribs));
}

int doattroff(KayaArray attribs)
{
    return attroff(att_to_int(attribs));
}

int dowattron(void* win, KayaArray attribs)
{
    return wattron((WINDOW*)win,att_to_int(attribs));
}

int dowattroff(void* win, KayaArray attribs)
{
    return wattroff((WINDOW*)win,att_to_int(attribs));
}

char dogetch()
{
    return getch();
}

char domvgetch(int y, int x)
{
    return mvgetch(y,x);
}

char dowgetch(void* win)
{
    return wgetch((WINDOW*)win);
}

char dowmvgetch(void* win, int y, int x)
{
    return mvwgetch((WINDOW*)win,y,x);
}

char* dogetstr()
{
    char* buf = (char*)(KayaAlloc(255));
    getnstr(buf,255);
    return buf;
}

char* dowgetstr(void* win)
{
    char* buf = (char*)(KayaAlloc(255));
    wgetnstr((WINDOW*)win,buf,255);
    return buf;
}

int getBlack()
{
    return COLOR_BLACK;
}

int getRed()
{
    return COLOR_RED;
}

int getGreen()
{
    return COLOR_GREEN;
}

int getYellow()
{
    return COLOR_YELLOW;
}

int getBlue()
{
    return COLOR_BLUE;
}

int getMagenta()
{
    return COLOR_MAGENTA;
}

int getCyan()
{
    return COLOR_CYAN;
}

int getWhite()
{
    return COLOR_WHITE;
}

int getColourPairs()
{
    return COLOR_PAIRS;
}

int getColours()
{
    return COLORS;
}

void* donewwin(int l, int c,int y, int x)
{
    void* win = (void*)(newwin(l,c,y,x));
//    char buf[50];
//    sprintf(buf,"New win %d",win);
//    addstr(buf);
    return win;
}

int dodelwin(void* win) {
    return delwin((WINDOW*)win);
}

int domvwin(void* win, int y, int x) {
    return mvwin((WINDOW*)win, y, x);
}

DEFKEY(DOWN);
DEFKEY(UP);
DEFKEY(LEFT);
DEFKEY(RIGHT);
DEFKEY(HOME);
DEFKEY(END);
DEFKEY(BACKSPACE);
DEFKEY(A1);
DEFKEY(A3);
DEFKEY(B2);
DEFKEY(C1);
DEFKEY(C3);

int dobox(void* win,char x, char y)
{
//    char buf[50];
//    sprintf(buf,"Boxing %d",win);
//    addstr(buf);
    return box((WINDOW*)win,x,y);
}

void doclear()
{
    clear();
}

void doerase()
{
    erase();
}

void doclrtobot()
{
    clrtobot();
}

void doclrtoeol()
{
    clrtoeol();
}

void dowclear(void* p)
{
    wclear((WINDOW*)p);
}

void dowerase(void* p)
{
    werase((WINDOW*)p);
}

void dowclrtobot(void* p)
{
    wclrtobot((WINDOW*)p);
}

void dowclrtoeol(void* p)
{
    wclrtoeol((WINDOW*)p);
}

Generated by  Doxygen 1.6.0   Back to index