diff --git a/cetodo/cetodo.d b/cetodo/cetodo.d index ac541547..90b58ff7 100644 --- a/cetodo/cetodo.d +++ b/cetodo/cetodo.d @@ -93,11 +93,11 @@ private struct TodoItem */ @safe public void serialize(ref string LfmString) { - LfmString ~= " item\n"; + LfmString ~= " \r\n item\r\n"; foreach(member; EnumMembers!TodoField) if (fFields[member].length) - LfmString ~= format(" %s = '%s'\n", to!string(member), fFields[member]); - LfmString ~= " end\n"; + LfmString ~= format(" %s = '%s'\r\n", to!string(member), fFields[member]); + LfmString ~= " end"; } } @@ -126,7 +126,7 @@ void main(string[] args) auto config = LexerConfig(f, StringBehavior.source); StringCache cache = StringCache(StringCache.defaultBucketCount); auto lexer = DLexer(src, config, &cache); - + // analyze the tokens foreach(tok; lexer) token2TodoItem(tok, f, todoItems); } @@ -134,15 +134,10 @@ void main(string[] args) // serialize the items using the pascal component streaming text format foreach(todoItem; todoItems) todoItem.serialize(LfmString); - // separates the data sent in procOutput() from those sent in procTerminated() - // TODO-cbugfix: find a way to determine if stdout has been written - if (stdout.size != 0) { - stdout.flush; - readln; - } - - // the widget has the LFM script in the output, it reads in procTerminated() - if (LfmString.length) writefln("object TTodoItems\n items = <\n%s>\nend", LfmString); + //TODO: NEVER call writeln() in this program otherwise the widget cant interpret the output as LFM + + // the widget has the LFM script in the output + if (LfmString.length) writefln("object TTodoItems\r\n items = <%s>\r\nend\r\n", LfmString); } /// Try to transforms a Token into a a TODO item @@ -150,12 +145,13 @@ void main(string[] args) { if (atok.type != (tok!"comment")) return; - if (atok.text.length < 3) + auto text = atok.text.strip; + if (text.length < 3) return; - if (atok.text[1] == '*' || atok.text[1] == '+' || atok.text[2] == '/') + if (text[1] == '*' || text[1] == '+' || text[2] == '/') return; - auto text = atok.text[2..$]; + text = text[2..$]; string identifier; bool isTodoComment; size_t pos; @@ -214,4 +210,4 @@ void main(string[] args) // TODO: set this property as const() to set it read only. // TODO-cfeature-sDone: save this property in the inifile. // TODO-cannnotations-p8: annotates the member of the module as @safe and if possible nothrow. - +// TODO-cfeature-sDone: save this property in the inifile. diff --git a/src/ce_todolist.pas b/src/ce_todolist.pas index 994ac0b0..04484fcb 100644 --- a/src/ce_todolist.pas +++ b/src/ce_todolist.pas @@ -82,8 +82,8 @@ type function getContext: TTodoContext; procedure killToolProcess; procedure callToolProcess; - procedure procTerminated(sender: TObject); procedure procOutput(sender: TObject); + procedure procOutputDbg(sender: TObject); procedure clearTodoList; procedure fillTodoList; procedure lstItemsDoubleClick(sender: TObject); @@ -278,10 +278,18 @@ begin // process parameter fToolProcess := TCheckedAsyncProcess.Create(nil); fToolProcess.Executable := ToolExeName; - fToolProcess.Options := [poUsePipes, poStderrToOutPut]; + fToolProcess.Options := [poUsePipes]; fToolProcess.ShowWindow := swoHIDE; - fToolProcess.OnTerminate := @procTerminated; + + // Something not quite clear: + // -------------------------- + // actually the two events can be called, depending + // on the amount of data in the output. + // many: OnReadData is called. + // few: OnTerminate is called. + fToolProcess.OnTerminate := @procOutput; fToolProcess.OnReadData := @procOutput; + // files passed to the tool argument if ctxt = tcProject then fToolProcess.Parameters.Add(symbolExpander.get('')) else fToolProcess.Parameters.AddText(symbolExpander.get('')); @@ -289,16 +297,15 @@ begin fToolProcess.Execute; end; -procedure TCETodoListWidget.procOutput(sender: TObject); +procedure TCETodoListWidget.procOutputDbg(sender: TObject); var str: TStringList; msg: string; ctxt: TTodoContext; begin - subjLmFromString(fLogMessager, 'called even if nothing in output', fProj, amcProj, amkAuto); str := TStringList.Create; try - processOutputToStrings(TAsyncProcess(fToolProcess), str); + processOutputToStrings(fToolProcess, str); ctxt := getContext; for msg in str do case ctxt of tcNone: subjLmFromString(fLogMessager, msg, nil, amcMisc, amkAuto); @@ -308,10 +315,9 @@ begin finally str.Free; end; - fToolProcess.Input.WriteByte($0A); end; -procedure TCETodoListWidget.procTerminated(sender: TObject); +procedure TCETodoListWidget.procOutput(sender: TObject); var str: TMemoryStream; cnt: Integer;