int main(int argc, char *argv[]) { (void) setlocale(LC_ALL, ""); #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't */ #endif (void) textdomain(TEXT_DOMAIN); setup(argc, argv); /* initialize and read productions */ TBITSET = NWORDS(ntoksz*LKFACTOR); tbitset = NWORDS(ntokens*LKFACTOR); mktbls(); cpres(); /* make table of which productions yield a */ /* given nonterminal */ cempty(); /* make a table of which nonterminals can match */ /* the empty string */ cpfir(); /* make a table of firsts of nonterminals */ stagen(); /* generate the states */ output(); /* write the states and the tables */ go2out(); hideprod(); summary(); callopt(); others(); return (0); }
int main(int argc, char *argv[]) { KCmdLineArgs::init(argc, argv, "cstester", 0, KLocalizedString(), 0, KLocalizedString()); KCmdLineOptions options; options.add("create", ki18n("create verification data for file")); options.add("indir <dir>", ki18n("directory to read the data from")); options.add("outdir <dir>", ki18n("directory to save the data to")); options.add("roundtrip", ki18n("load/save/load and check the document is the same after load and save/load")); options.add("verbose", ki18n("be verbose")); options.add("!verify", ki18n("verify the file")); options.add( "+file", ki18n("file to use")); KCmdLineArgs::addCmdLineOptions(options); QApplication app(argc, argv); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); bool create = false; bool roundtrip = false; bool verify = false; int optionCount = 0; if (args->isSet("create")) { create = true; optionCount++; } if (args->isSet("roundtrip")) { roundtrip = true; optionCount++; } if (args->isSet("verify")) { verify = true; optionCount++; } if (optionCount > 1) { kError() << "create, roundtrip and verify cannot be used the same time"; exit(1); } else if (optionCount < 1) { kError() << "one of the options create, roundtrip or verify needs to be specified"; exit(1); } QString outDir; if (args->isSet("outdir")) { // check if it is a directory QDir dir(args->getOption("outdir")); if (!dir.exists()) { kError() << "outdir" << args->getOption("outdir") << "does not exist"; exit(1); } outDir = dir.path(); } QString inDir; if (args->isSet("indir")) { // check if it is a directory QDir dir(args->getOption("indir")); if (!dir.exists()) { kError() << "indir" << args->getOption("indir") << "does not exist"; exit(1); } inDir = dir.path(); } bool verbose = args->isSet("verbose"); int exitValue = 0; int successful = 0; int failed = 0; for (int i=0; i < args->count(); ++i) { QString filename(args->arg(i)); QFileInfo file(filename); QString checkDir; if (!args->isSet("indir")) { checkDir = filename + ".check"; } else { checkDir = inDir + '/' + file.fileName() + ".check"; } // this is wrong for multiple files in different dirs if (!args->isSet("outdir")) { outDir = file.path(); } qDebug() << "filename" << filename << "path" << file.path() << file.completeBaseName() << checkDir << file.absoluteFilePath(); qDebug() << "inDir" << inDir << "outDir" << outDir << "checkDir" << checkDir; // filename must be a absolute path KoDocument* document = openFile(file.absoluteFilePath()); if (!document) { exit(2); } QList<QImage> thumbnails(createThumbnails(document, QSize(800,800))); qDebug() << "created" << thumbnails.size() << "thumbnails"; if (create) { saveThumbnails(file, thumbnails, outDir); } else if (verify) { if (args->isSet("outdir")) { saveThumbnails(file, thumbnails, outDir); } if (checkThumbnails(thumbnails, checkDir, verbose)) { ++successful; } else { ++failed; exitValue = 2; } } else if (roundtrip) { QString rFilename = saveFile(document, filename, "cstester-roundtrip"); delete document; QFileInfo rFile(rFilename); qDebug() << roundtrip << "rFilename" << rFilename << rFile.absoluteFilePath(); document = openFile(rFile.absoluteFilePath()); QList<QImage> others(createThumbnails(document, QSize(800,800))); if (args->isSet("outdir")) { saveThumbnails(file, others, outDir); saveThumbnails(file, thumbnails, outDir + "/before"); } if (checkThumbnails(thumbnails, others, verbose)) { ++successful; } else { ++failed; exitValue = 2; } } delete document; } if (verify || roundtrip) { qDebug() << "Totals:" << successful << "passed" << failed << "failed"; } QTimer::singleShot(1, &app, SLOT(quit())); app.exec(); return exitValue; }
Graph::Graph(const int *cartan, const std::vector<Word>& gens, //namesake const std::vector<Word>& v_cogens, const std::vector<Word>& e_gens, const std::vector<Word>& f_gens, const Vect& weights) { //define symmetry group relations std::vector<Word> words = words_from_cartan(cartan); { const Logging::fake_ostream& os = logger.debug(); os << "relations ="; for (int w=0; w<6; ++w) { Word& word = words[w]; os << "\n "; for (unsigned i=0; i<word.size(); ++i) { os << word[i]; } } os |0; } //check vertex stabilizer generators { const Logging::fake_ostream& os = logger.debug(); os << "v_cogens ="; for (unsigned w=0; w<v_cogens.size(); ++w) { const Word& jenn = v_cogens[w]; //namesake os << "\n "; for (unsigned t=0; t<jenn.size(); ++t) { int j = jenn[t]; os << j; Assert (0<=j and j<4, "generator out of range: letter w[" << w << "][" << t << "] = " << j ); } } os |0; } //check edge generators { const Logging::fake_ostream& os = logger.debug(); os << "e_gens ="; for (unsigned w=0; w<e_gens.size(); ++w) { const Word& edge = e_gens[w]; os << "\n "; for (unsigned t=0; t<edge.size(); ++t) { int j = edge[t]; os << j; Assert (0<=j and j<4, "generator out of range: letter w[" << w << "][" << t << "] = " << j ); } } os |0; } //check face generators { const Logging::fake_ostream& os = logger.debug(); os << "f_gens ="; for (unsigned w=0; w<f_gens.size(); ++w) { const Word& face = f_gens[w]; os << "\n "; for (unsigned t=0; t<face.size(); ++t) { int j = face[t]; os << j; Assert (0<=j and j<4, "generator out of range: letter w[" << w << "][" << t << "] = " << j ); } } os |0; } //build symmetry group Group group(words); logger.debug() << "group.ord = " << group.ord |0; //build subgroup std::vector<int> subgroup; subgroup.push_back(0); std::set<int> in_subgroup; in_subgroup.insert(0); for (unsigned g=0; g<subgroup.size(); ++g) { int g0 = subgroup[g]; for (unsigned j=0; j<gens.size(); ++j) { int g1 = group.left(g0,gens[j]); if (in_subgroup.find(g1) != in_subgroup.end()) continue; subgroup.push_back(g1); in_subgroup.insert(g1); } } logger.debug() << "subgroup.ord = " << subgroup.size() |0; //build cosets and count ord std::map<int,int> coset; //maps group elements to cosets ord = 0; //used as coset number for (unsigned g=0; g<subgroup.size(); ++g) { int g0 = subgroup[g]; if (coset.find(g0) != coset.end()) continue; int c0 = ord++; coset[g0] = c0; std::vector<int> members(1, g0); std::vector<int> others(0); for (unsigned i=0; i<members.size(); ++i) { int g1 = members[i]; for (unsigned w=0; w<v_cogens.size(); ++w) { int g2 = group.left(g1, v_cogens[w]); if (coset.find(g2) != coset.end()) continue; coset[g2] = c0; members.push_back(g2); } } } logger.info() << "cosets table built: " << " ord = " << ord |0; //build edge lists std::vector<std::set<int> > neigh(ord); for (unsigned g=0; g<subgroup.size(); ++g) { int g0 = subgroup[g]; int c0 = coset[g0]; for (unsigned w=0; w<e_gens.size(); ++w) { int g1 = group.left(g0, e_gens[w]); Assert (in_subgroup.find(g1) != in_subgroup.end(), "edge leaves subgroup"); int c1 = coset[g1]; if (c0 != c1) neigh[c0].insert(c1); } } // make symmetric for (int c0=0; c0<ord; ++c0) { const std::set<int>& n = neigh[c0]; for (std::set<int>::iterator c1=n.begin(); c1!=n.end(); ++c1) { neigh[*c1].insert(c0); } } // build edge table adj.resize(ord); for (int c=0; c<ord; ++c) { adj[c].insert(adj[c].begin(), neigh[c].begin(), neigh[c].end()); } neigh.clear(); deg = adj[0].size(); logger.info() << "edge table built: deg = " << deg |0; //define faces for (unsigned g=0; g<f_gens.size(); ++g) { const Word& face = f_gens[g]; logger.debug() << "defining faces on " << face |0; Logging::IndentBlock block; //define basic face in group Ring basic(1,0); // g = 0; int g0 = 0; for (unsigned c=0; true; ++c) { g0 = group.left(g0, face[c%face.size()]); if (c >= face.size() and g0 == 0) break; if (in_subgroup.find(g0) != in_subgroup.end() and g0 != basic.back()) { basic.push_back(g0); } } for (unsigned c=0; c<basic.size(); ++c) { logger.debug() << " corner: " << basic[c] |0; } logger.debug() << "sides/face (free) = " << basic.size() |0; //build orbit of basic face std::vector<Ring> faces_g; faces_g.push_back(basic); FaceRecognizer recognized; recognized(basic); for (unsigned i=0; i<faces_g.size(); ++i) { const Ring f = faces_g[i]; for (unsigned j=0; j<gens.size(); ++j) { //right action of group on faces Ring f_j(f.size()); for (unsigned c=0; c<f.size(); ++c) { f_j[c] = group.right(f[c],gens[j]); } //add face if (not recognized(f_j)) { faces_g.push_back(f_j); //logger.debug() << "new face: " << f_j |0; } else { //logger.debug() << "old face: " << f_j|0; } } } //hom face down to quotient graph recognized.clear(); for (unsigned f=0; f<faces_g.size(); ++f) { const Ring face_g = faces_g[f]; Ring face; face.push_back(coset[face_g[0]]); for (unsigned i=1; i<face_g.size(); ++i) { int c = coset[face_g[i]]; if (c != face.back() and c != face[0]) { face.push_back(c); } } if (face.size() < 3) continue; if (not recognized(face)) { faces.push_back(face); } } } ord_f = faces.size(); logger.info() << "faces defined: order = " << ord_f |0; //define vertex coset std::vector<Word> vertex_coset; for (unsigned g=0; g<subgroup.size(); ++g) { int g0 = subgroup[g]; if (coset[g0]==0) vertex_coset.push_back(group.parse(g0)); } //build geometry std::vector<Mat> gen_reps(gens.size()); points.resize(ord); build_geom(cartan, vertex_coset, gens, v_cogens, weights, gen_reps, points[0]); std::vector<int> pointed(ord,0); pointed[0] = true; logger.debug() << "geometry built" |0; //build point sets std::vector<int> reached(1,0); std::set<int> is_reached; is_reached.insert(0); for (unsigned g=0; g<subgroup.size(); ++g) { int g0 = reached[g]; for (unsigned j=0; j<gens.size(); ++j) { int g1 = group.right(g0,gens[j]); if (is_reached.find(g1) == is_reached.end()) { if (not pointed[coset[g1]]) { vect_mult(gen_reps[j], points[coset[g0]], points[coset[g1]]); pointed[coset[g1]] = true; } reached.push_back(g1); is_reached.insert(g1); } } } logger.debug() << "point set built." |0; //build face normals normals.resize(ord_f); for (int f=0; f<ord_f; ++f) { Ring& face = faces[f]; Vect &a = points[face[0]]; Vect &b = points[face[1]]; Vect &c = points[face[2]]; Vect &n = normals[f]; cross4(a,b,c, n); normalize(n); /* Assert1(fabs(inner(a,n)) < 1e-6, "bad normal: <n,a> = " << fabs(inner(a,n))); Assert1(fabs(inner(b,n)) < 1e-6, "bad normal: <n,b> = " << fabs(inner(b,n))); Assert1(fabs(inner(c,n)) < 1e-6, "bad normal: <n,b> = " << fabs(inner(c,n))); */ } logger.debug() << "face normals built." |0; }
void Main::InitCommands() { // コマンド m_commands = CreateCommands(COMMANDS, sizeof(COMMANDS) / sizeof(COMMANDS[0])); function current(this, &Main::ForwardToCurrent); function all (this, &Main::ForwardToAll); function shown (this, &Main::ForwardToShown); function hidden (this, &Main::ForwardToHidden); function left (this, &Main::ForwardToLeft); function right (this, &Main::ForwardToRight); function others (this, &Main::ForwardToOthers); function dups (this, &Main::ForwardToDuplicate); function anyFolder(this, &Main::EnableIfAnyFolder); function anySelect(this, &Main::EnableIfAnySelection); // System CommandProcess(L"System.Exit" , m_form, CommandClose); CommandProcess(L"System.Restart", &Main::SystemRestart); CommandProcess(L"System.About" , &Main::SystemAbout); // File CommandProcess(L"Explorer.Clone" , &Main::ExplorerImport, 0); CommandProcess(L"Explorer.Import" , &Main::ExplorerImport, 1); CommandProcess(L"File.Open" , &Main::FileOpen, 0); CommandProcess(L"File.Load" , &Main::FileLoad); CommandHandler(L"File.Save" , &Main::FileSave , null, &Main::EnableIfAnyFolder, null); CommandHandler(L"File.MRU" , &Main::FileMRU , null, &Main::ObserveMRU, null); CommandHandler(L"RecycleBin.Empty" , &Main::ProcessRecycleBin , null, &Main::ObserveRecycleBin, null); // Current CommandHandler(L"Current.Lock(true)" , &Main::CurrentLock, BoolTrue , &Main::ObserveLock, BoolTrue); CommandHandler(L"Current.Lock(false)" , &Main::CurrentLock, BoolFalse , &Main::ObserveLock, BoolFalse); CommandHandler(L"Current.Lock(toggle)" , &Main::CurrentLock, BoolUnknown , &Main::ObserveLock, BoolUnknown); CommandToFocus(L"Current.Menu" , CommandMenu); CommandToFocus(L"Current.New" , AVESTA_New); CommandToFocus(L"Current.NewFolder" , AVESTA_NewFolder); CommandToFocus(L"Current.SelectPattern" , AVESTA_SelectPattern); CommandToFocus(L"Current.Close" , CommandClose); CommandToFocus(L"Current.Show(false)" , AVESTA_Hide); CommandToFocus(L"Current.Export" , AVESTA_Export); CommandToFocus(L"Current.Refresh" , CommandUpdate); CommandToFocus(L"Current.Find" , AVESTA_Find); CommandToFocus(L"Current.PatternMask" , AVESTA_PatternMask); CommandToSelect(L"Current.Cut" , CommandCut); CommandToSelect(L"Current.Copy" , CommandCopy); CommandToSelect(L"Current.Copy.Base" , AVESTA_CopyBase); CommandToSelect(L"Current.Copy.Name" , AVESTA_CopyName); CommandToSelect(L"Current.Copy.Path" , AVESTA_CopyPath); CommandToSelect(L"Current.Copy.Here" , AVESTA_CopyHere); CommandToSelect(L"Current.Delete" , CommandDelete); CommandToSelect(L"Current.Bury" , CommandBury); CommandToSelect(L"Current.Rename" , CommandRename); CommandToSelect(L"Current.Rename.Dialog" , AVESTA_RenameDialog); CommandToSelect(L"Current.Property" , CommandProperty); CommandToSelect(L"Current.CopyTo" , AVESTA_CopyTo); CommandToSelect(L"Current.MoveTo" , AVESTA_MoveTo); CommandToSelect(L"Current.CopyToOther" , AVESTA_CopyToOther); CommandToSelect(L"Current.MoveToOther" , AVESTA_MoveToOther); CommandToSelect(L"Current.CopyCheckedTo" , AVESTA_CopyCheckedTo); CommandToSelect(L"Current.MoveCheckedTo" , AVESTA_MoveCheckedTo); CommandToFocus(L"Current.SyncDescendants" , AVESTA_SyncDesc); CommandToFocus(L"Current.Key.Up" , CommandKeyUp); CommandToFocus(L"Current.Key.Down" , CommandKeyDown); CommandToFocus(L"Current.Key.Left" , CommandKeyLeft); CommandToFocus(L"Current.Key.Right" , CommandKeyRight); CommandToFocus(L"Current.Key.Home" , CommandKeyHome); CommandToFocus(L"Current.Key.End" , CommandKeyEnd); CommandToFocus(L"Current.Key.PageUp" , CommandKeyPageUp); CommandToFocus(L"Current.Key.PageDown" , CommandKeyPageDown); CommandToFocus(L"Current.Key.Space" , CommandKeySpace); CommandToFocus(L"Current.Key.Enter" , CommandKeyEnter); m_commands->Alias(L"Current.Cursor.Up" , L"Current.Key.Up" ); m_commands->Alias(L"Current.Cursor.Down" , L"Current.Key.Down" ); m_commands->Alias(L"Current.Cursor.Left" , L"Current.Key.Left" ); m_commands->Alias(L"Current.Cursor.Right" , L"Current.Key.Right" ); m_commands->Alias(L"Current.Cursor.Home" , L"Current.Key.Home" ); m_commands->Alias(L"Current.Cursor.End" , L"Current.Key.End" ); m_commands->Alias(L"Current.Cursor.PageUp" , L"Current.Key.PageUp" ); m_commands->Alias(L"Current.Cursor.PageDown", L"Current.Key.PageDown" ); CommandToSelect(L"Current.SelectNone" , CommandSelectNone); CommandToCheck(L"Current.CheckAll" , CommandCheckAll); CommandToCheck(L"Current.CheckNone" , CommandCheckNone); CommandToFocus(L"Current.SelectAll" , CommandSelectAll); CommandToFocus(L"Current.SelectChecked" , CommandSelectChecked); CommandToFocus(L"Current.SelectReverse" , CommandSelectReverse); CommandToFocus(L"Current.SelectToFirst" , CommandSelectToFirst); CommandToFocus(L"Current.SelectToLast" , CommandSelectToLast); CommandToFocus(L"Current.Undo" , CommandUndo); CommandProcess(L"Current.SyncFileDialog" , &Main::ProcessSyncFileDialog); CommandHandler(L"Current.Paste" , current, CommandPaste , &Main::ObserveClipboard , CF_SHELLIDLIST); CommandHandler(L"Current.PasteTo" , current, AVESTA_PasteTo , &Main::ObserveClipToSelect , CF_HDROP); CommandHandler(L"Current.Rename.Paste" , current, AVESTA_RenamePaste , &Main::ObserveClipToSelect , CF_UNICODETEXT); CommandHandler(L"Current.Go.Up" , current, CommandGoUp , &Main::ObserveGo , DirNorth); CommandHandler(L"Current.Go.Back" , current, CommandGoBack , &Main::ObserveGo , DirWest); CommandHandler(L"Current.Go.Forward" , current, CommandGoForward , &Main::ObserveGo , DirEast); CommandHandler(L"Current.Go.Location" , &Main::FileOpen, 1, anyFolder, null); CommandHandler(L"Current.AutoArrange" , current, AVESTA_AutoArrange , current, AVEOBS_AutoArrange); CommandHandler(L"Current.Grouping" , current, AVESTA_Grouping , current, AVEOBS_Grouping); CommandHandler(L"Current.ShowAllFiles" , current, AVESTA_ShowAllFiles , current, AVEOBS_ShowAllFiles); CommandHandler(L"Current.Mode.Icon" , current, StyleMsg(ListStyleIcon) , &Main::ObserveMode, ListStyleIcon); CommandHandler(L"Current.Mode.List" , current, StyleMsg(ListStyleList) , &Main::ObserveMode, ListStyleList); CommandHandler(L"Current.Mode.Details" , current, StyleMsg(ListStyleDetails) , &Main::ObserveMode, ListStyleDetails); CommandHandler(L"Current.Mode.Thumbnail", current, StyleMsg(ListStyleThumnail) , &Main::ObserveMode, ListStyleThumnail); CommandHandler(L"Current.Mode.Tile" , current, StyleMsg(ListStyleTile) , &Main::ObserveMode, ListStyleTile); CommandToFocus(L"Current.AdjustToItem" , CommandAdjustToItem); CommandToFocus(L"Current.AdjustToWindow", CommandAdjustToWindow); // All CommandHandler(L"All.Close" , all, CommandClose , anyFolder, null); CommandHandler(L"All.Refresh" , all, CommandUpdate , anyFolder, null); CommandHandler(L"All.Export" , all, AVESTA_Export , anyFolder, null); CommandHandler(L"All.Show(true)" , all, AVESTA_Show , anyFolder, null); // Shown CommandHandler(L"Shown.Close" , shown , CommandClose , anyFolder, null); CommandHandler(L"Shown.Refresh" , shown , CommandUpdate , anyFolder, null); CommandHandler(L"Shown.Export" , shown , AVESTA_Export , anyFolder, null); CommandHandler(L"Shown.AdjustToItem" , shown , CommandAdjustToItem , anyFolder, null); CommandHandler(L"Shown.AdjustToWindow" , shown , CommandAdjustToWindow , anyFolder, null); CommandHandler(L"Shown.ToLeft" , m_tab, CommandShownToLeft , anyFolder, null); CommandHandler(L"Shown.ToRight" , m_tab, CommandShownToRight , anyFolder, null); // Locked CommandHandler(L"Locked.ToLeft" , m_tab , CommandLockedToLeft , anyFolder, null); CommandHandler(L"Locked.ToRight" , m_tab , CommandLockedToRight , anyFolder, null); // Hidden CommandHandler(L"Hidden.Close" , hidden, CommandClose , anyFolder, null); CommandHandler(L"Hidden.Refresh" , hidden, CommandUpdate , anyFolder, null); CommandHandler(L"Hidden.Export" , hidden, AVESTA_Export , anyFolder, null); // Duplicate CommandHandler(L"Duplicate.Close" , dups , CommandClose , anyFolder, null); // Left CommandHandler(L"Left.Close" , left , CommandClose , anyFolder, null); CommandHandler(L"Left.Show(false)" , left , AVESTA_Hide , anyFolder, null); CommandHandler(L"Left.Show(true)" , left , AVESTA_Show , anyFolder, null); // Right CommandHandler(L"Right.Close" , right , CommandClose , anyFolder, null); CommandHandler(L"Right.Show(false)" , right , AVESTA_Hide , anyFolder, null); CommandHandler(L"Right.Show(true)" , right , AVESTA_Show , anyFolder, null); // Others CommandHandler(L"Others.Close" , others, CommandClose , anyFolder, null); CommandHandler(L"Others.Show(false)", others, AVESTA_Hide , anyFolder, null); // Tab CommandProcess(L"Tab.Focus" , m_tab, &IWindow::Focus); CommandHandler(L"Tab.Sort" , &Main::ProcessTabSort, null, anyFolder, null); CommandHandler(L"Tab.Next" , m_tab, CommandGoForward , anyFolder, null); CommandHandler(L"Tab.Next2" , m_tab, CommandGoDown , anyFolder, null); CommandHandler(L"Tab.Prev" , m_tab, CommandGoBack , anyFolder, null); CommandHandler(L"Tab.Prev2" , m_tab, CommandGoUp , anyFolder, null); CommandHandler(L"Current.ToLeft" , &Main::ProcessTabMove, -1, anyFolder, null); CommandHandler(L"Current.ToRight" , &Main::ProcessTabMove, +1, anyFolder, null); // Single Tab for(int i = 0; i < 9; ++i) { TCHAR name[MAX_PATH]; wsprintf(name, L"Tab[%d].Show(toggle)", (i+1)); CommandHandler(name, &Main::ProcessTabShow , i, &Main::ObserveTabShow , i); wsprintf(name, L"Tab[%d].Focus", (i+1)); CommandHandler(name, &Main::ProcessTabFocus, i, &Main::ObserveTabFocus, i); } // Form CommandProcess(L"Form.Show(true)" , &Main::WindowVisibleTrue); CommandProcess(L"Form.Show(false)" , m_form, CommandMinimize); CommandProcess(L"Form.Show(toggle)" , &Main::WindowVisibleToggle); CommandProcess(L"Form.Maximize" , m_form, CommandMaximize); CommandProcess(L"Form.Restore" , m_form, CommandRestore); CommandProcess(L"Form.Resize" , m_form, CommandResize); CommandProcess(L"Form.Move" , m_form, CommandMove); CommandProcess(L"Form.Menu" , m_form, CommandMenu); CommandHandler(L"Form.DropMode" , &Main::ProcessDropMode, null, &Main::ObserveDropMode, null); m_commands->Alias(L"Form.Zoom" , L"Form.Maximize"); m_commands->Alias(L"Form.Minimize" , L"Form.Show(false)"); m_commands->Alias(L"Form.Close" , L"System.Exit"); m_commands->Alias(L"Window.Show(true)" , L"Form.Show(true)" ); m_commands->Alias(L"Window.Show(false)" , L"Form.Show(false)" ); m_commands->Alias(L"Window.Show(toggle)" , L"Form.Show(toggle)" ); m_commands->Alias(L"Window.Maximize" , L"Form.Maximize" ); m_commands->Alias(L"Window.Restore" , L"Form.Restore" ); m_commands->Alias(L"Window.Resize" , L"Form.Resize" ); m_commands->Alias(L"Window.Move" , L"Form.Move" ); m_commands->Alias(L"Window.Menu" , L"Form.Menu" ); m_commands->Alias(L"Window.Zoom" , L"Form.Maximize" ); m_commands->Alias(L"Window.Minimize" , L"Form.Show(false)" ); m_commands->Alias(L"Window.Close" , L"System.Exit" ); // Address CommandToFocus(L"Address.Focus" , CommandFocusAddress); // Header CommandToFocus(L"Header.Focus" , FocusHeaderMessage()); // Tree CommandProcess(L"Tree.Refresh" , &Main::ProcessTreeRefresh); CommandHandler(L"Tree.Sync" , &Main::ProcessTreeSync , null, &Main::ObserveTreeSync , null); CommandHandler(L"Tree.Reflect" , &Main::ProcessTreeReflect , null, &Main::ObserveTreeReflect , null); CommandHandler(L"Tree.AutoSync" , &Main::OptionBoolean , BoolTreeAutoSync , &Main::ObserveBoolean , BoolTreeAutoSync); CommandHandler(L"Tree.AutoReflect" , &Main::OptionBoolean , BoolTreeAutoReflect , &Main::ObserveBoolean , BoolTreeAutoReflect); CommandProcess(L"Tree.Cut" , m_tree, CommandCut); CommandProcess(L"Tree.Copy" , m_tree, CommandCopy); CommandProcess(L"Tree.Copy.Base" , m_tree, AVESTA_CopyBase); CommandProcess(L"Tree.Copy.Name" , m_tree, AVESTA_CopyName); CommandProcess(L"Tree.Copy.Path" , m_tree, AVESTA_CopyPath); CommandProcess(L"Tree.Copy.Here" , m_tree, AVESTA_CopyHere); CommandProcess(L"Tree.Delete" , m_tree, CommandDelete); CommandProcess(L"Tree.Bury" , m_tree, CommandBury); CommandProcess(L"Tree.Rename" , m_tree, CommandRename); CommandProcess(L"Tree.Paste" , m_tree, CommandPaste); CommandProcess(L"Tree.Property" , m_tree, CommandProperty); CommandProcess(L"Tree.MoveTo" , m_tree, AVESTA_MoveTo); CommandProcess(L"Tree.CopyTo" , m_tree, AVESTA_CopyTo); // Option CommandProcess(L"Option.Reload" , &Main::OptionReload); CommandProcess(L"Option.Font" , &Main::OptionFont); CommandProcess(L"FolderOptions.Show" , &Main::ProcessFolderOptionsShow); CommandHandler(L"Option.Thumbnail.64" , &Main::ProcessThumbSize, 64 , &Main::ObserveThumbSize, 64 ); CommandHandler(L"Option.Thumbnail.96" , &Main::ProcessThumbSize, 96 , &Main::ObserveThumbSize, 96 ); CommandHandler(L"Option.Thumbnail.128" , &Main::ProcessThumbSize, 128, &Main::ObserveThumbSize, 128); CommandHandler(L"Option.Thumbnail.192" , &Main::ProcessThumbSize, 192, &Main::ObserveThumbSize, 192); CommandHandler(L"Option.Thumbnail.256" , &Main::ProcessThumbSize, 256, &Main::ObserveThumbSize, 256); CommandHandler(L"Arrange.Auto" , &Main::ProcessArrange, ArrangeAuto, &Main::ObserveArrange, ArrangeAuto); CommandHandler(L"Arrange.Horz" , &Main::ProcessArrange, ArrangeHorz, &Main::ObserveArrange, ArrangeHorz); CommandHandler(L"Arrange.Vert" , &Main::ProcessArrange, ArrangeVert, &Main::ObserveArrange, ArrangeVert); CommandHandler(L"Keybind.Normal" , &Main::ProcessKeybind, afx::KeybindNormal , &Main::ObserveKeybind, afx::KeybindNormal ); CommandHandler(L"Keybind.Atok" , &Main::ProcessKeybind, afx::KeybindAtok , &Main::ObserveKeybind, afx::KeybindAtok ); CommandHandler(L"Keybind.Emacs" , &Main::ProcessKeybind, afx::KeybindEmacs, &Main::ObserveKeybind, afx::KeybindEmacs); CommandHandler(L"MiddleClick.Disable" , &Main::ProcessMiddleClick, ModifierNone , &Main::ObserveMiddleClick, ModifierNone ); CommandHandler(L"MiddleClick.Control" , &Main::ProcessMiddleClick, ModifierControl, &Main::ObserveMiddleClick, ModifierControl); CommandHandler(L"MiddleClick.Shift" , &Main::ProcessMiddleClick, ModifierShift , &Main::ObserveMiddleClick, ModifierShift ); CommandHandler(L"AutoCopy.None" , &Main::ProcessAutoCopy, CopyNone, &Main::ObserveAutoCopy, CopyNone); CommandHandler(L"AutoCopy.Base" , &Main::ProcessAutoCopy, CopyBase, &Main::ObserveAutoCopy, CopyBase); CommandHandler(L"AutoCopy.Name" , &Main::ProcessAutoCopy, CopyName, &Main::ObserveAutoCopy, CopyName); CommandHandler(L"AutoCopy.Path" , &Main::ProcessAutoCopy, CopyPath, &Main::ObserveAutoCopy, CopyPath); // あとでなくなるもの CommandProcess(L"Option.WallPaper" , &Main::OptionWallPaper); CommandHandler(L"Option.Insert.Head" , &Main::OptionInsert, InsertHead, &Main::ObserveInsert, InsertHead); CommandHandler(L"Option.Insert.Tail" , &Main::OptionInsert, InsertTail, &Main::ObserveInsert, InsertTail); CommandHandler(L"Option.Insert.Prev" , &Main::OptionInsert, InsertPrev, &Main::ObserveInsert, InsertPrev); CommandHandler(L"Option.Insert.Next" , &Main::OptionInsert, InsertNext, &Main::ObserveInsert, InsertNext); CommandHandler(L"Option.TaskTray" , &Main::OptionTaskTray , null, &Main::ObserveTaskTray , null); CommandHandler(L"Option.AlwaysTray" , &Main::OptionAlwaysTray , null, &Main::ObserveAlwaysTray , null); CommandHandler(L"Option.CloseToTray" , &Main::OptionCloseToTray , null, &Main::ObserveCloseToTray , null); CommandHandler(L"Option.AlwaysTop" , &Main::OptionAlwaysTop , null, &Main::ObserveAlwaysTop , null); CommandHandler(L"Option.CheckBox" , &Main::OptionCheckBox , BoolCheckBox , &Main::ObserveBoolean, BoolCheckBox); CommandHandler(L"Option.DnDCopyInterDrive" , &Main::OptionBoolean , BoolDnDCopyInterDrv , &Main::ObserveBoolean, BoolDnDCopyInterDrv); CommandHandler(L"Option.DistinguishTab" , &Main::OptionBoolean , BoolDistinguishTab , &Main::ObserveBoolean, BoolDistinguishTab); CommandHandler(L"Option.FullRowSelect" , &Main::OptionFullRowSelect, BoolFullRowSelect , &Main::ObserveBoolean, BoolFullRowSelect); CommandHandler(L"Option.GestureOnName" , &Main::OptionBoolean , BoolGestureOnName , &Main::ObserveBoolean, BoolGestureOnName); CommandHandler(L"Option.GridLine" , &Main::OptionGridLine , BoolGridLine , &Main::ObserveBoolean, BoolGridLine); CommandHandler(L"Option.OpenDups" , &Main::OptionBoolean , BoolOpenDups , &Main::ObserveBoolean, BoolOpenDups); CommandHandler(L"Option.OpenNotify" , &Main::OptionBoolean , BoolOpenNotify , &Main::ObserveBoolean, BoolOpenNotify); CommandHandler(L"Option.RestoreConditions" , &Main::OptionBoolean , BoolRestoreCond , &Main::ObserveBoolean, BoolRestoreCond); CommandHandler(L"Option.LazyExecute" , &Main::OptionBoolean , BoolLazyExecute , &Main::ObserveBoolean, BoolLazyExecute); CommandHandler(L"Option.LockClose" , &Main::OptionBoolean , BoolLockClose , &Main::ObserveBoolean, BoolLockClose); CommandHandler(L"Option.LoopCursor" , &Main::OptionBoolean , BoolLoopCursor , &Main::ObserveBoolean, BoolLoopCursor); CommandHandler(L"MiddleClick.SingleExecute" , &Main::OptionBoolean , BoolMiddleSingle , &Main::ObserveBoolean, BoolMiddleSingle); CommandHandler(L"Option.RenameExtension" , &Main::OptionRenameExtension, null, &Main::ObserveBoolean, BoolRenameExtension); CommandHandler(L"Option.PasteInFolder" , &Main::OptionBoolean , BoolPasteInFolder , &Main::ObserveBoolean, BoolPasteInFolder); CommandHandler(L"Option.Python" , &Main::OptionPython , BoolPython , &Main::ObserveBoolean, BoolPython); CommandHandler(L"Option.QuietProgress" , &Main::OptionBoolean , BoolQuietProgress , &Main::ObserveBoolean, BoolQuietProgress); }
int main() { core::logger::init(); core::logger::addOutput(&std::cout); graphics::Graphics* gfx = new graphics::Graphics; events::Events ev; bool cont = true; if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { std::cout << "Couldn't load SDL : " << SDL_GetError() << std::endl; return 1; } cont = gfx->openWindow("Test events::Events joysticks handling", 800, 600); if(!cont) return 1; /* Background */ geometry::AABB bgaabb(800.0f, 600.0f); graphics::Color bgc; bgc.r = bgc.g = 127; bgc.b = 255; /* Particular events. */ events::KeySave kqs (events::Key('Q')); events::KeySave others (events::Key(' ')); size_t kq = ev.addSaved(&kqs); ev.addSaved(&others); events::Joystick* joystick = ev.openJoystick(0); if(!joystick) { std::cout << "There must be a joystick." << std::endl; return 1; } events::JoyButtonSave jbs; jbs.set(joystick, 0); ev.addSaved(&jbs); events::JoyHatSave jhs; jhs.set(joystick, 0, events::JoyHatState::Up); ev.addSaved(&jhs); events::JoyAxisSave jas; jas.set(joystick, 0, -32768); ev.addSaved(&jas); ev.enableInput(true); while(cont) { ev.update(); ev.clearInput(); if(ev.closed() || ev.quit() || ev.isSavedValid(kq)) cont = false; std::vector<size_t> l = ev.lastSavedValidated(); if(!l.empty()) { std::cout << l.size() << " events have been validated." << std::endl; for(size_t id : l) { std::cout << "\t> " << id << " : " << ev.getSaved(id)->save() << " at " << ev.lastSavedValid(id) << std::endl; } } l = ev.lastSavedReleased(); if(!l.empty()) { std::cout << l.size() << " events have been released." << std::endl; for(size_t id : l) { std::cout << "\t> " << id << " : " << ev.getSaved(id)->save() << " at " << ev.lastSavedRelease(id) << std::endl; } } gfx->beginDraw(); gfx->draw(bgaabb, bgc); gfx->endDraw(); SDL_Delay(1000/30); } delete gfx; core::logger::free(); SDL_Quit(); return 0; }
int main(int argc, char **argv) { struct stat st; char *file_type_mode[] = { "NULL", "FIFO", "charactr device", "NULL", "directory", "NULL", "block device", "NULL", "regular file", "NULL", "symbolic link", "NULL", "socket" }; #if 0 // int stat(const char *path, struct stat *buf); struct stat { dev_t st_dev; /* ID of device containing file */ ino_t st_ino; /* inode number */ mode_t st_mode; /* protection */ nlink_t st_nlink; /* number of hard links */ uid_t st_uid; /* user ID of owner */ gid_t st_gid; /* group ID of owner */ dev_t st_rdev; /* device ID (if special file) */ off_t st_size; /* total size, in bytes */ blksize_t st_blksize; /* blocksize for file system I/O */ blkcnt_t st_blocks; /* number of 512B blocks allocated */ time_t st_atime; /* time of last access */ time_t st_mtime; /* time of last modification */ time_t st_ctime; /* time of last status change */ }; S_IFMT 0170000 bit mask for the file type bit fields S_IFSOCK 0140000 socket S_IFLNK 0120000 symbolic link S_IFREG 0100000 regular file S_IFBLK 0060000 block device S_IFDIR 0040000 directory S_IFCHR 0020000 character device S_IFIFO 0010000 FIFO S_ISUID 0004000 set UID bit S_ISGID 0002000 set-group-ID bit (see below) S_ISVTX 0001000 sticky bit (see below) S_IRWXU 00700 mask for file owner permissions S_IRUSR 00400 owner has read permission S_IWUSR 00200 owner has write permission S_IXUSR 00100 owner has execute permission S_IRWXG 00070 mask for group permissions S_IRGRP 00040 group has read permission S_IWGRP 00020 group has write permission S_IXGRP 00010 group has execute permission S_IRWXO 00007 mask for permissions for others (not in group) S_IROTH 00004 others have read permission S_IWOTH 00002 others have write permission S_IXOTH 00001 others have execute permission #endif if(argc != 2) { fprintf(stdout, "Usage: %s <pathname>\n", argv[0]); exit(EXIT_FAILURE); } // int open(const char *pathname, int flags); // int open(const char *pathname, int flags, mode_t mode); int fd; if((fd = open(argv[1], O_RDONLY)) < 0) { perror("argv[1]"); exit(EXIT_FAILURE); } if(fstat(fd, &st)) { perror("argv[1]"); exit(EXIT_FAILURE); } fprintf(stdout, " File: \"%s\"\n", argv[1]); fprintf(stdout, " Size: %ld Blocks: %ld IO block: %ld %s\n",\ st.st_size, st.st_blocks, st.st_blksize, file_type_mode[(st.st_mode & S_IFMT) >> 12]); fprintf(stdout, "Device: ?/? Inode: %ld Links: %ld\n", (long)st.st_ino, (long)st.st_nlink); return 0; }