// This function is now implemented in ede-launch void MainMenu::resolve_program(Fl_String cmd) { char pRun[FL_PATH_MAX]; snprintf(pRun, sizeof(pRun)-1, "ede-launch \"%s\"", cmd.c_str()); fl_start_child_process(pRun, false); }
double Fl_String::to_double(double defvalue) const { Fl_String t = trim(); if (!t.length()) return defvalue; double value = strtod(t.c_str(), NULL); if (errno == ERANGE) return defvalue; return value; }
float Fl_String::to_float(float defvalue) const { Fl_String t = trim(); if(!t.length()) return defvalue; float value = (float)strtod(t.c_str(), NULL); if(errno == ERANGE) return defvalue; return value; }
int Fl_String::to_int(int defvalue) const { Fl_String t = trim(); if (!t.length()) return defvalue; int value = strtol(t.c_str(), NULL, 10); if(errno == ERANGE) return defvalue; if(value == 0 && t != "0") return defvalue; return value; }
Fl_String Fl_String::operator + (const Fl_String& s) const { int len = length() + s.length(); char *temp = (char*)malloc(len+1); strncpy(temp, str_, length()); if(s.length()) strncpy(temp+length(), s.c_str(), s.length()); temp[len] = '\0'; Fl_String s1(temp, len, true); return s1; }
Fl_String get_localized_string() { Fl_String locale = setlocale(LC_MESSAGES, NULL); // int pos = locale.rpos('_'); // if(pos>0) locale.sub_delete(pos, locale.length()-pos); if(locale=="C" || locale=="POSIX") locale.clear(); Fl_String localName; if(locale.empty()) localName = "Name"; else localName.printf("Name[%s]", locale.c_str()); return localName; }
void Fl_Led_Window::led_color(Fl_String col) { const char *color = strdup(col.c_str()); if (strcmp(color,"green") == 0) { color_index = FL_GREEN; return; } if (strcmp(color,"red") == 0) { color_index = FL_RED; return; } if (strcmp(color,"yellow") == 0) { color_index = FL_YELLOW; return; } }
const char *fl_font_change_attrib(const char *name, int word, const char *replace) { int att = font_word_pos(name, word); if(att==-1) return strdup(name); att++; int att_end = font_word_pos(name, word+1); if(att_end==-1) att_end = strlen(name); int len = att_end-att; Fl_String newname; newname.append(name, att); newname.append(replace, strlen(replace)); newname.append(name+att+len, strlen(name)-att_end); return strdup(newname.c_str()); }
void Fl_Type::read_property(const Fl_String &c) { if (!strcmp(c,"label")) label(read_word()); else if (!strcmp(c,"tooltip")) tooltip(read_word()); else if (!strcmp(c,"user_data")) user_data(read_word()); else if (!strcmp(c,"user_data_type")) user_data_type(read_word()); else if (!strcmp(c,"callback")) callback(read_word()); else if (!strcmp(c,"open")) open_ = 1; else if (!strcmp(c,"selected")) select(this,1); else read_error("Unknown property \"%s\"", c.c_str()); }
void parse_header(Fl_Buffer &buf) { if(!header.empty()) return; char *ptr = buf.data(); char *header_end = strstr(ptr, "\r\n\r\n"); if(header_end) { header = Fl_String(ptr, header_end-ptr); int hlen = header.length()+4; buf.set(buf.data()+hlen, buf.bytes()-hlen); printf("HEADER (%s)\n", header.c_str()); int pos = header.pos("Content-Length"); if(pos>-1) { pos += 15; int pos2 = header.pos("\r\n", pos); content_len = header.sub_str(pos, pos2-pos).to_int(); p_bar->range(0, content_len); } } }
Fl_String Fl_String::from_codeset(Fl_String codeset, const char *str, int str_len) { return Fl_String::from_codeset(fl_find_converter(codeset.c_str()), str, str_len); }
void apply_colors_gtk(Fl_Color fg, Fl_Color bg, Fl_Color selection, Fl_Color selection_text, Fl_Color tooltip, Fl_Color tooltip_text, Fl_Color text, Fl_String font) { uchar r, g, b; uchar text_r, text_g, text_b; //, b1, r2, g2, b2; uchar selection_r, selection_g, selection_b; uchar selection_text_r, selection_text_g, selection_text_b; uchar tooltip_r, tooltip_g, tooltip_b; uchar tooltip_text_r, tooltip_text_g, tooltip_text_b; fl_get_color(bg, r, g, b); fl_get_color(fg, text_r, text_g, text_b); fl_get_color(selection, selection_r, selection_g, selection_b); fl_get_color(selection_text, selection_text_r, selection_text_g, selection_text_b); fl_get_color(tooltip, tooltip_r, tooltip_g, tooltip_b); fl_get_color(tooltip_text, tooltip_text_r, tooltip_text_g, tooltip_text_b); // fl_get_color(text, r2, g2, b2); Fl_String filePath(fl_homedir()); filePath += "/.gtkrc"; FILE *gtkFile = fopen(filePath.c_str(), "w"); fprintf(gtkFile, "style \"default\" \n"); fprintf(gtkFile, "{\n"); fprintf(gtkFile, "fontset = \"%s\" \n", font.c_str()); fprintf(gtkFile, "bg[NORMAL] = \"#%02X%02X%02X\"\n", r, g, b); fprintf(gtkFile, "fg[NORMAL] = \"#%02X%02X%02X\"\n", text_r, text_g, text_b); fprintf(gtkFile, "bg[PRELIGHT] = \"#%02X%02X%02X\"\n", r, g, b); fprintf(gtkFile, "fg[PRELIGHT] = \"#%02X%02X%02X\"\n", text_r, text_g, text_b); fprintf(gtkFile, "bg[ACTIVE] = \"#%02X%02X%02X\"\n", r, g, b); fprintf(gtkFile, "fg[ACTIVE] = \"#%02X%02X%02X\"\n", text_r, text_g, text_b); fprintf(gtkFile, "bg[SELECTED] = \"#%02X%02X%02X\"\n", selection_r, selection_g, selection_b); fprintf(gtkFile, "fg[SELECTED] = \"#%02X%02X%02X\"\n", selection_text_r, selection_text_g, selection_text_b); fprintf(gtkFile, "}\n"); fprintf(gtkFile, "style \"menu\" \n"); fprintf(gtkFile, "{\n"); fprintf(gtkFile, "bg[PRELIGHT] = \"#%02X%02X%02X\"\n", selection_r, selection_g, selection_b); fprintf(gtkFile, "fg[PRELIGHT] = \"#%02X%02X%02X\"\n", selection_text_r, selection_text_g, selection_text_b); fprintf(gtkFile, "}\n"); fprintf(gtkFile, "style \"tooltip\" \n"); fprintf(gtkFile, "{\n"); fprintf(gtkFile, "bg[NORMAL] = \"#%02X%02X%02X\"\n", tooltip_r, tooltip_g, tooltip_b); fprintf(gtkFile, "fg[NORMAL] = \"#%02X%02X%02X\"\n", tooltip_text_r, tooltip_text_g, tooltip_text_b); fprintf(gtkFile, "}\n"); fprintf(gtkFile, "class \"*\" style \"default\"\n"); fprintf(gtkFile, "widget_class \"*Menu*\" style \"menu\" \n"); fprintf(gtkFile, "widget \"gtk-tooltips\" style \"tooltip\" \n"); fclose(gtkFile); }
void Fl_Query::sql(const Fl_String& _sql) { // Looking up for SQL parameters Fl_String paramName; char delimitter[] = " "; char delimitters[] = "'\":'"; char *s = strdup(_sql.c_str()); char *paramStart = s; char *paramEnd; int paramNumber = 0; for (unsigned i = 0; i < m_params.count(); i++) { Fl_Param& param = m_params[i]; param.bind_clear(); } Fl_String odbcSQL = ""; bool endOfString; for (;;) { paramEnd = strpbrk(paramStart,delimitters); if ( !paramEnd ) { odbcSQL += paramStart; break; } *delimitter = *paramEnd; if (*paramEnd == ':') { if (paramEnd != s && isalnum(*(paramEnd-1)) ) { *paramEnd = char(0); odbcSQL += paramStart; odbcSQL += ":"; paramStart = paramEnd + 1; continue; } if (paramEnd[1] == ':') { paramEnd++; *paramEnd = char(0); odbcSQL += paramStart; paramStart = paramEnd + 1; continue; } } if ( *paramEnd == '\'' || *paramEnd == '"' ) { paramEnd = strpbrk(paramEnd + 1,delimitter); if ( !paramEnd ) { break; // Unmatched quotes } *paramEnd = char(0); odbcSQL += paramStart; odbcSQL += delimitter; paramStart = paramEnd + 1; continue; } *paramEnd = char(0); odbcSQL += paramStart; paramStart = paramEnd + 1; delimitter[0] = 0; char *ptr = paramStart; for (; *ptr; ptr++) { char c = *ptr; if ( c == '_' ) continue; if (!isalnum(c)) { delimitter[0] = c; break; } } paramEnd = ptr; endOfString = (*paramEnd == 0); *paramEnd = char(0); if (ptr != paramStart) { //Fl_Param *param; int index = m_params.param_index(paramStart); if ( index == -1 ) { theParam = new Fl_Param(paramStart); m_params.add(theParam); } else { theParam = &m_params[index]; } theParam->bind_add(paramNumber); paramNumber++; odbcSQL += "?"; odbcSQL += delimitter; } else { odbcSQL += ":"; } paramStart = paramEnd + 1; if (endOfString) break; } free(s); for (int p = m_params.count() - 1; p >= 0; p--) if (!m_params[p].bind_count()) m_params.remove(p); if (m_sql != odbcSQL) { m_sql = odbcSQL; if (m_database) { if ( active() ) close(); free_stmt(); } } }