nomad-software / tkd

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

adding a system path to a ComboBox makes it display garbage #20

Closed ghost closed 10 years ago

ghost commented 10 years ago

ComboBox.setData(["c:\a\b"]) //Garbage

It works if you double escape the backslashes but makes it difficult and error prone to use. ComboBox.setData(["c:\a\b"])

ghost commented 10 years ago

I meant to put back-ticks instead of quotes in the example above ComboBox.setData([c:\a\b]) //Garbage ComboBox.setData([c:\\a\\b]) //works Sorry bout that

nomad-software commented 10 years ago

This is an issue with string escaping throughout Tkd. I'm looking into it now.

ghost commented 10 years ago

Ha, web site has same bug :)

ghost commented 10 years ago

no prob. no hurry. thanks

nomad-software commented 10 years ago

Ok this is now fixed in master. https://github.com/nomad-software/tkd/commit/63ac96719f8372462920aa07a090dbee88e9ab88

I'll do another beta release soon.

This is a compound problem i think. In your example creating a string literal like this: "c:\a\b" is not going to work. This is because \a and \b are special control characters. So the solution here is to use raw strings by prepending an r before the string like this: r"c:\a\b" which disables all special control characters or to escape the backslash like this: "c:\\a\\b". This was also a problem on my end in that Tcl/Tk was parsing these special characters as well. I've added some code to escape backslashes and other special Tcl characters to avoid problems in the future but you'll still need to take into account the above information on control characters.

ghost commented 10 years ago

Thanks Gary for the quick responses. Github trashes the backslashes in the strings too, much to my amusement, so I could not give you a good example. I am very familiar with string escape codes. I was sending it correctly but it showed up wrong in the comments. LOL

Dave

On Sat, May 17, 2014 at 1:35 PM, Gary Willoughby notifications@github.comwrote:

Ok this is now fixed in master. 63ac967https://github.com/nomad-software/tkd/commit/63ac96719f8372462920aa07a090dbee88e9ab88

I'll do another beta release soon.

This is a compound problem i think. In your example creating a string literal like this: "c:\a\b" is not going to work. This is because \a and \b are special control characters. So the solution here is to use raw strings by prepending an r before the string like this: r"c:\a\b" which disables all special control characters or to double escape the backslash like this: "c:\a\b". This was also a problem on my end in that Tcl/Tk was parsing these special characters as well. I've added some code to escape backslashes and other special Tcl characters to avoid problems in the future.

— Reply to this email directly or view it on GitHubhttps://github.com/nomad-software/tkd/issues/20#issuecomment-43416175 .

nomad-software commented 10 years ago

I got your meaning though and tested it for myself and saw it was handling things wrong, thanks for the heads up.

ghost commented 10 years ago

NP. I work for a company that makes systems that a major US financial company uses. I frequently make tools/utilities for the systems. They are all Windows controllers. Because it is a financial outfit, they pretty much frown on installing large libraries like java, GTK, etc. on anything attached to their networks. When I make a tool, a small exe without a big library works best. D with SQLite and your TKD lib is a nice fit for making something quick and small.

I have made a couple of things using IUP, just using the C bindings. It took me a long time to make GUIs. I was going to make a D wrapper for IUP similar to yours when you came out with this.

I just finished my first tool with TKD although it is pretty simple, It allows user/technician to switch servers on a failure. Only took me a couple days to make though. Attached is a screenshot:

Appreciate the work you are doing with this project!

Dave Gregory

On Sat, May 17, 2014 at 2:20 PM, Gary Willoughby notifications@github.comwrote:

I got your meaning though and tested it for myself and saw it was handling things wrong, thanks for the heads up.

— Reply to this email directly or view it on GitHubhttps://github.com/nomad-software/tkd/issues/20#issuecomment-43417511 .