whline(WINDOW *win, chtype ch, int n) { int code = ERR; NCURSES_SIZE_T start; NCURSES_SIZE_T end; T((T_CALLED("whline(%p,%s,%d)"), win, _tracechtype(ch), n)); if (win) { struct ldat *line = &(win->_line[win->_cury]); NCURSES_CH_T wch; start = win->_curx; end = start + n - 1; if (end > win->_maxx) end = win->_maxx; CHANGED_RANGE(line, start, end); if (ch == 0) SetChar(wch, ChCharOf(ACS_HLINE), ChAttrOf(ACS_HLINE)); else SetChar(wch, ChCharOf(ch), ChAttrOf(ch)); wch = _nc_render(win, wch); while (end >= start) { line->text[end] = wch; end--; } _nc_synchook(win); code = OK; } returnCode(code); }
int PathArray::GetMultiPath(void *multi_path, int max_len, const void *separator, const void *escape_char) { void *buf = multi_path; void *FMT_STRSTR_V = IS_WINNT_V ? (void *)L"%s%s" : (void *)"%s%s"; int sep_len = strlenV(separator); int total_len = 0; int escape_val = escape_char ? GetChar(escape_char, 0) : 0; for (int i=0; i < num; i++) { BOOL is_escape = escape_val && strchrV(pathArray[i]->path, escape_val); int need_len = pathArray[i]->len + 1 + (is_escape ? 2 : 0) + (i ? sep_len : 0); if (max_len - total_len < need_len) { SetChar(multi_path, total_len, 0); return -1; } if (i) { memcpy(MakeAddr(buf, total_len), separator, sep_len * CHAR_LEN_V); total_len += sep_len; } if (is_escape) { SetChar(buf, total_len, '"'); total_len++; } memcpy(MakeAddr(buf, total_len), pathArray[i]->path, pathArray[i]->len * CHAR_LEN_V); total_len += pathArray[i]->len; if (is_escape) { SetChar(buf, total_len, '"'); total_len++; } } SetChar(multi_path, total_len, 0); return total_len; }
void TestApp::UpdateF(float deltaTime) { SetChar(mObj1XOld, mObj1YOld, L' '); SetChar(mObj1X, mObj1Y, L'O'); mObj1XOld = mObj1X; mObj1YOld = mObj1Y; //----------------------------- SetChar(mObj2X, mObj2Y, L' '); if (mDirection) { mObj2X++; if (mObj2X == 40) mDirection = false; } else { mObj2X--; if (mObj2X == 10) mDirection = true; } SetChar(mObj2X, mObj2Y, L'F'); }
wvline(WINDOW *win, chtype ch, int n) { int code = ERR; NCURSES_SIZE_T row, col; NCURSES_SIZE_T end; T((T_CALLED("wvline(%p,%s,%d)"), win, _tracechtype(ch), n)); if (win) { NCURSES_CH_T wch; row = win->_cury; col = win->_curx; end = row + n - 1; if (end > win->_maxy) end = win->_maxy; if (ch == 0) SetChar(wch, ChCharOf(ACS_VLINE), ChAttrOf(ACS_VLINE)); else SetChar(wch, ChCharOf(ch), ChAttrOf(ch)); wch = _nc_render(win, wch); while (end >= row) { struct ldat *line = &(win->_line[end]); line->text[col] = wch; CHANGED_CELL(line, col); end--; } _nc_synchook(win); code = OK; } returnCode(code); }
PyrObject* ConvertOSCMessage(int inSize, char *inData) { char *cmdName = inData; int cmdNameLen = OSCstrlen(cmdName); sc_msg_iter msg(inSize - cmdNameLen, inData + cmdNameLen); int numElems; if (inSize == cmdNameLen) { numElems = 0; } else { if (!msg.tags) { numElems = 0; error("OSC messages must have type tags. %s\n", cmdName); } else { numElems = strlen(msg.tags); } } //post("tags %s %d\n", msg.tags, numElems); VMGlobals *g = gMainVMGlobals; PyrObject *obj = newPyrArray(g->gc, numElems + 1, 0, false); PyrSlot *slots = obj->slots; SetSymbol(slots+0, getsym(cmdName)); for (int i=0; i<numElems; ++i) { char tag = msg.nextTag(); //post("%d %c\n", i, tag); switch (tag) { case 'i' : SetInt(slots+i+1, msg.geti()); break; case 'f' : SetFloat(slots+i+1, msg.getf()); break; case 'd' : SetFloat(slots+i+1, msg.getd()); break; case 's' : SetSymbol(slots+i+1, getsym(msg.gets())); //post("sym '%s'\n", slots[i+1].us->name); break; case 'b' : SetObject(slots+i+1, (PyrObject*)MsgToInt8Array(msg)); break; case 'c': SetChar(slots+i+1, (char)msg.geti()); break; // else add the type tag as a char (jrhb 2009) default: SetChar(slots+i+1, tag); msg.gets(); } } obj->size = numElems + 1; return obj; }
/* 親ディレクトリ取得(必ずフルパスであること。UNC対応) */ BOOL GetParentDirV(const void *srcfile, void *dir) { WCHAR path[MAX_PATH], *fname=NULL; if (GetFullPathNameV(srcfile, MAX_PATH, path, (void **)&fname) == 0 || fname == NULL) return strcpyV(dir, srcfile), FALSE; if (((char *)fname - (char *)path) > 3 * CHAR_LEN_V || GetChar(path, 1) != ':') SetChar(fname, -1, 0); else SetChar(fname, 0, 0); // C:\ の場合 strcpyV(dir, path); return TRUE; }
waddnstr(WINDOW *win, const char *astr, int n) { const char *str = astr; int code = ERR; T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbufn(astr, n), n)); if (win && (str != 0)) { TR(TRACE_VIRTPUT | TRACE_ATTRS, ("... current %s", _traceattr(win->_attrs))); code = OK; if (n < 0) n = (int) strlen(astr); TR(TRACE_VIRTPUT, ("str is not null, length = %d", n)); while ((n-- > 0) && (*str != '\0')) { NCURSES_CH_T ch; TR(TRACE_VIRTPUT, ("*str = %#o", UChar(*str))); SetChar(ch, UChar(*str++), A_NORMAL); if (_nc_waddch_nosync(win, ch) == ERR) { code = ERR; break; } } _nc_synchook(win); } TR(TRACE_VIRTPUT, ("waddnstr returns %d", code)); returnCode(code); }
waddnwstr(WINDOW *win, const wchar_t *str, int n) { int code = ERR; T((T_CALLED("waddnwstr(%p,%s,%d)"), win, _nc_viswbufn(str, n), n)); if (win && (str != 0)) { TR(TRACE_VIRTPUT | TRACE_ATTRS, ("... current %s", _traceattr(win->_attrs))); code = OK; if (n < 0) n = (int) wcslen(str); TR(TRACE_VIRTPUT, ("str is not null, length = %d", n)); while ((n-- > 0) && (*str != L('\0'))) { NCURSES_CH_T ch; TR(TRACE_VIRTPUT, ("*str[0] = %#lx", (unsigned long) *str)); SetChar(ch, *str++, A_NORMAL); if (wadd_wch(win, &ch) == ERR) { code = ERR; break; } } _nc_synchook(win); } TR(TRACE_VIRTPUT, ("waddnwstr returns %d", code)); returnCode(code); }
NCURSES_SP_NAME(newpad) (NCURSES_SP_DCLx int l, int c) { WINDOW *win; NCURSES_CH_T *ptr; int i; T((T_CALLED("newpad(%p,%d, %d)"), (void *) SP_PARM, l, c)); if (l <= 0 || c <= 0) returnWin(0); win = NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_ARGx l, c, 0, 0, _ISPAD); if (win == NULL) returnWin(0); for (i = 0; i < l; i++) { if_USE_SCROLL_HINTS(win->_line[i].oldindex = _NEWINDEX); if ((win->_line[i].text = typeCalloc(NCURSES_CH_T, ((size_t) c))) == 0) { (void) _nc_freewin(win); returnWin(0); } for (ptr = win->_line[i].text; ptr < win->_line[i].text + c; ptr++) SetChar(*ptr, BLANK_TEXT, BLANK_ATTR); } returnWin(win); }
void MyTweener::AddChar(char* var, char startvalue, char endvalue, double tweentime, MyTweenType tweentype, double delay, bool updatewhiledelayed, unsigned int id) { TweenChar* pVar = MyNew TweenChar; m_ListOfVars.Add( (TweenVar*)pVar ); SetChar( m_ListOfVars.Count()-1, var, startvalue, endvalue, tweentime, tweentype, delay, updatewhiledelayed, id ); }
BOOL ConvertToX86Dir(void *target) { WCHAR buf[MAX_PATH]; WCHAR buf86[MAX_PATH]; int len; if (!TSHGetSpecialFolderPathV(NULL, buf, CSIDL_PROGRAM_FILES, FALSE)) return FALSE; len = strlenV(buf); SetChar(buf, len++, '\\'); SetChar(buf, len, 0); if (strnicmpV(buf, target, len)) return FALSE; if (!TSHGetSpecialFolderPathV(NULL, buf86, CSIDL_PROGRAM_FILESX86, FALSE)) return FALSE; MakePathV(buf, buf86, MakeAddr(target, len)); strcpyV(target, buf); return TRUE; }
VOID CPokemonCodec::CreatePokemon(WORD wBreed, DWORD dwLang, BYTE bGameVersion) { if(m_pPokemon == NULL || m_bEncoded) return; ZeroMemory(m_pPokemon->rgInfo, sizeof(m_pPokemon->rgInfo)); // char SetChar(GenLongRandom()); // id SetID(GenLongRandom()); // nick name if(dwLang != lang_jp && dwLang != lang_en) dwLang = m_dwLang; if(dwLang == lang_en) { m_pPokemon->Header.bNickNameLanguage = 0x02; FillMemory(m_pPokemon->Header.bNickName, POKEMON_NICK_NAME_SIZE, 0xFF); FillMemory(m_pPokemon->Header.bCatcherName, POKEMON_TRAINER_NAME_SIZE, 0xFF); } else { m_pPokemon->Header.bNickNameLanguage = 0x01; FillMemory(m_pPokemon->Header.bNickName, 6, 0xFF); FillMemory(m_pPokemon->Header.bNickName + 6, POKEMON_NICK_NAME_SIZE - 6, 0x00); FillMemory(m_pPokemon->Header.bCatcherName, 5, 0xFF); FillMemory(m_pPokemon->Header.bCatcherName + 5, POKEMON_TRAINER_NAME_SIZE - 5, 0x00); } // bad egg m_pPokemon->Header.bBadEgg = 0x02; // unk0 *(LPWORD)(m_pPokemon->Header.unk0) = 0; // wBreed m_pBreedInfo->wBreed = wBreed; // bCatchPlace if(bGameVersion == pm_ruby || bGameVersion == pm_sapphire) { m_pInnateInfo->bCatchPlace = 0x55; } else { m_pInnateInfo->bCatchPlace = 0xFF; // うんめいてきな } // bCatchLevel m_pInnateInfo->bCatchLevel = 0x00; // 0x00 means the pokemon comes from an egg, the game considers 0x00 to be 0x05 // Game Version m_pInnateInfo->bGameVersion = min(bGameVersion, 0x0F); // bPokeball m_pInnateInfo->bPokeBall = 0xB; // ゴージャスボール // bObedience SetObedience(); }
void LabelHide(Label const label) { int column = label->column; char const* text = label->text; while(*text) { SetChar(label->area, label->row, column, ' '); ++column; ++text; } }
BOOL GetRootDirV(const void *path, void *root_dir) { if (GetChar(path, 0) == '\\') { // "\\server\volname\" 4つ目の \ を見つける DWORD ch; int backslash_cnt = 0, offset; for (offset=0; (ch = GetChar(path, offset)) != 0 && backslash_cnt < 4; offset++) { if (ch == '\\') backslash_cnt++; } memcpy(root_dir, path, offset * CHAR_LEN_V); if (backslash_cnt < 4) // 4つの \ がない場合は、末尾に \ を付与 SetChar(root_dir, offset++, '\\'); // (\\server\volume など) SetChar(root_dir, offset, 0); // NULL terminate } else { // "C:\" 等 memcpy(root_dir, path, 3 * CHAR_LEN_V); SetChar(root_dir, 3, 0); // NULL terminate } return TRUE; }
static NCURSES_INLINE void #endif wbkgrndset(WINDOW *win, const ARG_CH_T ch) { T((T_CALLED("wbkgdset(%p,%s)"), (void *) win, _tracech_t(ch))); if (win) { attr_t off = AttrOf(win->_nc_bkgd); attr_t on = AttrOf(CHDEREF(ch)); toggle_attr_off(WINDOW_ATTRS(win), off); toggle_attr_on(WINDOW_ATTRS(win), on); #if NCURSES_EXT_COLORS { int pair; if ((pair = GetPair(win->_nc_bkgd)) != 0) SET_WINDOW_PAIR(win, 0); if ((pair = GetPair(CHDEREF(ch))) != 0) SET_WINDOW_PAIR(win, pair); } #endif if (CharOf(CHDEREF(ch)) == L('\0')) { SetChar(win->_nc_bkgd, BLANK_TEXT, AttrOf(CHDEREF(ch))); if_EXT_COLORS(SetPair(win->_nc_bkgd, GetPair(CHDEREF(ch)))); } else { win->_nc_bkgd = CHDEREF(ch); } #if USE_WIDEC_SUPPORT /* * If we're compiled for wide-character support, _bkgrnd is the * preferred location for the background information since it stores * more than _bkgd. Update _bkgd each time we modify _bkgrnd, so the * macro getbkgd() will work. */ { cchar_t wch; int tmp; (void) wgetbkgrnd(win, &wch); tmp = _nc_to_char((wint_t) CharOf(wch)); win->_bkgd = (((tmp == EOF) ? ' ' : (chtype) tmp) | (AttrOf(wch) & ALL_BUT_COLOR) | ColorPair(GET_WINDOW_PAIR(win))); } #endif } returnVoid; }
LetterDisplayAnimation::LetterDisplayAnimation(TextureFont* font, MetaballGrid* metaballGrid,MetaballManager2D* metaballMgr2D, char c,IvVector3& start, IvVector3& end, unsigned int duration):LetterDisplay(font) { mMetaballGrid = metaballGrid; mMetaballGrid->AddObject(mID,mID,start); mMetaballMgr2D = metaballMgr2D; Init(); SetChar(c); mStartPos = start; mEndPos = end; mDuration = duration; }
int processchar(int c) { PyrSlot slot; PyrSlotNode *node; #if DEBUGLEX if (gDebugLexer) postfl("processhex: '%c'\n",c); #endif SetChar(&slot, c); node = newPyrSlotNode(&slot); zzval = (long)node; return ASCII; }
/********************************************************************** * Purpose: Sets a length of characters equal to a string, beginning at a specified coordinate. * * Precondition: * None * * Postcondition: * cString set at location. * ************************************************************************/ void ScreenBuffer::SetcString(int r, int c, wchar_t * a, WORD p) { if (_origin_r + _offset_r + r < 0 || _origin_c + _offset_c + c < 0) throw Exception("Coordinate must not lie outside of boundary!"); if (_origin_r + _offset_r + r > SB_HEIGHT - 1 || _origin_c + _offset_c + c > SB_WIDTH - 1) throw Exception("Coordinate must not lie outside of boundary!"); if (_origin_c + _offset_c + c + wcslen(a) > SB_WIDTH - 1) throw Exception("cString size must not exceed horizontal boundary!"); for (int i = 0; i < wcslen(a); ++i) SetChar(r, c + i, a[i], p); }
_nc_build_wch(WINDOW *win, ARG_CH_T ch) { char *buffer = WINDOW_EXT(win, addch_work); int len; int x = win->_curx; int y = win->_cury; mbstate_t state; wchar_t result; if ((WINDOW_EXT(win, addch_used) != 0) && (WINDOW_EXT(win, addch_x) != x || WINDOW_EXT(win, addch_y) != y)) { /* discard the incomplete multibyte character */ WINDOW_EXT(win, addch_used) = 0; TR(TRACE_VIRTPUT, ("Alert discarded multibyte on move (%d,%d) -> (%d,%d)", WINDOW_EXT(win, addch_y), WINDOW_EXT(win, addch_x), y, x)); } WINDOW_EXT(win, addch_x) = x; WINDOW_EXT(win, addch_y) = y; init_mb(state); buffer[WINDOW_EXT(win, addch_used)] = (char) CharOf(CHDEREF(ch)); WINDOW_EXT(win, addch_used) += 1; buffer[WINDOW_EXT(win, addch_used)] = '\0'; if ((len = (int) mbrtowc(&result, buffer, (size_t) WINDOW_EXT(win, addch_used), &state)) > 0) { attr_t attrs = AttrOf(CHDEREF(ch)); if_EXT_COLORS(int pair = GetPair(CHDEREF(ch))); SetChar(CHDEREF(ch), result, attrs); if_EXT_COLORS(SetPair(CHDEREF(ch), pair)); WINDOW_EXT(win, addch_used) = 0; } else if (len == -1) { /* * An error occurred. We could either discard everything, * or assume that the error was in the previous input. * Try the latter. */ TR(TRACE_VIRTPUT, ("Alert! mbrtowc returns error")); /* handle this with unctrl() */ WINDOW_EXT(win, addch_used) = 0; } return len; }
BaseApp::BaseApp(int xSize, int ySize) : X_SIZE(xSize), Y_SIZE(ySize) { SMALL_RECT windowSize = {0, 0, X_SIZE, Y_SIZE}; COORD windowBufSize = {X_SIZE+1, Y_SIZE+1}; mConsole = GetStdHandle(STD_OUTPUT_HANDLE); mConsoleIn = GetStdHandle(STD_INPUT_HANDLE); if(!SetConsoleScreenBufferSize(mConsole, windowBufSize)) { cout << "SetConsoleScreenBufferSize failed with error " << GetLastError() << endl; } if(!SetConsoleWindowInfo(mConsole, TRUE, &windowSize)) { cout << "SetConsoleWindowInfo failed with error " << GetLastError() << endl; } CONSOLE_CURSOR_INFO cursorInfo; GetConsoleCursorInfo(mConsole, &cursorInfo); cursorInfo.bVisible = FALSE; cursorInfo.dwSize = 1; SetConsoleCursorInfo(mConsole, &cursorInfo); mChiBuffer = (CHAR_INFO*)malloc((X_SIZE+1)*(Y_SIZE+1)*sizeof(CHAR_INFO)); mDwBufferSize.X = X_SIZE + 1; mDwBufferSize.Y = Y_SIZE + 1; // размер буфера данных mDwBufferCoord.X = 0; mDwBufferCoord.Y = 0; // координаты ¤чейки mLpWriteRegion.Left = 0; mLpWriteRegion.Top = 0; mLpWriteRegion.Right = X_SIZE + 1; mLpWriteRegion.Bottom = Y_SIZE + 1; // пр¤моугольник дл¤ чтени¤ for (int x=0; x<X_SIZE+1; x++) { for (int y=0; y<Y_SIZE+1; y++) { SetChar(x, y, ' '); } } }
BOOL TInstDlg::RunAsAdmin(BOOL is_imme) { SHELLEXECUTEINFOW sei = {0}; WCHAR buf[MAX_PATH * 2]; WCHAR exe_path[MAX_PATH]; WCHAR setup_path[MAX_PATH]; WCHAR app_data[MAX_PATH]; WCHAR virtual_store[MAX_PATH]; WCHAR fastcopy_dir[MAX_PATH]; WCHAR *fastcopy_dirname = NULL; int len; ::GetModuleFileNameW(NULL, exe_path, sizeof(exe_path)); if (!(len = GetDlgItemTextV(FILE_EDIT, setup_path, MAX_PATH))) return FALSE; if (GetChar(setup_path, len-1) == '\\') SetChar(setup_path, len-1, 0); if (!GetFullPathNameW(setup_path, MAX_PATH, fastcopy_dir, &fastcopy_dirname)) return FALSE; if (!TSHGetSpecialFolderPathV(NULL, buf, CSIDL_APPDATA, FALSE)) return FALSE; MakePathV(app_data, buf, fastcopy_dirname); strcpyV(buf, fastcopy_dir); #ifdef _WIN64 ConvertToX86Dir(buf); #endif if (!TMakeVirtualStorePathV(buf, virtual_store)) return FALSE; sprintfV(buf, L"/runas=%p,%d,%d,%d,%d,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"", hWnd, cfg.mode, is_imme, cfg.programLink, cfg.desktopLink, cfg.startMenu, cfg.deskTop, setup_path, app_data, virtual_store); sei.cbSize = sizeof(SHELLEXECUTEINFO); sei.lpVerb = L"runas"; sei.lpFile = exe_path; sei.lpDirectory = NULL; sei.nShow = SW_NORMAL; sei.lpParameters = buf; EnableWindow(FALSE); BOOL ret = ::ShellExecuteExW(&sei); EnableWindow(TRUE); return ret; }
void CScrollBufL2::SetInsertionCol(int nCol) { long nInsertionLine; long nTmp; m_nInsertionCol = nCol; BoundsCheckCol(&m_nInsertionCol, m_bWrap); nInsertionLine = GetInsertionLine(); for (nTmp = 0; nTmp < m_nInsertionCol; nTmp++) { if (GetChar(nInsertionLine, nTmp) == 0) { SetChar(nInsertionLine, nTmp, ' ', 1, NULL); } } }
int prFileGetChar(struct VMGlobals *g, int numArgsPushed) { PyrSlot *a; PyrFile *pfile; FILE *file; char z; a = g->sp; pfile = (PyrFile*)slotRawObject(a); file = (FILE*)slotRawPtr(&pfile->fileptr); if (file == NULL) return errFailed; int count = (int)fread(&z, sizeof(char), 1, file); // kengo: if (count==0) SetNil(a); else SetChar(a, z); return errNone; }
VOID CPokemonCodec::SetPersonality(BYTE bType) { if(m_pPokemon == NULL || m_bEncoded) return; BYTE bShiny = GetIsShiny(); DWORD dwDiff; if(bType >= 25) bType %= 25; dwDiff = bType + 25 - GetPersonality(); if(dwDiff >= 25) dwDiff %= 25; if(dwDiff == 0) return; // note: 0x00100000 % 25 = 1 // it is an ideal number for preserving the low word dwDiff <<= 20; DWORD dwChar = m_pPokemon->Header.dwChar; if(0xFFFFFFFF - dwChar < dwDiff) // must not overflow !!! dwChar -= 0x01900000 - dwDiff; else dwChar += dwDiff; SetChar(dwChar); if(bShiny) { SetID(GenShinyID()); } else { while(GetIsShiny()) { SetID(m_pPokemon->Header.dwID + 0x00010000); } } }
void nsCompressedCharMap::SetChars(PRUint16* aCCMap) { int i, j; if(mExtended){ PRUint32 page = CCMAP_BEGIN_AT_START_OF_MAP; while (NextNonEmptyCCMapPage(aCCMap, &page)) { PRUint32 pagechar = page; for (i=0; i<(CCMAP_BITS_PER_PAGE/8); i++) { for (j=0; j<8; j++) { if (CCMAP_HAS_CHAR_EXT(aCCMap, pagechar)) { SetChar(pagechar); } pagechar++; } } } } else { // // Copy the input CCMap // // walk thru the upper pointers PRUint16 *upper = &aCCMap[0]; for (i=0; i<CCMAP_NUM_UPPER_POINTERS; i++) { if (upper[i] == CCMAP_EMPTY_MID) continue; // walk the mid array PRUint16 *mid = &aCCMap[upper[i]]; for (j=0; j<CCMAP_NUM_MID_POINTERS; j++) { if (mid[j] == CCMAP_EMPTY_PAGE) continue; PRUint32 base = (i*CCMAP_NUM_UCHARS_PER_MID) + (j*CCMAP_NUM_UCHARS_PER_PAGE); NS_ASSERTION(base<NUM_UNICODE_CHARS, "invalid page address"); ALU_TYPE *page = (ALU_TYPE*)&aCCMap[mid[j]]; SetChars((PRUint16)base, page); } } } }
waddchnstr(WINDOW *win, const chtype *astr, int n) { NCURSES_SIZE_T y = win->_cury; NCURSES_SIZE_T x = win->_curx; int code = OK; struct ldat *line; T((T_CALLED("waddchnstr(%p,%p,%d)"), win, astr, n)); if (!win) returnCode(ERR); if (n < 0) { const chtype *str; n = 0; for (str = (const chtype *) astr; *str != 0; str++) n++; } if (n > win->_maxx - x + 1) n = win->_maxx - x + 1; if (n == 0) returnCode(code); line = &(win->_line[y]); #if USE_WIDEC_SUPPORT { int i; for (i = 0; i < n; ++i) SetChar(line->text[i + x], ChCharOf(astr[i]), ChAttrOf(astr[i])); } #else memcpy(line->text + x, astr, n * sizeof(*astr)); #endif CHANGED_RANGE(line, x, x + n - 1); _nc_synchook(win); returnCode(code); }
/********************************************************************** * Purpose: Sets all characters between two specifed coordinates to a specified character. * * Precondition: * None * * Postcondition: * Block set at location. * ************************************************************************/ void ScreenBuffer::SetBlock(int r1, int c1, int r2, int c2, wchar_t a, WORD p) { if (_origin_r + _offset_r + r1 < 0 || _origin_c + _offset_c + c1 < 0 || _origin_r + _offset_r + r2 < 0 || _origin_c + _offset_c + c2 < 0) throw Exception("Coordinates must not lie outside of boundary!"); if (_origin_r + _offset_r + r1 > SB_HEIGHT - 1 || _origin_c + _offset_c + c1 > SB_WIDTH - 1 || _origin_r + _offset_r + r2 > SB_HEIGHT - 1 || _origin_c + _offset_c + c2 > SB_WIDTH - 1) throw Exception("Coordinates must not lie outside of boundary!"); if (c1 > c2) { c1 ^= c2; c2 ^= c1; c1 ^= c2; // XOR swap } if (r1 > r2) { r1 ^= r2; r2 ^= r1; r1 ^= r2; // XOR swap } for (int x = 0; x <= r2 - r1; ++x) for (int y = 0; y <= c2 - c1; ++y) SetChar(x + r1, y + c1, a); SetBlockAttribute(r1, c1, r2, c2, p); }
VOID CPokemonCodec::SetSexByte(BYTE bSexByte) { if(m_pPokemon == NULL || m_bEncoded) return; BYTE bShiny = GetIsShiny(); BYTE bPersonality = GetPersonality(); // the code is a bit slow, but it is easy to write SetChar((m_pPokemon->Header.dwChar & 0xFFFFFF00) + bSexByte); // the least significant byte indicates sex SetPersonality(bPersonality); if(bShiny) { SetID(GenShinyID()); } else { while(GetIsShiny()) { SetID(m_pPokemon->Header.dwID + 0x00010000); } } }
/*========================================================================= 拡張 strtok() "" に出くわすと、"" の中身を取り出す token の前後に空白があれば取り除く それ以外は、strtok_r() と同じ =========================================================================*/ void *strtok_pathV(void *str, const void *sep, void **p, BOOL remove_quote) { const void *quote=QUOTE_V, *org_sep = sep; if (str) *p = str; else str = *p; if (!*p) return NULL; // 頭だし while (GetChar(str, 0) && (strchrV(sep, GetChar(str, 0)) || GetChar(str, 0) == ' ')) str = MakeAddr(str, 1); if (GetChar(str, 0) == 0) return NULL; // 終端検出 void *in = str, *out = str; for ( ; GetChar(in, 0); in = MakeAddr(in, 1)) { BOOL is_set = FALSE; if (sep == org_sep) { // 通常 mode if (strchrV(sep, GetChar(in, 0))) { break; } else if (GetChar(in, 0) == '"') { if (!remove_quote) { is_set = TRUE; } sep = quote; // quote mode に遷移 } else { is_set = TRUE; } } else { // quote mode if (GetChar(in, 0) == '"') { sep = org_sep; // 通常 mode に遷移 if (!remove_quote) { is_set = TRUE; } } else { is_set = TRUE; } } if (is_set) { SetChar(out, 0, GetChar(in, 0)); out = MakeAddr(out, 1); } } *p = GetChar(in, 0) ? MakeAddr(in, 1) : NULL; SetChar(out, 0, 0); // 末尾の空白を取り除く for (out = MakeAddr(out, -1); out >= str && GetChar(out, 0) == ' '; out = MakeAddr(out, -1)) SetChar(out, 0, 0); return str; }
static NCURSES_INLINE int wadd_wch_nosync(WINDOW *win, cchar_t ch) /* the workhorse function -- add a character to the given window */ { NCURSES_SIZE_T x, y; wchar_t *s; int tabsize = 8; #if USE_REENTRANT SCREEN *sp = _nc_screen_of(win); #endif /* * If we are using the alternate character set, forget about locale. * Otherwise, if the locale claims the code is printable, treat it that * way. */ if ((AttrOf(ch) & A_ALTCHARSET) || iswprint((wint_t) CharOf(ch))) return wadd_wch_literal(win, ch); /* * Handle carriage control and other codes that are not printable, or are * known to expand to more than one character according to unctrl(). */ x = win->_curx; y = win->_cury; switch (CharOf(ch)) { case '\t': #if USE_REENTRANT tabsize = *ptrTabsize(sp); #else tabsize = TABSIZE; #endif x = (NCURSES_SIZE_T) (x + (tabsize - (x % tabsize))); /* * Space-fill the tab on the bottom line so that we'll get the * "correct" cursor position. */ if ((!win->_scroll && (y == win->_regbottom)) || (x <= win->_maxx)) { cchar_t blank = blankchar; AddAttr(blank, AttrOf(ch)); while (win->_curx < x) { if (wadd_wch_literal(win, blank) == ERR) return (ERR); } break; } else { wclrtoeol(win); win->_flags |= _WRAPPED; if (newline_forces_scroll(win, &y)) { x = win->_maxx; if (win->_scroll) { scroll(win); x = 0; } } else { x = 0; } } break; case '\n': wclrtoeol(win); if (newline_forces_scroll(win, &y)) { if (win->_scroll) scroll(win); else return (ERR); } /* FALLTHRU */ case '\r': x = 0; win->_flags &= ~_WRAPPED; break; case '\b': if (x == 0) return (OK); x--; win->_flags &= ~_WRAPPED; break; default: if ((s = wunctrl(&ch)) != 0) { while (*s) { cchar_t sch; SetChar(sch, *s++, AttrOf(ch)); if_EXT_COLORS(SetPair(sch, GetPair(ch))); if (wadd_wch_literal(win, sch) == ERR) return ERR; } return OK; } return ERR; } win->_curx = x; win->_cury = y; return OK; }