string Vehicle::fullname(bool halffull) const { string s; int words = 0; if (heat_>0) { s = "Stolen "; words++; } if (displayscolor()) { s += color_+" "; words++; } if (myear_!=-1 && words<2)//don't print year if that will make the name too long. { s += tostring(myear_)+" "; } if (halffull) s += shortname(); else s += longname(); return s; }
QString SkyObject::messageFromTitle( const QString &imageTitle ) { QString message = imageTitle; //HST Image if ( imageTitle == i18n( "Show HST Image" ) || imageTitle.contains("HST") ) { message = i18n( "%1: Hubble Space Telescope, operated by STScI for NASA [public domain]" ).arg( longname() ); //Spitzer Image } else if ( imageTitle.contains( i18n( "Show Spitzer Image" ) ) ) { message = i18n( "%1: Spitzer Space Telescope, courtesy NASA/JPL-Caltech [public domain]" ).arg( longname() ); //SEDS Image } else if ( imageTitle == i18n( "Show SEDS Image" ) ) { message = i18n( "%1: SEDS, http://www.seds.org [free for non-commercial use]" ).arg( longname() ); //Kitt Peak AOP Image } else if ( imageTitle == i18n( "Show KPNO AOP Image" ) ) { message = i18n( "%1: Advanced Observing Program at Kitt Peak National Observatory [free for non-commercial use; no physical reproductions]" ).arg( longname() ); //NOAO Image } else if ( imageTitle.contains( i18n( "Show NOAO Image" ) ) ) { message = i18n( "%1: National Optical Astronomy Observatories and AURA [free for non-commercial use]" ).arg( longname() ); //VLT Image } else if ( imageTitle.contains( "VLT" ) ) { message = i18n( "%1: Very Large Telescope, operated by the European Southern Observatory [free for non-commercial use; no reproductions]" ).arg( longname() ); //All others } else if ( imageTitle.startsWith( i18n( "Show" ) ) ) { message = imageTitle.mid( imageTitle.find( " " ) + 1 ); //eat first word, "Show" message = longname() + ": " + message; } return message; }
char* rt_pvd_file::longname(pwr_tOix oix) { if (m_list[oix].fthoix == 0) strcpy(m_list[oix].lname, m_list[oix].name); else { strcpy(m_list[oix].lname, longname(m_list[oix].fthoix)); strcat(m_list[oix].lname, "-"); strcat(m_list[oix].lname, m_list[oix].name); } return m_list[oix].lname; }
bool wb_pvd_gvl::check_list( pwr_tStatus *sts) { int error_cnt = 0; char msg[200]; for ( int i = 0; i < (int) m_list.size(); i++) { if ( m_list[i].flags & procom_obj_mFlags_Deleted) continue; switch ( m_list[i].cid) { case pwr_cClass_VolumeReg: { pwr_sClass_VolumeReg *body = (pwr_sClass_VolumeReg *)m_list[i].body; pwr_tOid oid; oid.oix = m_list[i].oix; oid.vid = ldh_cProjectListVolume; if ( body->VolumeId == 0) { sprintf( msg, "VolumeId is missing, in object %s", longname(m_list[i].oix)); MsgWindow::message('E', msg, msgw_ePop_No, oid); error_cnt++; } if ( strcmp( body->Project, "") == 0) { sprintf( msg, "Project is missing, in object %s", longname(m_list[i].oix)); MsgWindow::message('E', msg, msgw_ePop_No, oid); error_cnt++; } break; } default: ; } } if ( error_cnt) { sprintf( msg, "%d error(s) found, Save aborted", error_cnt); MsgWindow::message('E', msg, msgw_ePop_Yes); *sts = LDH__SYNTAX; return false; } *sts = LDH__SUCCESS; return true; }
void rt_pvd_file::objectName(co_procom* pcom, char* name, pwr_tOix poix) { for (int i = 0; i < (int)m_list.size(); i++) { if (!(m_list[i].flags & procom_obj_mFlags_Deleted)) { if (str_NoCaseStrcmp(name, longname(m_list[i].oix)) == 0) { objectOid(pcom, i); return; } } } if (m_env == pvd_eEnv_Wb) pcom->provideObject(0, 0, 0, 0, 0, 0, 0, 0, "", ""); else pcom->provideStatus(GDH__NOSUCHOBJ); }
void rt_pvd_udb::save( pwr_tStatus *sts) { gu->clear(); for ( int i = 1; i < (int)m_list.size(); i++) { if ( m_list[i].flags & procom_obj_mFlags_Deleted) continue; switch ( m_list[i].cid) { case pwr_cClass_SystemGroupReg: { pwr_sClass_SystemGroupReg *body = (pwr_sClass_SystemGroupReg *)m_list[i].body; *sts = gu->add_system( groupname(longname( m_list[i].oix)), body->Attributes, body->Description, m_list[i].oix-1); if ( EVEN(*sts)) return; break; } case pwr_cClass_UserReg: { pwr_sClass_UserReg *body = (pwr_sClass_UserReg *)m_list[i].body; char gname[120]; char *s; strcpy( gname, longname( m_list[i].oix)); if ( (s = strrchr( gname, '-'))) *s = 0; *sts = gu->add_user( groupname(gname), m_list[i].name, body->Password, body->Privileges, body->FullName, body->Description, body->Email, body->Phone, body->Sms, m_list[i].oix-1); if ( EVEN(*sts)) return; break; } default: ; } } *sts = gu->save(); }
void rt_pvd_file::objectOid(co_procom* pcom, pwr_tOix oix) { if (m_env == pvd_eEnv_Wb) { if (oix >= m_list.size() || oix <= 0) { pcom->provideObject(LDH__NOSUCHOBJ, 0, 0, 0, 0, 0, 0, 0, "", ""); return; } pcom->provideObject(1, oix, m_list[oix].fthoix, m_list[oix].bwsoix, m_list[oix].fwsoix, m_list[oix].fchoix, m_list[oix].lchoix, m_list[oix].cid, m_list[oix].name, longname(oix)); } else { if (oix >= m_list.size()) { pcom->provideStatus(GDH__NOSUCHOBJ); return; } pcom->provideObjects(GDH__SUCCESS, m_list); } }
void setterm(char *type) { int tgetent(char *bp, const char *name); register int unknown, i; register int l; char ltcbuf[TCBUFSIZE]; struct winsize win; char *s; if (type[0] == 0) type = "xx"; unknown = 0; putpad(TE); if (tgetent(ltcbuf, type) != 1) { unknown++; CP(ltcbuf, "xx|dumb:"); } gettmode(); if (ioctl(0, TIOCGWINSZ, &win) < 0) { i = EX_LINES = tgetnum("li"); COLUMNS = tgetnum("co"); } else { if ((EX_LINES = win.ws_row) == 0) EX_LINES = tgetnum("li"); i = EX_LINES; if ((COLUMNS = win.ws_col) == 0) COLUMNS = tgetnum("co"); } if (EX_LINES <= 5) EX_LINES = 24; if (EX_LINES > TUBELINES) EX_LINES = TUBELINES; l = EX_LINES; if (ex_ospeed < B1200) l = 9; /* including the message line at the bottom */ else if (ex_ospeed < B2400) l = 17; if (l > EX_LINES) l = EX_LINES; aoftspace = tspace; zap(); /* * Initialize keypad arrow keys. */ arrows[0].cap = KU; arrows[0].mapto = "k"; arrows[0].descr = "up"; arrows[1].cap = KD; arrows[1].mapto = "j"; arrows[1].descr = "down"; arrows[2].cap = KL; arrows[2].mapto = "h"; arrows[2].descr = "left"; arrows[3].cap = KR; arrows[3].mapto = "l"; arrows[3].descr = "right"; arrows[4].cap = KH; arrows[4].mapto = "H"; arrows[4].descr = "home"; /* * Handle funny termcap capabilities */ if (CS && SC && RC) AL=DL=""; if (AL_PARM && AL==NULL) AL=""; if (DL_PARM && DL==NULL) DL=""; if (IC && IM==NULL) IM=""; if (IC && EI==NULL) EI=""; if (!GT) BT=NULL; /* If we can't tab, we can't backtab either */ #ifdef SIGTSTP /* * Now map users susp char to ^Z, being careful that the susp * overrides any arrow key, but only for hackers (=new tty driver). */ if (dosusp) { static char sc[2]; int i; sc[0] = tty.c_cc[VSUSP]; sc[1] = 0; if (*sc == CTRL('z')) { for (i=0; i<=4; i++) if (arrows[i].cap && arrows[i].cap[0] == CTRL('z')) addmac(sc, NULL, NULL, arrows); } else addmac(sc, "\32", "susp", arrows); } #endif options[WINDOW].ovalue = options[WINDOW].odefault = l - 1; if (defwind) options[WINDOW].ovalue = defwind; options[SCROLL].ovalue = options[SCROLL].odefault = HC ? 11 : ((l-1) / 2); if (COLUMNS <= 4) COLUMNS = 1000; if (!(s = tgoto(CM, 2, 2)) || *s == 'O') /* OOPS */ CA = 0, CM = 0; else CA = 1, costCM = cost(tgoto(CM, 8, 10)); costSR = cost(SR); costAL = cost(AL); costDP = cost(tgoto(DOWN_PARM, 10, 10)); costLP = cost(tgoto(LEFT_PARM, 10, 10)); costRP = cost(tgoto(RIGHT_PARM, 10, 10)); PC = xPC ? xPC[0] : 0; aoftspace = tspace; CP(ex_ttytype, longname(ltcbuf, type)); if (i <= 0) EX_LINES = 2; /* proper strings to change tty type */ termreset(); value(REDRAW) = AL && DL; value(OPTIMIZE) = !CA && !GT; if (ex_ospeed == B1200 && !value(REDRAW)) value(SLOWOPEN) = 1; /* see also gettmode above */ if (unknown) serror("%s: Unknown terminal type", type); }
void software_list_device::internal_validity_check(validity_checker &valid) { enum { NAME_LEN_PARENT = 16, NAME_LEN_CLONE = 16 }; softlist_map names; softlist_map descriptions; for (const software_info &swinfo : get_info()) { std::string const &shortname(swinfo.shortname()); // first parse and output core errors if any if (m_errors.length() > 0) { osd_printf_error("%s: Errors parsing software list:\n%s", filename(), errors_string()); break; } // Now check if the xml data is valid: // Did we lost any description? if (swinfo.longname().empty()) { osd_printf_error("%s: %s has no description\n", filename(), shortname.c_str()); break; } // Did we lost any year? if (swinfo.year().empty()) { osd_printf_error("%s: %s has no year\n", filename(), shortname.c_str()); break; } // Did we lost any publisher? if (swinfo.publisher().empty()) { osd_printf_error("%s: %s has no publisher\n", filename(), shortname.c_str()); break; } // Did we lost the software parts? if (swinfo.parts().empty()) { osd_printf_error("%s: %s has no part\n", filename(), shortname.c_str()); break; } // Second, since the xml is fine, run additional checks: // check for duplicate names if (!names.insert(std::make_pair(shortname, &swinfo)).second) { const software_info *match = names.find(shortname)->second; osd_printf_error("%s: %s is a duplicate name (%s)\n", filename(), shortname.c_str(), match->shortname().c_str()); } // check for duplicate descriptions std::string longname(swinfo.longname()); if (!descriptions.insert(std::make_pair(strmakelower(longname), &swinfo)).second) osd_printf_error("%s: %s is a duplicate description (%s)\n", filename(), swinfo.longname().c_str(), shortname.c_str()); bool const is_clone(!swinfo.parentname().empty()); if (is_clone) { if (swinfo.parentname() == shortname) { osd_printf_error("%s: %s is set as a clone of itself\n", filename(), shortname.c_str()); break; } // make sure the parent exists const software_info *swinfo2 = find(swinfo.parentname().c_str()); if (swinfo2 == nullptr) osd_printf_error("%s: parent '%s' software for '%s' not found\n", filename(), swinfo.parentname().c_str(), shortname.c_str()); else if (!swinfo2->parentname().empty()) osd_printf_error("%s: %s is a clone of a clone\n", filename(), shortname.c_str()); } // make sure the driver name isn't too long if (shortname.length() > (is_clone ? NAME_LEN_CLONE : NAME_LEN_PARENT)) osd_printf_error("%s: %s %s software name must be %d characters or less\n", filename(), shortname.c_str(), is_clone ? "clone" : "parent", is_clone ? NAME_LEN_CLONE : NAME_LEN_PARENT); // make sure the driver name doesn't contain invalid characters for (char ch : shortname) if (((ch < '0') || (ch > '9')) && ((ch < 'a') || (ch > 'z')) && (ch != '_')) { osd_printf_error("%s: %s contains invalid characters\n", filename(), shortname.c_str()); break; } // make sure the year is only digits, '?' or '+' for (char ch : swinfo.year()) if (!isdigit(u8(ch)) && (ch != '?') && (ch != '+')) { osd_printf_error("%s: %s has an invalid year '%s'\n", filename(), shortname.c_str(), swinfo.year().c_str()); break; } softlist_map part_names; for (const software_part &part : swinfo.parts()) { if (part.interface().empty()) osd_printf_error("%s: %s has a part (%s) without interface\n", filename(), shortname.c_str(), part.name().c_str()); if (part.romdata().empty()) osd_printf_error("%s: %s has a part (%s) with no data\n", filename(), shortname.c_str(), part.name().c_str()); if (!part_names.insert(std::make_pair(part.name(), &swinfo)).second) osd_printf_error("%s: %s has a part (%s) whose name is duplicate\n", filename(), shortname.c_str(), part.name().c_str()); } } // release all the memory release(); }
void ObjModelLoader::secondPass() { string lastType = ""; int grpId = -1; mPriModelPtr->setCurrentGrp(mPriModelPtr->getGrpStart()->first); fs::path my_path(mPriFName); fs::ifstream objFile; objFile.open(my_path, ios::out); char line[200]; vector<string> tokens; while (objFile.getline(line, 200)) { tokens = splitSpace(string(line)); if (tokens[0] == ("g")) { // removeSpecialCharsFromName(tokens[1]); ++grpId; lastType = "g"; string longname(""); for (unsigned int i = 1; i < tokens.size(); ++i) { longname.append(tokens[i]); longname.append("_"); } longname.erase(longname.end() - 1); mPriModelPtr->setCurrentGrp(longname); //cout << _model.getCurrentGrpPtr()->name << endl; } else if (tokens[0] == ("v")) { lastType = "v"; } // moved material assignment to 2nd pass because it references a group. // But only at end of 1st pass we know our groups else if (tokens[0] == ("usemtl")) { // cout << "found material reference " << tokens[1] << " in obj-file" << endl; string longName(""); for (unsigned int i = 1; i < tokens.size(); ++i) { longName.append(tokens[i]); longName.append(" "); } longName.erase(longName.end() - 1); if (mPriMatMap.find(longName) != mPriMatMap.end()) mPriModelPtr->getCurrentGrpPtr()->setMat(*mPriMatMap[longName]); lastType = "usemtl"; } else if (tokens[0] == ("f")) { //cout << "Number of Components per face: " << tokens.size()-1 << endl; Face* f = new Face(); f->norm = false; f->vert = false; f->matIdx = 0; f->tex = 0; f->fNormal = 0; string::size_type loc = tokens[1].find("/", 0); if (loc != string::npos) { for (string::size_type i = 1; i < tokens.size(); ++i) { vector<int> comp = extractFaceComponents(tokens[i]); // vertices if ((comp[0] & 4)) { V3f* vtx = mPriModelPtr->getVPtr(comp[1] - 1); f->vertexPtrList.push_back(vtx); vtx->addFaceRef(f); f->vert = true; mPriModelPtr->getCurrentGrpPtr()->nVertices++; mPriModelPtr->incVCount(); mPriModelPtr->getCurrentGrpPtr()->bb->expand(*vtx); } // textures if ((comp[0] & 2)) { f->texturePtrList.push_back(mPriModelPtr->getTPtr( comp[2] - 1)); ++f->tex; mPriModelPtr->getCurrentGrpPtr()->nTextureCoords++; mPriModelPtr->incTCount(); } // normals if ((comp[0] & 1)) { f->normalPtrList.push_back(mPriModelPtr->getNPtr( comp[3] - 1)); f->norm = true; mPriModelPtr->getCurrentGrpPtr()->nNormals++; mPriModelPtr->incNCount(); } comp.clear(); } } else { V3f* vtx = mPriModelPtr->getVPtr(atoi(tokens[1].c_str()) - 1); f->vertexPtrList.push_back(vtx); mPriModelPtr->getCurrentGrpPtr()->bb->expand(*vtx); vtx = mPriModelPtr->getVPtr(atoi(tokens[2].c_str()) - 1); f->vertexPtrList.push_back(vtx); mPriModelPtr->getCurrentGrpPtr()->bb->expand(*vtx); vtx = mPriModelPtr->getVPtr(atoi(tokens[3].c_str()) - 1); f->vertexPtrList.push_back(vtx); mPriModelPtr->getCurrentGrpPtr()->bb->expand(*vtx); f->vert = true; mPriModelPtr->getCurrentGrpPtr()->nVertices += 3; mPriModelPtr->incVCount(3); } mPriModelPtr->addFPtrToCurrent(f); lastType = "f"; } } objFile.close(); }
void ObjModelLoader::firstPass() { string lastType = ""; fs::path my_path(mPriFName); fs::ifstream objFile; objFile.open(my_path, ios::in); char line[200]; vector<string> tokens; while (objFile.getline(line, 200)) { tokens = splitSpace(string(line)); if (tokens[0] == ("o")) { //++grpCount; lastType = "o"; } else if (tokens[0] == ("g")) { // removeSpecialCharsFromName(tokens[1]); string longname(""); for (unsigned int i = 1; i < tokens.size(); ++i) { longname.append(tokens[i]); longname.append("_"); } longname.erase(longname.end() - 1); mPriModelPtr->addGrpPtr(new MetaGroup(longname)); lastType = "g"; } else if (tokens[0] == ("mtllib")) { string longname(""); for (unsigned int i = 1; i < tokens.size(); ++i) { longname.append(tokens[i]); longname.append(" "); } longname.erase(longname.end() - 1); parseMtl(fs::path(my_path.parent_path() / longname)); lastType = "mtllib"; } else if (tokens[0] == ("v")) { V3f* v = new V3f(atof(tokens[1].c_str()), atof(tokens[2].c_str()), atof(tokens[3].c_str())); mPriModelPtr->addVPtr(v); lastType = "v"; } else if (tokens[0] == ("vt")) { V3f* t = new V3f(atof(tokens[1].c_str()), atof(tokens[2].c_str()), atof(tokens[3].c_str())); mPriModelPtr->addTPtr(t); lastType = "vt"; } else if (tokens[0] == ("vn")) { V3b *n = new V3b((char) 127.0f * atof(tokens[1].c_str()), (char) 127.0f * atof(tokens[2].c_str()), (char) 127.0f * atof(tokens[3].c_str())); mPriModelPtr->addNPtr(n); lastType = "vn"; } else if (tokens[0] == ("f")) { lastType = "f"; } } objFile.close(); // if we have not read any groups in, create a default group if (mPriModelPtr->getGrpCount() < 1) { mPriModelPtr->addGrpPtr(new MetaGroup()); } }
static void outputTest(WINDOW *win) { WINDOW *win1; char Buffer[80]; chtype ch; int by, bx; #if !HAVE_TIGETSTR #if HAVE_TGETENT char tc_buffer[4096]; char tc_parsed[4096]; char *area_pointer = tc_parsed; tgetent(tc_buffer, getenv("TERM")); #else #define tgetstr(a,b) 0 #endif #endif /* !HAVE_TIGETSTR */ nl(); wclear(win); MvWAddStr(win, 1, 1, "You should now have a screen in the upper left corner, and this text should have wrapped"); mvwin(win, 2, 1); waddstr(win, "\nThis text should be down\n"); waddstr(win, "and broken into two here ^"); Continue(win); wclear(win); wattron(win, A_BOLD); MvWAddStr(win, 1, 1, "A new window will appear with this text in it"); MvWAddStr(win, 8, 1, "Press any key to continue"); wrefresh(win); wgetch(win); getbegyx(win, by, bx); if (LINES < 24 || COLS < 75) { MvWAddStr(win, 5, 1, "Some tests have been skipped as they require a"); MvWAddStr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS"); Continue(win); } else { win1 = newwin(10, 50, 14, 25); if (win1 == NULL) { endwin(); return; } #ifdef A_COLOR if (has_colors()) { init_pair(3, COLOR_BLUE, COLOR_WHITE); wbkgd(win1, (chtype) COLOR_PAIR(3)); } else wbkgd(win1, A_NORMAL); #else wbkgd(win1, A_NORMAL); #endif wclear(win1); MvWAddStr(win1, 5, 1, "This text should appear; using overlay option"); copywin(win, win1, 0, 0, 0, 0, 9, 49, TRUE); #if defined(PDCURSES) && !defined(XCURSES) box(win1, 0xb3, 0xc4); #else box(win1, ACS_VLINE, ACS_HLINE); #endif wmove(win1, 8, 26); wrefresh(win1); wgetch(win1); wclear(win1); wattron(win1, A_BLINK); MvWAddStr(win1, 4, 1, "This blinking text should appear in only the second window"); wattroff(win1, A_BLINK); mvwin(win1, by, bx); overlay(win, win1); mvwin(win1, 14, 25); wmove(win1, 8, 26); wrefresh(win1); wgetch(win1); delwin(win1); } clear(); wclear(win); wrefresh(win); MvWAddStr(win, 6, 2, "This line shouldn't appear"); MvWAddStr(win, 4, 2, "Only half of the next line is visible"); MvWAddStr(win, 5, 2, "Only half of the next line is visible"); wmove(win, 6, 1); wclrtobot(win); wmove(win, 5, 20); wclrtoeol(win); MvWAddStr(win, 8, 2, "This line also shouldn't appear"); wmove(win, 8, 1); wdeleteln(win); Continue(win); wmove(win, 5, 9); ch = winch(win); wclear(win); wmove(win, 6, 2); waddstr(win, "The next char should be l: "); winsch(win, ch); Continue(win); #if HAVE_WINSSTR (void) mvwinsstr(win, 6, 2, "A1B2C3D4E5"); Continue(win); #endif wmove(win, 5, 1); winsertln(win); MvWAddStr(win, 5, 2, "The lines below should have moved down"); Continue(win); wclear(win); wmove(win, 2, 2); wprintw(win, "This is a formatted string in a window: %d %s\n", 42, "is it"); MvWAddStr(win, 10, 1, "Enter a string: "); wrefresh(win); noraw(); echo(); *Buffer = 0; wscanw(win, "%s", Buffer); printw("This is a formatted string in stdscr: %d %s\n", 42, "is it"); MvAddStr(10, 1, "Enter a string: "); *Buffer = 0; scanw("%s", Buffer); if (TIGETSTR("cvvis", "vs") != 0) { wclear(win); curs_set(2); MvWAddStr(win, 1, 1, "The cursor should appear as a block (visible)"); Continue(win); } if (TIGETSTR("civis", "vi") != 0) { wclear(win); curs_set(0); MvWAddStr(win, 1, 1, "The cursor should have disappeared (invisible)"); Continue(win); } if (TIGETSTR("cnorm", "ve") != 0) { wclear(win); curs_set(1); MvWAddStr(win, 1, 1, "The cursor should be an underline (normal)"); Continue(win); } #ifdef A_COLOR if (has_colors()) { wclear(win); MvWAddStr(win, 1, 1, "Colors should change after you press a key"); Continue(win); init_pair(1, COLOR_RED, COLOR_WHITE); wrefresh(win); } #endif werase(win); #if HAVE_TERMNAME MvWAddStr(win, 1, 1, "Information About Your Terminal"); MvWAddStr(win, 3, 1, termname()); MvWAddStr(win, 4, 1, longname()); if (termattrs() & A_BLINK) MvWAddStr(win, 5, 1, "This terminal supports blinking."); else MvWAddStr(win, 5, 1, "This terminal does NOT support blinking."); #endif (void) mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16); wrefresh(win); (void) mvwinnstr(win, 7, 5, Buffer, 18); MvAddStr(LINES - 2, 10, Buffer); refresh(); Continue(win); }
static int tput(int argc, char *argv[]) { NCURSES_CONST char *name; char *s; int i, j, c; int status; FILE *f; #if !PURE_TERMINFO bool termcap = FALSE; #endif if ((name = argv[0]) == 0) name = ""; check_aliases(name); if (is_reset || is_init) { if (init_prog != 0) { system(init_prog); } FLUSH; if (is_reset && reset_1string != 0) { PUTS(reset_1string); } else if (init_1string != 0) { PUTS(init_1string); } FLUSH; if (is_reset && reset_2string != 0) { PUTS(reset_2string); } else if (init_2string != 0) { PUTS(init_2string); } FLUSH; #ifdef set_lr_margin if (set_lr_margin != 0) { PUTS(TPARM_2(set_lr_margin, 0, columns - 1)); } else #endif #ifdef set_left_margin_parm if (set_left_margin_parm != 0 && set_right_margin_parm != 0) { PUTS(TPARM_1(set_left_margin_parm, 0)); PUTS(TPARM_1(set_right_margin_parm, columns - 1)); } else #endif if (clear_margins != 0 && set_left_margin != 0 && set_right_margin != 0) { PUTS(clear_margins); if (carriage_return != 0) { PUTS(carriage_return); } else { PUTCHAR('\r'); } PUTS(set_left_margin); if (parm_right_cursor) { PUTS(TPARM_1(parm_right_cursor, columns - 1)); } else { for (i = 0; i < columns - 1; i++) { PUTCHAR(' '); } } PUTS(set_right_margin); if (carriage_return != 0) { PUTS(carriage_return); } else { PUTCHAR('\r'); } } FLUSH; if (init_tabs != 8) { if (clear_all_tabs != 0 && set_tab != 0) { for (i = 0; i < columns - 1; i += 8) { if (parm_right_cursor) { PUTS(TPARM_1(parm_right_cursor, 8)); } else { for (j = 0; j < 8; j++) PUTCHAR(' '); } PUTS(set_tab); } FLUSH; } } if (is_reset && reset_file != 0) { f = fopen(reset_file, "r"); if (f == 0) { quit(4 + errno, "Can't open reset_file: '%s'", reset_file); } while ((c = fgetc(f)) != EOF) { PUTCHAR(c); } fclose(f); } else if (init_file != 0) { f = fopen(init_file, "r"); if (f == 0) { quit(4 + errno, "Can't open init_file: '%s'", init_file); } while ((c = fgetc(f)) != EOF) { PUTCHAR(c); } fclose(f); } FLUSH; if (is_reset && reset_3string != 0) { PUTS(reset_3string); } else if (init_3string != 0) { PUTS(init_3string); } FLUSH; return 0; } if (strcmp(name, "longname") == 0) { PUTS(longname()); return 0; } #if !PURE_TERMINFO retry: #endif if ((status = tigetflag(name)) != -1) { return exit_code(BOOLEAN, status); } else if ((status = tigetnum(name)) != CANCELLED_NUMERIC) { (void) printf("%d\n", status); return exit_code(NUMBER, 0); } else if ((s = tigetstr(name)) == CANCELLED_STRING) { #if !PURE_TERMINFO if (!termcap) { const struct name_table_entry *np; termcap = TRUE; if ((np = _nc_find_entry(name, _nc_get_hash_table(termcap))) != 0) { switch (np->nte_type) { case BOOLEAN: if (bool_from_termcap[np->nte_index]) name = boolnames[np->nte_index]; break; case NUMBER: if (num_from_termcap[np->nte_index]) name = numnames[np->nte_index]; break; case STRING: if (str_from_termcap[np->nte_index]) name = strnames[np->nte_index]; break; } goto retry; } } #endif quit(4, "unknown terminfo capability '%s'", name); } else if (s != ABSENT_STRING) { if (argc > 1) { int k; int popcount; long numbers[1 + NUM_PARM]; char *strings[1 + NUM_PARM]; char *p_is_s[NUM_PARM]; /* Nasty hack time. The tparm function needs to see numeric * parameters as numbers, not as pointers to their string * representations */ for (k = 1; k < argc; k++) { char *tmp = 0; strings[k] = argv[k]; numbers[k] = strtol(argv[k], &tmp, 0); if (tmp == 0 || *tmp != 0) numbers[k] = 0; } for (k = argc; k <= NUM_PARM; k++) { numbers[k] = 0; strings[k] = 0; } switch (tparm_type(name)) { case Num_Str: s = TPARM_2(s, numbers[1], strings[2]); break; case Num_Str_Str: s = TPARM_3(s, numbers[1], strings[2], strings[3]); break; case Numbers: default: (void) _nc_tparm_analyze(s, p_is_s, &popcount); #define myParam(n) (p_is_s[n - 1] != 0 ? ((TPARM_ARG) strings[n]) : numbers[n]) s = TPARM_9(s, myParam(1), myParam(2), myParam(3), myParam(4), myParam(5), myParam(6), myParam(7), myParam(8), myParam(9)); break; } } /* use putp() in order to perform padding */ putp(s); return exit_code(STRING, 0); } return exit_code(STRING, 1); }
static int tput(int argc, char *argv[]) { NCURSES_CONST char *name; char *s; int i, j, c; int status; FILE *f; check_aliases(name = argv[0]); if (is_reset || is_init) { if (init_prog != 0) { system(init_prog); } FLUSH; if (is_reset && reset_1string != 0) { PUTS(reset_1string); } else if (init_1string != 0) { PUTS(init_1string); } FLUSH; if (is_reset && reset_2string != 0) { PUTS(reset_2string); } else if (init_2string != 0) { PUTS(init_2string); } FLUSH; if (set_lr_margin != 0) { PUTS(tparm(set_lr_margin, 0, columns - 1)); } else if (set_left_margin_parm != 0 && set_right_margin_parm != 0) { PUTS(tparm(set_left_margin_parm, 0)); PUTS(tparm(set_right_margin_parm, columns - 1)); } else if (clear_margins != 0 && set_left_margin != 0 && set_right_margin != 0) { PUTS(clear_margins); if (carriage_return != 0) { PUTS(carriage_return); } else { PUTCHAR('\r'); } PUTS(set_left_margin); if (parm_right_cursor) { PUTS(tparm(parm_right_cursor, columns - 1)); } else { for (i = 0; i < columns - 1; i++) { PUTCHAR(' '); } } PUTS(set_right_margin); if (carriage_return != 0) { PUTS(carriage_return); } else { PUTCHAR('\r'); } } FLUSH; if (init_tabs != 8) { if (clear_all_tabs != 0 && set_tab != 0) { for (i = 0; i < columns - 1; i += 8) { if (parm_right_cursor) { PUTS(tparm(parm_right_cursor, 8)); } else { for (j = 0; j < 8; j++) PUTCHAR(' '); } PUTS(set_tab); } FLUSH; } } if (is_reset && reset_file != 0) { f = fopen(reset_file, "r"); if (f == 0) { quit(errno, "Can't open reset_file: '%s'", reset_file); } while ((c = fgetc(f)) != EOF) { PUTCHAR(c); } fclose(f); } else if (init_file != 0) { f = fopen(init_file, "r"); if (f == 0) { quit(errno, "Can't open init_file: '%s'", init_file); } while ((c = fgetc(f)) != EOF) { PUTCHAR(c); } fclose(f); } FLUSH; if (is_reset && reset_3string != 0) { PUTS(reset_3string); } else if (init_2string != 0) { PUTS(init_2string); } FLUSH; return 0; } if (strcmp(name, "longname") == 0) { PUTS(longname()); return 0; } #if !PURE_TERMINFO { const struct name_table_entry *np; if ((np = _nc_find_entry(name, _nc_get_hash_table(1))) != 0) switch (np->nte_type) { case BOOLEAN: if (bool_from_termcap[np->nte_index]) name = boolnames[np->nte_index]; break; case NUMBER: if (num_from_termcap[np->nte_index]) name = numnames[np->nte_index]; break; case STRING: if (str_from_termcap[np->nte_index]) name = strnames[np->nte_index]; break; } } #endif if ((status = tigetflag(name)) != -1) { return (status != 0); } else if ((status = tigetnum(name)) != CANCELLED_NUMERIC) { (void) printf("%d\n", status); return (0); } else if ((s = tigetstr(name)) == CANCELLED_STRING) { quit(4, "%s: unknown terminfo capability '%s'", prg_name, name); } else if (s != ABSENT_STRING) { if (argc > 1) { int k; int numbers[10]; char *strings[10]; /* Nasty hack time. The tparm function needs to see numeric * parameters as numbers, not as pointers to their string * representations */ for (k = 1; k < argc; k++) { char *tmp = 0; strings[k] = argv[k]; numbers[k] = strtol(argv[k], &tmp, 0); if (tmp == 0 || *tmp != 0) numbers[k] = 0; } for (k = argc; k <= 9; k++) { numbers[k] = 0; strings[k] = 0; } switch (tparm_type(name)) { case Num_Str: s = tparm(s, numbers[1], strings[2]); break; case Num_Str_Str: s = tparm(s, numbers[1], strings[2], strings[3]); break; default: s = tparm(s, numbers[1], numbers[2], numbers[3], numbers[4], numbers[5], numbers[6], numbers[7], numbers[8], numbers[9]); break; } } /* use putp() in order to perform padding */ putp(s); return (0); } return (0); }
/*** Fetch the verbose name of the terminal. @function longname @treturn string verbose description of the current terminal @see longname(3x) */ static int Plongname(lua_State *L) { return pushstringresult(longname()); }
// Wb only void rt_pvd_file::createObject( co_procom* pcom, pwr_tOix destoix, int desttype, pwr_tCid cid, char* name) { procom_obj item; if (destoix >= m_list.size()) { pcom->provideObject(LDH__NOSUCHOBJ, 0, 0, 0, 0, 0, 0, 0, "", ""); return; } if (destoix == 0 && m_list.size() == 1) { // First object item.cid = cid; item.oix = next_oix++; item.fthoix = destoix; item.fwsoix = 0; item.bwsoix = 0; item.fchoix = 0; item.lchoix = 0; m_list[0].fchoix = item.oix; } else { if (destoix >= m_list.size() || destoix <= 0) { pcom->provideObject(0, 0, 0, 0, 0, 0, 0, 0, "", ""); return; } item.cid = cid; item.oix = next_oix++; switch (desttype) { case ldh_eDest_IntoFirst: item.fthoix = destoix; item.fwsoix = m_list[item.fthoix].fchoix; item.bwsoix = 0; item.fchoix = 0; item.lchoix = 0; if (item.fwsoix != 0) m_list[item.fwsoix].bwsoix = item.oix; m_list[item.fthoix].fchoix = item.oix; if (m_list[item.fthoix].lchoix == 0) m_list[item.fthoix].lchoix = item.oix; break; case ldh_eDest_IntoLast: item.fthoix = destoix; item.bwsoix = m_list[item.fthoix].lchoix; item.fwsoix = 0; item.fchoix = 0; item.lchoix = 0; if (item.bwsoix != 0) m_list[item.bwsoix].fwsoix = item.oix; m_list[item.fthoix].lchoix = item.oix; if (m_list[item.fthoix].fchoix == 0) m_list[item.fthoix].fchoix = item.oix; break; case ldh_eDest_After: item.fthoix = m_list[destoix].fthoix; item.fwsoix = m_list[destoix].fwsoix; item.bwsoix = destoix; item.fchoix = 0; item.lchoix = 0; m_list[destoix].fwsoix = item.oix; if (item.fwsoix != 0) m_list[item.fwsoix].bwsoix = item.oix; if (item.fthoix != 0) if (m_list[item.fthoix].lchoix == destoix) m_list[item.fthoix].lchoix = item.oix; break; case ldh_eDest_Before: item.fthoix = m_list[destoix].fthoix; item.bwsoix = m_list[destoix].bwsoix; item.fwsoix = destoix; item.fchoix = 0; item.lchoix = 0; m_list[destoix].bwsoix = item.oix; if (item.bwsoix != 0) m_list[item.bwsoix].fwsoix = item.oix; if (item.fthoix != 0) if (m_list[item.fthoix].fchoix == destoix) m_list[item.fthoix].fchoix = item.oix; break; default:; } } switch (cid) { case pwr_eClass_Hier: item.body_size = sizeof(pwr_sHier); item.body = calloc(1, item.body_size); break; case pwr_cClass_VolumeReg: item.body_size = sizeof(pwr_sClass_VolumeReg); item.body = calloc(1, item.body_size); break; case pwr_cClass_SystemGroupReg: item.body_size = sizeof(pwr_sClass_SystemGroupReg); item.body = calloc(1, item.body_size); break; case pwr_cClass_UserReg: item.body_size = sizeof(pwr_sClass_UserReg); item.body = calloc(1, item.body_size); break; case pwr_cClass_ProjectReg: item.body_size = sizeof(pwr_sClass_ProjectReg); item.body = calloc(1, item.body_size); break; case pwr_cClass_BaseReg: item.body_size = sizeof(pwr_sClass_BaseReg); item.body = calloc(1, item.body_size); break; } if (streq(name, "")) sprintf(item.name, "O%d", item.oix); else strcpy(item.name, name); item.flags |= procom_obj_mFlags_Created; m_list.push_back(item); pcom->provideObject(1, item.oix, item.fthoix, item.bwsoix, item.fwsoix, item.fchoix, item.lchoix, item.cid, item.name, longname(item.oix)); }
int main(int argc, char **argv) { int i, std_argc; char *term = getenv("TERM"); char *cap, std_input = FALSE; int setuperr; (void) setlocale(LC_ALL, ""); #if !defined(TEXT_DOMAIN) #define TEXT_DOMAIN "SYS_TEST" #endif (void) textdomain(TEXT_DOMAIN); progname = argv[0]; while ((i = getopt(argc, argv, "ST:")) != EOF) { switch (i) { case 'T': fildes = -1; (void) putenv("LINES="); (void) putenv("COLUMNS="); term = optarg; break; case 'S': std_input = TRUE; break; case '?': /* FALLTHROUGH */ usage: /* FALLTHROUGH */ default: (void) fprintf(stderr, gettext( "usage:\t%s [-T [term]] capname [parm argument...]\n"), progname); (void) fprintf(stderr, gettext("OR:\t%s -S <<\n"), progname); exit(2); } } if (!term || !*term) { (void) fprintf(stderr, gettext("%s: No value for $TERM and no -T specified\n"), progname); exit(2); } (void) setupterm(term, fildes, &setuperr); switch (setuperr) { case -2: (void) fprintf(stderr, gettext("%s: unreadable terminal descriptor \"%s\"\n"), progname, term); exit(3); break; case -1: (void) fprintf(stderr, gettext("%s: no terminfo database\n"), progname); exit(3); break; case 0: (void) fprintf(stderr, gettext("%s: unknown terminal \"%s\"\n"), progname, term); exit(3); } reset_shell_mode(); /* command line arguments */ if (!std_input) { if (argc == optind) goto usage; cap = argv[optind++]; if (strcmp(cap, "init") == 0) initterm(); else if (strcmp(cap, "reset") == 0) reset_term(); else if (strcmp(cap, "longname") == 0) (void) printf("%s\n", longname()); else exit(outputcap(cap, argc, argv)); return (0); } else { /* standard input argumets */ char buff[128]; char **v; /* allocate storage for the 'faked' argv[] array */ v = (char **)malloc(10 * sizeof (char *)); for (i = 0; i < 10; i++) v[i] = (char *)malloc(32 * sizeof (char)); while (gets(buff) != NULL) { /* read standard input line; skip over empty lines */ if ((std_argc = sscanf(buff, "%s %s %s %s %s %s %s %s %s %s", v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9])) < 1) { continue; } cap = v[0]; optind = 1; if (strcmp(cap, "init") == 0) { initterm(); } else if (strcmp(cap, "reset") == 0) { reset_term(); } else if (strcmp(cap, "longname") == 0) { (void) printf("%s\n", longname()); } else { (void) outputcap(cap, std_argc, v); } (void) fflush(stdout); } return (0); } }
// Wb only void rt_pvd_file::copyObject( co_procom* pcom, pwr_tOix oix, pwr_tOix destoix, int desttype, char* name) { if (destoix >= m_list.size() || oix >= m_list.size() || oix <= 0) { pcom->provideObject(LDH__NOSUCHOBJ, 0, 0, 0, 0, 0, 0, 0, "", ""); return; } procom_obj item = m_list[oix]; item.oix = next_oix++; if (streq(name, "")) sprintf(item.name, "O%d_%s", next_oix, m_list[oix].name); else strcpy(item.name, name); // Insert in new position switch (desttype) { case ldh_eDest_IntoFirst: item.fthoix = destoix; item.fwsoix = m_list[destoix].fchoix; if (m_list[destoix].fchoix == 0) m_list[destoix].lchoix = item.oix; m_list[destoix].fchoix = item.oix; if (item.fwsoix) m_list[item.fwsoix].bwsoix = item.oix; item.bwsoix = 0; break; case ldh_eDest_IntoLast: item.fthoix = destoix; item.bwsoix = m_list[destoix].lchoix; if (m_list[destoix].fchoix == 0) m_list[destoix].fchoix = item.oix; m_list[destoix].lchoix = item.oix; if (item.bwsoix) m_list[item.bwsoix].fwsoix = item.oix; item.fwsoix = 0; break; case ldh_eDest_After: item.fthoix = m_list[destoix].fthoix; item.fwsoix = m_list[destoix].fwsoix; m_list[destoix].fwsoix = item.oix; item.bwsoix = destoix; if (m_list[item.fthoix].lchoix == destoix) m_list[item.fthoix].lchoix = item.oix; if (item.fwsoix) m_list[item.fwsoix].bwsoix = item.oix; break; case ldh_eDest_Before: item.fthoix = m_list[destoix].fthoix; item.bwsoix = m_list[destoix].bwsoix; m_list[destoix].bwsoix = item.oix; item.fwsoix = destoix; if (m_list[item.fthoix].fchoix == destoix) m_list[item.fthoix].fchoix = item.oix; if (item.bwsoix) m_list[item.bwsoix].fwsoix = item.oix; break; default:; } item.flags |= procom_obj_mFlags_Created; m_list.push_back(item); pcom->provideObject(1, item.oix, item.fthoix, item.bwsoix, item.fwsoix, item.fchoix, item.lchoix, item.cid, item.name, longname(item.oix)); }
/* Among other things, 'newtest' demonstrates how to make a Win32a PDCurses app that is a for-real, "pure Windows" version (instead of a console application). Doing this is quite easy, and has certain advantages. If the app is invoked from a command prompt, the only difference you'll see is that the app runs separately (that is, you can continue to use the command prompt, switching between it, your PDCurses/Win32a app, and other processes). Which is the main reason I did it; it meant that I could invoke a PDCurses-based text editor, for example, and still have use of the command line. (NOTE that, for reasons I don't actually understand, this happens when the Visual C++ compiler is used. With MinGW or OpenWatcom, it's still "really" a console app.) To do it, we ensure that the usual main() function has an alternative dummy_main() form, taking the same arguments as main(). We add a WinMain() function, whose sole purpose is to reformulate lpszCmdLine into argc/argv form, and pass it on to dummy_main(). And, of course, we can switch back to a "normal" console app by removing the above #define PURE_WINDOWS_VERSION line. */ #ifdef PURE_WINDOWS_VERSION #undef MOUSE_MOVED #include <windows.h> int dummy_main( int argc, char **argv); int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { char *argv[30]; int i, argc = 1; argv[0] = "newtest"; for( i = 0; lpszCmdLine[i]; i++) if( lpszCmdLine[i] != ' ' && (!i || lpszCmdLine[i - 1] == ' ')) argv[argc++] = lpszCmdLine + i; for( i = 0; lpszCmdLine[i]; i++) if( lpszCmdLine[i] == ' ') lpszCmdLine[i] = '\0'; return dummy_main( argc, (char **)argv); } int dummy_main( int argc, char **argv) #else /* "usual", console-app version: */ int main( int argc, char **argv) #endif { int quit = 0, i, use_slk = 1; int fmt = 0xa; bool blink_state = FALSE; int cursor_state_1 = 2, cursor_state_2 = 3; int show_slk_index_line = 0; int redraw = 1; unsigned extra_character_to_show = 0; #ifdef PDC_WIDE unsigned unicode_offset = 0x80; #endif /* setlocale(LC_ALL, ".utf8"); */ ttytype[0] = 25; ttytype[1] = 90; /* Allow 25 to 90 lines... */ ttytype[2] = 80; ttytype[3] = (char)200; /* ...and 80 to 200 columns */ /* (This program gets weird artifacts when smaller than 25x80.) */ for( i = 1; i < argc; i++) if( argv[i][0] == '-') switch( argv[i][1]) { case 's': use_slk = 0; break; case 'l': setlocale( LC_ALL, argv[i] + 2); break; case 'e': sscanf( argv[i] + 2, "%x", &extra_character_to_show); break; case 'f': sscanf( argv[i] + 2, "%x", (unsigned *)&fmt); break; case 'i': show_slk_index_line = 1; break; case 'r': /* allow user-resizable windows */ { int min_lines, max_lines, min_cols, max_cols; if( sscanf( argv[i] + 2, "%d,%d,%d,%d", &min_lines, &max_lines, &min_cols, &max_cols) == 4) { ttytype[0] = min_lines; ttytype[1] = max_lines; ttytype[2] = min_cols; ttytype[3] = max_cols; } } break; case 'd': /* set window size before initscr */ { int n_lines, n_cols; if( sscanf( argv[i] + 2, "%d,%d", &n_lines, &n_cols) == 2) resize_term( n_lines, n_cols); } break; #ifdef PDC_WIDE case 'u': sscanf( argv[i] + 2, "%x", &unicode_offset); break; #endif default: printf( "Option '%s' unrecognized\n", argv[i]); break; } if( use_slk) slk_init( show_slk_index_line ? 3 : 0); Xinitscr(argc, argv); if( use_slk) slk_setup( show_slk_index_line ? -fmt : fmt); start_color(); # if defined(NCURSES_VERSION) || (defined(PDC_BUILD) && PDC_BUILD > 3000) use_default_colors(); # endif cbreak(); noecho(); clear(); refresh(); #ifdef __PDCURSES__ PDC_set_title( "NewTest: tests various PDCurses features"); #endif keypad( stdscr, TRUE); init_pair( 1, 15, COLOR_BLACK); init_pair( 2, COLOR_BLACK, COLOR_YELLOW); mousemask( ALL_MOUSE_EVENTS, NULL); attrset( COLOR_PAIR( 1)); while( !quit) { char buff[80]; const int xmax = getmaxx( stdscr); const int ymax = getmaxy( stdscr); int color_block_start = 54, c; int color_block_cols = (xmax - color_block_start) / 2; const int color_block_lines = 19; const char *cursor_state_text[N_CURSORS] = { "Invisible (click to change) ", "Underscore (click to change)", "Block (click to change) ", "Outline (click to change) ", "Caret (click to change) ", "Half-block (click to change)", "Central (click to change) ", "Cross (click to change) ", "Heavy box (click to change) " }; if( color_block_cols < 0) color_block_cols = 0; if( redraw) { mvaddstr( 1, COL1, "'Normal' white-on-black"); mvaddstr( 2, COL1, longname( )); #if(CHTYPE_LONG >= 2) /* "non-standard" 64-bit chtypes */ attron( A_DIM); mvaddstr( 15, 41, "Dimmed text"); attroff( A_DIM); #endif #ifdef PDC_WIDE mvaddwstr( 3, COL1, L"'Normal' text, but wide"); #endif attron( A_BLINK); mvaddstr( 6, 40, "Blinking"); attron( A_BOLD); mvaddstr( 8, 40, "BlinkBold"); attron( A_ITALIC); mvaddstr( 0, COL2, "BlinkBoldItalic"); attrset( COLOR_PAIR( 3)); attron( A_UNDERLINE); #ifdef PDC_WIDE mvaddstr( 1, COL2, "Underlined"); addwstr( L"WideUnder"); #endif attrset( COLOR_PAIR( 1)); attron( A_UNDERLINE | A_ITALIC); mvaddstr( 2, COL2, "UnderlinedItalic"); attrset( COLOR_PAIR( 2)); attron( A_BLINK); mvaddstr( 4, COL1, "Black-on-yellow blinking"); attrset( COLOR_PAIR( 1)); move( 4, COL2); text_in_a_box( "Text in a box"); #ifdef CHTYPE_LONG attrset( COLOR_PAIR( 6)); attron( A_STRIKEOUT); mvaddstr( 10, 40, "Strikeout"); attrset( COLOR_PAIR( 1)); #endif #ifdef PDC_WIDE move( 11, 40); text_in_a_box( "Next Ucode pg"); if( unicode_offset) { move( 12, 40); text_in_a_box( "Prev Ucode pg"); } mvprintw( 13, 40, "U+%04x ", unicode_offset); #endif for( i = 0; i < 128; i++) { /* Show extended characters: */ #ifdef PDC_WIDE wchar_t buff[20]; swprintf( buff, 20, L"%02x ", (unsigned)( i + unicode_offset) & 0xff); mvaddwstr( 5 + i % 16, (i / 16) * 5, buff); if( i + unicode_offset > ' ') addch( (chtype)( i + unicode_offset)); else addch( ' '); addch( ' '); #else char buff[6]; sprintf( buff, "%02x %c", i + 128, (char)(i + 128)); mvaddstr( 5 + i % 16, (i / 16) * 5, buff); #endif } #if(CHTYPE_LONG >= 2) /* "non-standard" 64-bit chtypes */ for( i = 0; i < 3 && i + 21 < ymax; i++) { /* Demonstrate full RGB color control: */ int j; const char *output_text[3] = { "Red on green to white on black | (you can get full RGB colors when desired,", "Blue on yellow to black on red | with palette coloring still being available)", "White on red to green on blue, underlined and italic" }; const int len = (int)strlen( output_text[i]); move( 21 + i, 1); for( j = 0; j < len && j + 1 < xmax; j++) { attr_t output_color; const int oval = j * 31 / len; const int reverse = 31 - oval; if( !i) output_color = A_RGB( 31, oval, oval, 0, reverse, 0); else if( i == 1) output_color = A_RGB( 0, 0, reverse, 31, reverse, 0); else { output_color = A_RGB( reverse, 31, reverse, reverse, 0, oval); output_color |= A_UNDERLINE | A_ITALIC; } attrset( output_color); addch( output_text[i][j]); } } #endif /* #if(CHTYPE_LONG >= 2) */ redraw = 0; attrset( COLOR_PAIR( 1)); if( extra_character_to_show && ymax > 23) mvaddch( 23, 63, (chtype)extra_character_to_show); #ifdef PDC_WIDE for( i = 0; i < 6; i++) { static const wchar_t spanish[] = L"Espa\xf1ol"; const int line = 24 + i / 3; const int col = 5 + 25 * (i % 3); static const wchar_t russian[] = {0x0420, 0x0443, 0x0441, 0x0441, 0x043a, 0x0438, 0x0439, L' ', 0x044f, 0x0437, 0x044b, 0x043a, 0}; static const wchar_t greek[] = {0x0395, 0x03bb, 0x03bb, 0x03b7, 0x03bd, 0x03b9, 0x03ba, 0x03ac, 0}; static const wchar_t georgian[] = {0x10e5, 0x10d0, 0x10e0, 0x10d7, 0x10e3, 0x10da, 0x10d8, L' ', 0x10d4, 0x10dc, 0x10d0, 0}; static const wchar_t fullwidth[] = { 0xff26, 0xff55, 0xff4c, 0xff4c, 0xff57, 0xff49, 0xff44, 0xff54, 0xff48, 0 }; /* "Fullwidth" */ static const wchar_t combining_marks[] = { L'C', L'o', 0x35c, L'm', L'b', 0x30a, L'i', L'n', L'i', 0x304, L'n', 0x30b, 0x329, L'g', 0x310, L' ', L'C', 0x338, L'h', 0x306, L'a', 0x361, L'r', L's', 0x30e, 0x348, 0 }; static const wchar_t *texts[6] = { spanish, russian, greek, georgian, fullwidth, combining_marks}; if( line < ymax && col < xmax) mvaddnwstr( line, 5 + 25 * (i % 3), texts[i], xmax - col); } #endif #ifdef MAYBE_TRY_THIS_SOMEWHERE_ELSE mvaddstr( 1, COL3, "Click on cursor descriptions to"); mvaddstr( 2, COL3, "cycle through possible cursors"); mvaddstr( 3, COL3, "Click on colors at left to change"); mvaddstr( 4, COL3, "colors used for under/over/outlining"); mvaddstr( 5, COL3, "Click 'Blink' at bottom to toggle"); mvaddstr( 6, COL3, "'real' blinking vs. 'highlit' blink"); #endif } mvaddnstr( 19, color_block_start, cursor_state_text[cursor_state_1], xmax - color_block_start); mvaddnstr( 20, color_block_start, cursor_state_text[cursor_state_2], xmax - color_block_start); curs_set( (cursor_state_1 << 8) | cursor_state_2); for( i = 0; i < color_block_cols * color_block_lines; i++) { const int n_color_blocks = (COLOR_PAIRS < 256 ? COLOR_PAIRS : 256); attrset( COLOR_PAIR( i >= n_color_blocks ? 2 : i)); if( i > 2 && i < n_color_blocks) init_pair((short)i, (short)i, COLOR_BLACK); if( !(i % color_block_cols)) move( i / color_block_cols, color_block_start); attron( A_REVERSE); addstr( " "); } move( 19, color_block_start - 3); refresh(); c = getch( ); attrset( COLOR_PAIR( 1)); if( c == KEY_RESIZE) { redraw = 1; resize_term( 0, 0); } else if( c == KEY_F(1) || c == 27) quit = 1; else if( c == KEY_F(2)) { blink_state ^= 1; PDC_set_blink( blink_state); } else if( c == KEY_F(3)) /* toggle SLKs */ { use_slk ^= 1; if( use_slk) slk_restore( ); else slk_clear( ); } else if( c >= KEY_F(4) && c < KEY_F(12)) { sscanf( labels[c - KEY_F(1)], "%x", (unsigned *)&fmt); if( use_slk) slk_setup( show_slk_index_line ? -fmt : fmt); } if( c != KEY_MOUSE) { sprintf( buff, "Key %s", keyname( c)); if( !memcmp( buff + 4, "UNKNOWN", 7)) sprintf( buff + 11, " (%x)", c); strcat( buff, " hit "); buff[COL2 - COL1] = '\0'; mvaddstr( 0, COL1, buff); } else { MEVENT mouse_event; #ifdef __PDCURSES__ nc_getmouse( &mouse_event); #else getmouse( &mouse_event); #endif sprintf( buff, "Mouse at %d x %d: %x ", mouse_event.x, mouse_event.y, (unsigned)mouse_event.bstate); mvaddstr( 0, COL1, buff); if( mouse_event.x >= color_block_start && mouse_event.y < color_block_lines) { int new_color = (mouse_event.x - color_block_start) / 2 + mouse_event.y * color_block_cols; if( new_color >= 256) new_color = -1; PDC_set_line_color( (short)new_color); } else if( mouse_event.x >= color_block_start) { int shift = ((mouse_event.bstate & BUTTON_MODIFIER_SHIFT) ? N_CURSORS - 1 : 1); if( mouse_event.y == 19) /* blink/non-blink toggle */ cursor_state_1 = (cursor_state_1 + shift) % N_CURSORS; else if( mouse_event.y == 20) /* cycle cursor state */ cursor_state_2 = (cursor_state_2 + shift) % N_CURSORS; } #ifdef PDC_WIDE else if( mouse_event.x >= 40 && mouse_event.x < 40 + 10) { if( mouse_event.y == 11) { redraw = 1; unicode_offset += 0x80; } else if( mouse_event.y == 12 && unicode_offset) { redraw = 1; unicode_offset -= 0x80; } } #endif } } endwin(); return 0; }
void outputTest(WINDOW *win) { WINDOW *win1; char Buffer[80]; chtype ch; int by, bx; nl(); wclear(win); mvwaddstr(win, 1, 1, "You should now have a screen in the upper " "left corner, and this text should have wrapped"); waddstr(win,"\nThis text should be down\n"); waddstr(win, "and broken into two here ^"); Continue(win); wclear(win); wattron(win, A_BOLD); mvwaddstr(win, 1, 1, "A new window will appear with this text in it"); mvwaddstr(win, 8, 1, "Press any key to continue"); wrefresh(win); wgetch(win); getbegyx(win, by, bx); if (LINES < 24 || COLS < 75) { mvwaddstr(win, 5, 1, "Some tests have been skipped as they require a"); mvwaddstr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS"); Continue(win); } else { win1 = newwin(10, 50, 14, 25); if (win1 == NULL) { endwin(); return; } #ifdef A_COLOR if (has_colors()) { init_pair(3, COLOR_BLUE, COLOR_WHITE); wbkgd(win1, COLOR_PAIR(3)); } else #endif wbkgd(win1, A_NORMAL); wclear(win1); mvwaddstr(win1, 5, 1, "This text should appear; using overlay option"); copywin(win, win1, 0, 0, 0, 0, 9, 49, TRUE); box(win1, ACS_VLINE, ACS_HLINE); wmove(win1, 8, 26); wrefresh(win1); wgetch(win1); wclear(win1); wattron(win1, A_BLINK); mvwaddstr(win1, 4, 1, "This blinking text should appear in only the second window"); wattroff(win1, A_BLINK); mvwin(win1, by, bx); overlay(win, win1); mvwin(win1, 14, 25); wmove(win1, 8, 26); wrefresh(win1); wgetch(win1); delwin(win1); } clear(); wclear(win); wrefresh(win); mvwaddstr(win, 6, 2, "This line shouldn't appear"); mvwaddstr(win, 4, 2, "Only half of the next line is visible"); mvwaddstr(win, 5, 2, "Only half of the next line is visible"); wmove(win, 6, 1); wclrtobot(win); wmove(win, 5, 20); wclrtoeol(win); mvwaddstr(win, 8, 2, "This line also shouldn't appear"); wmove(win, 8, 1); winsdelln(win, -1); Continue(win); wmove(win, 5, 9); ch = winch(win); wclear(win); wmove(win, 6, 2); waddstr(win, "The next char should be l: "); winsch(win, ch); Continue(win); mvwinsstr(win, 6, 2, "A1B2C3D4E5"); Continue(win); wmove(win, 5, 1); winsdelln(win, 1); mvwaddstr(win, 5, 2, "The lines below should have moved down"); Continue(win); wclear(win); wmove(win, 2, 2); wprintw(win, "This is a formatted string in a window: %d %s\n", 42, "is it"); mvwaddstr(win, 10, 1, "Enter a string: "); wrefresh(win); echo(); wscanw(win, "%s", Buffer); printw("This is a formatted string in stdscr: %d %s\n", 42, "is it"); mvaddstr(10, 1, "Enter a string: "); scanw("%s", Buffer); wclear(win); curs_set(2); mvwaddstr(win, 1, 1, "The cursor should be in high-visibility mode"); Continue(win); wclear(win); curs_set(0); mvwaddstr(win, 1, 1, "The cursor should have disappeared"); Continue(win); wclear(win); curs_set(1); mvwaddstr(win, 1, 1, "The cursor should be normal"); Continue(win); #ifdef A_COLOR if (has_colors()) { wclear(win); mvwaddstr(win, 1, 1, "Colors should change after you press a key"); Continue(win); init_pair(1, COLOR_RED, COLOR_WHITE); wrefresh(win); } #endif werase(win); mvwaddstr(win, 1, 1, "Information About Your Terminal"); mvwaddstr(win, 3, 1, termname()); mvwaddstr(win, 4, 1, longname()); if (termattrs() & A_BLINK) mvwaddstr(win, 5, 1, "This terminal claims to support blinking."); else mvwaddstr(win, 5, 1, "This terminal does NOT support blinking."); mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16); wrefresh(win); mvwinnstr(win, 7, 5, Buffer, 18); mvaddstr(LINES - 2, 10, Buffer); refresh(); Continue(win); }
NCURSES_SP_NAME(longname) (NCURSES_SP_DCL0) { (void) SP_PARM; return longname(); }