inline char* chinput_get_reply_punct(char c, chinput_symbol *chinput_corner, int nchinput_corner) { if(!chinput_corner || nchinput_corner <= 0) return NULL; int item; item = in_punct(c, chinput_corner, nchinput_corner); if(item != -1) { if(chinput_corner[item].num == 1) { return Sstrdup(chinput_corner[item].s); } else { char* tmp_utf8 = NULL; const char *tmp1 = chinput_corner[item].s; const char *tmp2 = NULL; if(chinput_corner[item].cur < 0 || chinput_corner[item].cur >= chinput_corner[item].num) chinput_corner[item].cur = 0; for(int i = 0; i <= chinput_corner[item].cur; i++) { uint len; tmp2 = __utf8_next_char(tmp1); if(!*tmp2) len = strlen(tmp1); else len = strlen(tmp1) - strlen(tmp2); if(tmp_utf8) delete[] tmp_utf8; tmp_utf8 = Sstrdup(tmp1, len); tmp1 += len; if(!tmp_utf8) break; if(!*tmp2) break; } chinput_corner[item].cur++; if(chinput_corner[item].cur >= chinput_corner[item].num) chinput_corner[item].cur = 0; return tmp_utf8; } } else return NULL; }
void SButton::Init(const BBitmap *bitmap, const char *label, const char *tooltips) { SButton::tooltips = NULL; SButton::bitmap = NULL; SButton::label = NULL; waitting = false; waitting_is_keyboard = false; focused = false; is_default = false; is_auto_default = false; old_time = 0; edge_is_black = true; behavior = S_ONE_STATE_BUTTON; SetValue(0); struct utsname the_os_name; uname(&the_os_name); if(strcasecmp(the_os_name.release, "5.1") == 0) button_style = DANO_STYLE; else button_style = R5_STYLE; if(label) SButton::label = Sstrdup(label); if(bitmap) SButton::bitmap = new BBitmap(bitmap); SetTooltips(tooltips); }
/** * puz_rtbl_set -- set the nth rtbl of a puzzle * * @puz: a pointer to the struct puzzle_t to read from (required) * @n: the index (between zero and rtbl_sz) to get * @val: the value to set it to * * Returns NULL on error, pointer to the puzzle's new copy on success. */ unsigned char * puz_rtbl_set(struct puzzle_t *puz, int n, unsigned char * val) { if(NULL == puz || n < 0 || n > puz->header.clue_count || NULL == val) return NULL; free(puz->rtbl[n]); puz->rtbl[n] = Sstrdup(val); return puz->rtbl[n]; }
/** * puz_copyright_set - set the puzzle's copyright * * @puz: a pointer to the struct puzzle_t to write to (required) * @val: a pointer to the string to st the value to (required) * * returns NULL on error, else a pointer to the struct's copy of the string */ unsigned char * puz_copyright_set(struct puzzle_t *puz, unsigned char *val) { if(NULL == puz || NULL == val) return NULL; free(puz->copyright); puz->copyright = Sstrdup(val); return puz->copyright; }
/** * puz_author_set - set the puzzle's author * * @puz: a pointer to the struct puzzle_t to write to (required) * @val: a pointer to the string to st the value to (required) * * returns NULL on error, else a pointer to the struct's copy of the string */ unsigned char * puz_author_set(struct puzzle_t *puz, unsigned char *val) { if(NULL == puz || NULL == val) return NULL; free(puz->author); puz->author = Sstrdup(val); return puz->author; }
/** * puz_title_set - set the puzzle's title * * @puz: a pointer to the struct puzzle_t to write to (required) * @val: a pointer to the string to st the value to (required) * * returns NULL on error, else a pointer to the struct's copy of the string */ unsigned char * puz_title_set(struct puzzle_t *puz, unsigned char *val) { if(NULL == puz || NULL == val) return NULL; free(puz->title); puz->title = Sstrdup(val); return puz->title; }
/** * puz_grid_set - set the puzzle's grid * * @puz: a pointer to the struct puzzle_t to write to (required) * @val: a pointer to the string to st the value to (required) * * returns NULL on error, else a pointer to the struct's copy of the string */ unsigned char * puz_grid_set(struct puzzle_t *puz, unsigned char *val) { if(NULL == puz || NULL == val) return NULL; free(puz->grid); puz->grid = Sstrdup(val); return puz->grid; }
/** * puz_solution_set - set the puzzle's solution * * @puz: a pointer to the struct puzzle_t to write to (required) * @val: a pointer to the string to st the value to (required) * * returns NULL on error, else a pointer to the struct's copy of the string */ unsigned char * puz_solution_set(struct puzzle_t *puz, unsigned char *val) { if(NULL == puz || NULL == val) return NULL; free(puz->solution); puz->solution = Sstrdup(val); return puz->solution; }
inline char* chinput_get_reply_corner(char c, chinput_symbol *chinput_corner, int nchinput_corner) { if(!chinput_corner || nchinput_corner <= 0) return NULL; int item; item = in_alnum(c, chinput_corner, nchinput_corner); if(item != -1) return Sstrdup(chinput_corner[item].s); else return NULL; }
/** * puz_notes_set - set the puzzle's notes * * @puz: a pointer to the struct puzzle_t to write to (required) * @val: a pointer to the string to st the value to (required) * * returns NULL on error, else a pointer to the struct's copy of the string */ unsigned char * puz_notes_set(struct puzzle_t *puz, unsigned char *val) { if(NULL == puz || NULL == val) return NULL; free(puz->notes); puz->notes = Sstrdup(val); puz->notes_sz = Sstrlen(val); return puz->notes; }
void SButton::SetLabel(const char *text) { if(label) delete[] label; if(text) label = Sstrdup(text); else label = NULL; BWindow *window = Window(); if(window) DrawDefault(Bounds(), false, window->IsActive()); }
void SButton::SetTooltips(const char *tooltips) { BWindow *window = Window(); if(SButton::tooltips) delete[] SButton::tooltips; if(tooltips) SButton::tooltips = Sstrdup(tooltips); else SButton::tooltips = NULL; if(window && tooltips) { BMessage msg(S_TOOLTIPS_CHANGED); msg.AddBool("state", false); BMessenger msgr(NULL, window); msgr.SendMessage(&msg); } }