# HG changeset patch # User Diggory Hardy # Date 1238859138 -7200 # Node ID e785e98d3b78ab4e1a1e9681b9143ae4845a90f8 # Parent 42fb97d9ff9ee1e2166657c2d7437f52c36d8d1f Updated for compatibility with tango 0.99.8. diff -r 42fb97d9ff9e -r e785e98d3b78 codeDoc/ideas.txt --- a/codeDoc/ideas.txt Sat Apr 04 11:59:27 2009 +0200 +++ b/codeDoc/ideas.txt Sat Apr 04 17:32:18 2009 +0200 @@ -29,6 +29,24 @@ -> with complicated substructures, may not be very intuitive -> limit to popup menus? -> these keyboard events only passed if activated by code outside the WidgetManager and no text input callback is active +> Drawing windows/popups (to draw a back): + -> Use the same renderer & manager: + -> Make all widgets draw a back? + -> bad for transparancy and performance + -> Force first widget to draw a back + -> extra parameter to pass in special cases + > Use a sub-renderer + -> extra parameter to pass + -> or some kind of lookup by mgr + +> enables nice transparancy + +> Use a sub-manager + +> holds a sub-renderer or something + +> enables nice transparancy + ?> integrates with popup support? will this work? + > each floating/popup widget has its own renderer (last two above) + +> combined rendering (to texture?) of each "layer" to enable nice transparancy + > lower performance? + Content: -> Per-content undo support? diff -r 42fb97d9ff9e -r e785e98d3b78 data/L10n/en-GB.mtt --- a/data/L10n/en-GB.mtt Sat Apr 04 11:59:27 2009 +0200 +++ b/data/L10n/en-GB.mtt Sat Apr 04 17:32:18 2009 +0200 @@ -31,8 +31,8 @@ - - + + diff -r 42fb97d9ff9e -r e785e98d3b78 mde/file/mergetag/MTTagWriter.d --- a/mde/file/mergetag/MTTagWriter.d Sat Apr 04 11:59:27 2009 +0200 +++ b/mde/file/mergetag/MTTagWriter.d Sat Apr 04 17:32:18 2009 +0200 @@ -22,7 +22,7 @@ import mde.file.mergetag.exception; import tango.io.device.File; -import tango.io.stream.Buffer; +import tango.io.stream.Buffered; import tango.util.log.Log : Log, Logger; private Logger logger; @@ -67,7 +67,7 @@ { /** Opens the file path for writing. Call close() when done! */ this (char[] path) { - buffer = new BufferOutput (new File (path, File.WriteCreate)); + buffer = new BufferedOutput (new File (path, File.WriteCreate)); buffer.append ("{" ~ CurrentVersionString ~ "}" ~ Eol); } @@ -87,7 +87,7 @@ } private: - scope BufferOutput buffer; + scope BufferedOutput buffer; } class MTBTagWriter : MTTagWriter diff -r 42fb97d9ff9e -r e785e98d3b78 mde/file/mergetag/Writer.d --- a/mde/file/mergetag/Writer.d Sat Apr 04 11:59:27 2009 +0200 +++ b/mde/file/mergetag/Writer.d Sat Apr 04 17:32:18 2009 +0200 @@ -37,7 +37,7 @@ // tango imports import tango.core.Exception; import tango.io.device.File; -import tango.io.stream.Buffer; +import tango.io.stream.Buffered; import tango.util.log.Log : Log, Logger; private Logger logger; @@ -171,13 +171,13 @@ try { scope File conduit; // actual conduit; don't use directly when there's content in the buffer - scope BufferOutput buffer; // write strings directly to this (use opCall(void[]) ) + scope BufferedOutput buffer; // write strings directly to this (use opCall(void[]) ) // Open a conduit on the file: conduit = new File (_path, File.WriteCreate); scope(exit) conduit.close(); - buffer = new BufferOutput(conduit); // And a buffer + buffer = new BufferedOutput(conduit); // And a buffer scope(exit) buffer.flush(); // Write the header: @@ -201,11 +201,11 @@ } } - private void writeSectionIdentifier (BufferOutput buffer, ID id) { + private void writeSectionIdentifier (BufferedOutput buffer, ID id) { buffer.append ("{" ~ id ~ "}" ~ Eol); } - private void writeSection (BufferOutput buffer, IDataSection sec) { + private void writeSection (BufferedOutput buffer, IDataSection sec) { void writeItem (char[] tp, ID id, char[] dt) { // actually writes an item buffer.append ("<" ~ tp ~ "|" ~ id ~"=" ~ dt ~ ">" ~ Eol); } diff -r 42fb97d9ff9e -r e785e98d3b78 mde/file/paths.d --- a/mde/file/paths.d Sat Apr 04 11:59:27 2009 +0200 +++ b/mde/file/paths.d Sat Apr 04 17:32:18 2009 +0200 @@ -51,12 +51,10 @@ } else version (Windows) import tango.sys.win32.SpecialPath; -debug { - import tango.util.log.Log : Log, Logger; - private Logger logger; - static this() { - logger = Log.getLogger ("mde.file.paths"); - } +import tango.util.log.Log : Log, Logger; +private Logger logger; +static this() { + logger = Log.getLogger ("mde.file.paths"); } /** Order to read files in. @@ -197,8 +195,7 @@ paths[pathsLen++] = fp.toString~'/'; return true; } catch (Exception e) { - // No logging avaiable yet: Use Stdout/Cout - Cout ("Creating path "~path~" failed:" ~ e.msg).newline; + logger.error ("Creating path {} failed:" ~ e.msg, path); } } return false; @@ -209,7 +206,7 @@ for (size_t i = 0; i < pathsLen; ++i) Cout ("\n\t" ~ paths[i]); } else - Cout ("[none]"); + Cout (" [none]"); } // Use a static array to store all possible paths with separate length counters. @@ -310,12 +307,11 @@ confDir.tryPath (userPath.toString ~ "/conf", true); if (extraConfPath) confDir.tryPath (extraConfPath); - if (!dataDir.pathsLen) throw new mdeException ("Fatal: no data path found!"); - if (!confDir.pathsLen) throw new mdeException ("Fatal: no conf path found!"); + if (dataDir.pathsLen==0) throw new mdeException ("Fatal: no data path found!"); + if (confDir.pathsLen==0) throw new mdeException ("Fatal: no conf path found!"); for (int i = dataDir.pathsLen - 1; i >= 0; --i) { FilePath font = FilePath (dataDir.paths[i] ~ "fonts"); - Cout ("considering: ")(font.toString).newline; if (font.exists && font.isFolder) fontPaths[iFP++] = font; } diff -r 42fb97d9ff9e -r e785e98d3b78 mde/setup/Init.d --- a/mde/setup/Init.d Sat Apr 04 11:59:27 2009 +0200 +++ b/mde/setup/Init.d Sat Apr 04 17:32:18 2009 +0200 @@ -59,7 +59,7 @@ //import tango.stdc.stringz : fromStringz; import tango.io.Console; // for printing command-line usage import TimeStamp = tango.text.convert.TimeStamp, tango.time.WallClock; // output date in log file -import tango.util.Arguments; +import tango.util.ArgParser; import tango.util.log.Log; import tango.util.log.AppendConsole; import tango.util.log.AppendFiles; @@ -88,7 +88,10 @@ logLevel = new EnumContent ("MiscOptions.logLevel", ["Trace", "Info", "Warn", "Error", "Fatal", "None"]); logOutput = new EnumContent ("MiscOptions.logOutput", - ["none", "console", "file", "both"]); + ["both", "file", "console", "none"]); + + // Callback to set the logging level on change: + logLevel.addCallback (&setLogLevel); } /** this() − pre-init and init */ @@ -98,45 +101,45 @@ * Pre-init - init code written in this module. *********************************************************************/ debug logger.trace ("Init: starting pre-init"); - //FIXME: warn on invalid arguments, including base-path on non-Windows - // But Arguments doesn't support this (in tango 0.99.6 and in r3563). - Arguments args; try { - args = new Arguments(); - args.define("base-path").parameters(1); - args.define("data-path").parameters(1,-1); - args.define("conf-path").parameters(1,-1); - args.define("font-path").parameters(1,-1); - args.define("paths"); - args.define("q").aliases(["quick-exit"]); - args.define("help").aliases(["h"]); - args.parse(cmdArgs); - if (args.contains("help")) // lazy way to print help - throw new InitException ("Help requested"); // and stop + // Create without a default-argument delegate; let ArgParser throw: + auto args = new ArgParser (); + char[] basePath = "."; + bool printPaths = false; + args.bind("--", "base-path=", delegate void(char[] value){ + basePath=value; + }); + args.bind("--", "data-path=", delegate void(char[] value){ + paths.extraDataPath = value; + }); + args.bind("--", "conf-path=", delegate void(char[] value){ + paths.extraConfPath = value; + }); + args.bind("--", "font-path=", delegate void(char[] value){ + paths.addFontPath (value); + }); + args.bind("--", "paths", delegate void(char[]){ + printPaths = true; + }); + args.bind([Argument("--", "quick-exit"), Argument ("-", "q")], + delegate void(char[]){ + imde.run = false; + }); + args.bind([Argument("--", "help"), Argument ("-", "h")], + delegate void(char[]){ + printUsage(cmdArgs[0]); + // Requesting help is an "error" in that normal program operation is cut short. + throw new InitException ("Help requested"); // stops program + }); + args.parse(cmdArgs[1..$]); + paths.resolvePaths (basePath); + + if (printPaths) { + paths.mdeDirectory.printPaths; + throw new InitException ("Paths requested"); // lazy way to stop + } } catch (Exception e) { - printUsage(cmdArgs[0]); - throw new InitException ("Parsing arguments failed: "~e.msg); - } - - // Find/create paths: - try { - if (args.contains("data-path")) - paths.extraDataPath = args["data-path"]; - if (args.contains("conf-path")) - paths.extraConfPath = args["conf-path"]; - if (args.contains("font-path")) - paths.addFontPath (args["font-path"]); - - if (args.contains("base-path")) - paths.resolvePaths (args["base-path"]); - else - paths.resolvePaths(); - } catch (Exception e) { - throw new InitException ("Resolving paths failed: " ~ e.msg); - } - if (args.contains("paths")) { - paths.mdeDirectory.printPaths; - throw new InitException ("Paths requested"); // lazy way to stop + throw new InitException ("Command-line: "~e.msg); } debug logger.trace ("Init: resolved paths successfully"); @@ -158,17 +161,14 @@ root = Log.root; root.clear; // we may no longer want to log to the console - // Now re-set the logging level and add callback to set on change: - setLogLevel (); - logLevel.addCallback (&setLogLevel); - - if (logOutput() & 2) { // first appender so root seperator messages don't show on console + // logOutput == 0 enables both outputs, in case options aren't read + if (!(logOutput() & 2)) { // first appender so root seperator messages don't show on console // Use 2 log files with a maximum size of 16kiB: root.add (new AppendFiles (paths.logDir~"/log-.txt", 2, 16*1024)); root.append (Level.None, ""); // some kind of separation between runs root.append (Level.None, ""); } - if (logOutput() & 1) + if (!(logOutput() & 1)) root.add(new AppendConsole); logger.info ("Starting mde [no version] on " ~ TimeStamp.toString(WallClock.now)); } catch (Exception e) { @@ -176,11 +176,11 @@ // logger and if that fails let the exception kill the program. root.clear; root.add (new AppendConsole); - logger.warn ("Exception while setting up the logger; logging to the console instead."); + logger.error ("Exception while setting up the logger; logging to the console instead."); } // a debugging option: - imde.run = !args.contains("q") && !exitImmediately(); + imde.run = imde.run && !exitImmediately(); debug logger.trace ("Init: applied pre-init options"); //BEGIN Load dynamic libraries @@ -401,6 +401,16 @@ // Callback on logLevel void setLogLevel (Content = null) { + int level = logLevel(); + if (level < Level.Trace || level > Level.None) { + logger.error ("incorrect logging level"); + level = Level.Info; + return; // setting the level causes this function to be called again + } + debug { + Log.root.level (Level.Trace); + logger.trace ("Setting logging level {}", logLevel()); + } Log.root.level (logOutput() == 0 ? Level.None : cast(Level) logLevel(), true); } @@ -410,15 +420,15 @@ Cout (progName ~ ` [options]`).newline; version(Windows) Cout ( -` --base-path path Use path as the base (install) path (Windows only). It +` --base-path=path Use path as the base (install) path (Windows only). It should contain the "data" directory.`).newline; Cout ( -` --data-path path(s) Add path(s) as a potential location for data files. - First path argument becomes the preffered location to - load data files from. - --conf-path path(s) Add path(s) as a potential location for config files. - Configuration in the first path given take highest - priority. +` --data-path=path Add path as a potential location for data files. May be + given multiple times. First path argument becomes + the prefered location to load data files from. + --conf-path=path Add path as a potential location for config files. May + be given multiple times. Configuration in the first + path given take highest priority. --paths Print all paths found and exit. --quick-exit, -q Exit immediately, without entering main loop. --help, -h Print this message.`).newline;