nomad-software / tkd

GUI toolkit for the D programming language based on Tcl/Tk
MIT License
117 stars 16 forks source link

Escaping problems with tcl's list command, and more orphan format issues #31

Closed callumenator closed 9 years ago

callumenator commented 9 years ago

There are still a few issues with text escaping and stuff. Tcl's list does its own escaping, so trying to set a column value to e.g. "[1,2,3]" shows up as "[1,2,3]". Replacing [list "%s"] with {"%s"} seems to work, but I don't know why, I'm not good with tcl, it might just be a coincidence.

The other problem was that the final command was still going through format, so orphan format specs were an issue. Pretty much any command that includes literal text has to be eval'd without going through format (or you could catch FormatExceptions and ignore them...).

This pull fixes just the couple of issues I've found in treeview. I can submit more for other places where this happens if this is the way you want to handle it. Feels a bit brittle though.

nomad-software commented 9 years ago

Hmm... i can't reproduce this issue. Make sure you are using the latest version (v1.1.2) there was a problem with dub registry and the latest version wasn't available for a while. I have successfully put the value [1,2,3] inside all tree row columns (including headings) without it showing slashes.

Can you provide a small fully formed program showing the issue please?

callumenator commented 9 years ago

Argh you're right, I was still using my own escaping function before calling, effectively escaping twice. Sorry bout that.

The orphan format thing is still a problem though.

nomad-software commented 9 years ago

No worries.

The orphan format thing is still a problem though.

Can you explain this a little more please, i'm not sure what you mean.

callumenator commented 9 years ago
auto frame = new Frame(2, ReliefStyle.groove)
            .pack(10);
auto tree = new TreeView(frame)
            .setHeading("Stuff")                
            .addColumn(new TreeViewColumn("Value"))                     
            .grid(0, 0, 5, 0, 1, 1, "nsew")         
            .configureGeometryColumn(0,1)
            .configureGeometryRow(0,1);                 
auto row = new TreeViewRow(["a", "%s"]);
tree.addRow(row);

Literal text that includes a format specifier. Because treeview sends this through to eval like this: this._tk.eval(%s insert {%s} end -text "~ row.values[0] ~" ~ values ~ -open %s ~ tags, this.id, parentRow, row.isOpen); it still gets format applied to it, and that picks up the format specifiers in the text string and thinks they are missing arguments.

nomad-software commented 9 years ago

This hopefully is fixed in commit: https://github.com/nomad-software/tkd/commit/2b8bca9987eb429392a56d1b36c4f454bd9354d0. Let me know if it tests ok for you and if so i'll create a new release.

callumenator commented 9 years ago

Missed treeview: updateDataColumn? https://github.com/nomad-software/tkd/blob/2b8bca9987eb429392a56d1b36c4f454bd9354d0/source/tkd/widget/treeview.d#L436-L441

nomad-software commented 9 years ago

Ah, good call. Fixed in commit: https://github.com/nomad-software/tkd/commit/e46b5efc4680f445814a0dae3afae7471b677635.