static void LoadGUI() { assert(!locked); locked = true; WndProperty* wp; wp = (WndProperty*)wf->FindByName(_T("prpFontName")); if (wp) { DataFieldEnum* dfe = (DataFieldEnum*)wp->GetDataField(); if (dfe) { dfe->Set(0); unsigned i; for (i = 0; i < dfe->Count(); i++) { if (_tcsncmp(dfe->GetAsString(), NewLogFont.lfFaceName, LF_FACESIZE) == 0) break; dfe->Inc(); } if (i == dfe->Count()) dfe->Set(dfe->addEnumText(NewLogFont.lfFaceName)); } wp->RefreshDisplay(); } wp = (WndProperty*)wf->FindByName(_T("prpFontHeight")); if (wp) { DataFieldInteger* dfi = (DataFieldInteger*)wp->GetDataField(); if (dfi) dfi->Set(NewLogFont.lfHeight); wp->RefreshDisplay(); } wp = (WndProperty*)wf->FindByName(_T("prpFontWeight")); if (wp) { DataFieldBoolean* dfi = (DataFieldBoolean*)wp->GetDataField(); if (dfi) dfi->Set(NewLogFont.lfWeight > 500); wp->RefreshDisplay(); } wp = (WndProperty*)wf->FindByName(_T("prpFontItalic")); if (wp) { DataFieldBoolean* dfb = (DataFieldBoolean*)wp->GetDataField(); if (dfb) dfb->Set(NewLogFont.lfItalic); wp->RefreshDisplay(); } locked = false; RedrawSampleFont(); }
static bool DetectSerialPorts(DataFieldEnum &df) { TTYEnumerator enumerator; if (enumerator.HasFailed()) return false; unsigned sort_start = df.Count(); bool found = false; const char *path; while ((path = enumerator.Next()) != nullptr) { const char *display_string = path; if (memcmp(path, "/dev/", 5) == 0) display_string = path + 5; AddPort(df, DeviceConfig::PortType::SERIAL, path, display_string); found = true; } if (found) df.Sort(sort_start); return found; }
static unsigned AddPort(DataFieldEnum &df, DeviceConfig::PortType type, const TCHAR *text, const TCHAR *display_string=NULL, const TCHAR *help=NULL) { /* the uppper 16 bit is the port type, and the lower 16 bit is a serial number to make the enum id unique */ unsigned id = ((unsigned)type << 16) + df.Count(); df.AddChoice(id, text, display_string, help); return id; }
static bool DetectSerialPorts(DataFieldEnum &df) { PortEnumerator enumerator; if (enumerator.Error()) return false; unsigned sort_start = df.Count(); bool found = false; while (enumerator.Next()) { AddPort(df, DeviceConfig::PortType::SERIAL, enumerator.GetName(), enumerator.GetDisplayName()); found = true; } if (found) df.Sort(sort_start); return found; }
static bool DetectSerialPorts(DataFieldEnum &df) { DIR *dir = opendir("/dev"); if (dir == NULL) return false; unsigned sort_start = df.Count(); bool found = false; struct dirent *ent; while ((ent = readdir(dir)) != NULL) { /* filter "/dev/tty*" */ if (memcmp(ent->d_name, "tty", 3) == 0) { /* filter out "/dev/tty0", ... (valid integer after "tty") */ char *endptr; strtoul(ent->d_name + 3, &endptr, 10); if (*endptr == 0) continue; } else if (memcmp(ent->d_name, "rfcomm", 6) != 0) continue; char path[64]; snprintf(path, sizeof(path), "/dev/%s", ent->d_name); if (access(path, R_OK|W_OK) == 0 && access(path, X_OK) < 0) { AddPort(df, DeviceConfig::PortType::SERIAL, path); found = true; } } closedir(dir); if (found) df.Sort(sort_start); return found; }