Re: My friend can't install DMD 2.076.0 after he deleted contents of C:\D
On Sunday, 17 September 2017 at 05:30:51 UTC, Enjoys Math wrote: Series of messages from installer: DMD v2.076.0 is installed on your system Press 'OK' to replace by DMD 2.076.0 An error occurred when removing DMD v2.076.0 Run 'dmd-2.076.0.exe /f to force install And using the command line has no effect - it repeats the above. He got into this situation by accidentally installing Visual Studio and / or Visual D to C:\D where I told him to install D to. At one point I told him to delete everything in C:\D and start over. *That* was a mistake... He's used a trial version of Revo-Uninstaller to remove contents of registry. The issue remains. How can we repair his system so that we can install D on it again? Thanks. I sent him a copy of uninstall.exe from my D install root and Revo then "removed D from the list" so that seemed to work. We ran D installer again and it worked!
My friend can't install DMD 2.076.0 after he deleted contents of C:\D
Series of messages from installer: DMD v2.076.0 is installed on your system Press 'OK' to replace by DMD 2.076.0 An error occurred when removing DMD v2.076.0 Run 'dmd-2.076.0.exe /f to force install And using the command line has no effect - it repeats the above. He got into this situation by accidentally installing Visual Studio and / or Visual D to C:\D where I told him to install D to. At one point I told him to delete everything in C:\D and start over. *That* was a mistake... He's used a trial version of Revo-Uninstaller to remove contents of registry. The issue remains. How can we repair his system so that we can install D on it again? Thanks.
Re: My friend can't install DMD 2.076.0 after he deleted contents of C:\D
On 17/09/2017 6:30 AM, Enjoys Math wrote: Series of messages from installer: DMD v2.076.0 is installed on your system Press 'OK' to replace by DMD 2.076.0 An error occurred when removing DMD v2.076.0 Run 'dmd-2.076.0.exe /f to force install And using the command line has no effect - it repeats the above. He got into this situation by accidentally installing Visual Studio and / or Visual D to C:\D where I told him to install D to. At one point I told him to delete everything in C:\D and start over. *That* was a mistake... He's used a trial version of Revo-Uninstaller to remove contents of registry. The issue remains. How can we repair his system so that we can install D on it again? Thanks. Skip Revo-Uninstaller, no idea why you'd ever use such trial software. Anyway what you want is CCleaner, standard software that all Windows installs should have on hand. That should remove all references to VS quite happily. It does a lot more than just modify the registry too :)
Novel Undo
Is there a way to integrate a undo/redo system in an already existing app without a huge amount of recording to support it? I.e., converting to using commands. I'd like to specify what is going to be modified and what needs to be done to restore the state. Given D's strong meta capabilities, I wonder if much of this can be alleviated? A struct that monitors it's own changes and possibly designing something using reversible delegates.
Re: Temporarily adding -vgc to a DUB build
On Saturday, 16 September 2017 at 21:45:34 UTC, Nordlöw wrote: How do I temporarily enable -vgc when building my app with DUB? I've tried DFLAGS=-vgc /usr/bin/dub build --build=unittest but it doesn't seem to have any effect as it doesn't rebuild directly after the call /usr/bin/dub build --build=unittest I'm using DUB version 1.5.0 Or is adding a new build configuration, say unittest-vgc, the only way to accomplish this? Setting the dflags in the dub.json should work. This is what I use for dcompute: { ... "dflags" : ["-mdcompute-targets=cuda-210" ,"-oq", "-betterC"], ... } so just change those flags to "-vgc" should do the trick.
Re: Convert user input string to Regex
On Saturday, 16 September 2017 at 03:23:14 UTC, Adam D. Ruppe wrote: On Saturday, 16 September 2017 at 03:18:31 UTC, Ky-Anh Huynh wrote: Is there a way to transform user input string to a regular expression? For example, I want to write a `grep`-like program import std.regex; auto re = regex(user_pattern, user_flags); You'll probably want to split it on the '/' to split the pattern and the flags since they are two separate variables to the regex function, but that's all you need to do. http://dpldocs.info/experimental-docs/std.regex.regex.2.html Thanks Adam. I will give it a try.
Temporarily adding -vgc to a DUB build
How do I temporarily enable -vgc when building my app with DUB? I've tried DFLAGS=-vgc /usr/bin/dub build --build=unittest but it doesn't seem to have any effect as it doesn't rebuild directly after the call /usr/bin/dub build --build=unittest I'm using DUB version 1.5.0 Or is adding a new build configuration, say unittest-vgc, the only way to accomplish this?
Re: Gtk toArray List funkiness
On Saturday, 16 September 2017 at 20:54:21 UTC, Mike Wey wrote: On 16-09-17 20:58, Joseph wrote: https://github.com/gtkd-developers/GtkD/blob/master/demos/gtkD/TestWindow/TestWindow.d has the code foreach ( int i, string selection ; fs.getSelections()) { writeln("File(s) selected [%d] %s",i,selection); } which is invalid for the demo, but foreach ( int i, string selection ; fd.getFilenames().toArray!(string,?)) { writeln("File(s) selected [%d] %s",i,selection); } results in some funky code. Gives errors in ObjectG about uint when setting ? to string, string* or void* or even uint: GtkD\generated\gtkd\gobject\ObjectG.d(172): Error: incompatible types for ((obj) is (null)): 'uint' and 'typeof(null)' GtkD\generated\gtkd\glib\ListSG.d(98): Error: template instance gobject.ObjectG.ObjectG.getDObject!(string, string, uint) error instantiating test.d(91): instantiated from here: toArray!(string, uint) test.d(93): Error: invalid foreach aggregate `fd.getFilenames()`, define opApply(), range primitives, or use .tupleof without specifying ? it assumes it's a tuple, which seems wrong? public T[] toArray(T, TC = typeof(T.tupleof[0]))() { T[] arr = new T[length()]; ListSG list = this; size_t count; while(list !is null && count < arr.length) { arr[count] = ObjectG.getDObject!(T)(cast(TC)list.data); list = list.next(); count++; } return arr; } foreach ( int i, Value selection ; fd.getFilenames().toArray!(Value)()) { writeln("File(s) selected [%d] %s",i,selection.getString); } crashes ;/ I'm not sure what types are what and it changes depending on the input. I think Value is the wrong type to use but string doesn't work so... ListG and ListSG are missing an toArray overload for string. And getFilenames returns a list of strings. I've added a string overload for toArray: https://github.com/gtkd-developers/GtkD/commit/ba20490b38e502a4d281226572c83c662a700858 public ListSG getFilenames() { auto p = gtk_file_chooser_get_filenames(getFileChooserStruct()); if(p is null) { return null; } return new ListSG(cast(GSList*) p, true); } Doesn't return a list of strings? That was the first thing I tried and the foreach loop wouldn't work over it because it was a ListSG. Thanks.
Re: Gtk toArray List funkiness
On 16-09-17 20:58, Joseph wrote: https://github.com/gtkd-developers/GtkD/blob/master/demos/gtkD/TestWindow/TestWindow.d has the code foreach ( int i, string selection ; fs.getSelections()) { writeln("File(s) selected [%d] %s",i,selection); } which is invalid for the demo, but foreach ( int i, string selection ; fd.getFilenames().toArray!(string,?)) { writeln("File(s) selected [%d] %s",i,selection); } results in some funky code. Gives errors in ObjectG about uint when setting ? to string, string* or void* or even uint: GtkD\generated\gtkd\gobject\ObjectG.d(172): Error: incompatible types for ((obj) is (null)): 'uint' and 'typeof(null)' GtkD\generated\gtkd\glib\ListSG.d(98): Error: template instance gobject.ObjectG.ObjectG.getDObject!(string, string, uint) error instantiating test.d(91): instantiated from here: toArray!(string, uint) test.d(93): Error: invalid foreach aggregate `fd.getFilenames()`, define opApply(), range primitives, or use .tupleof without specifying ? it assumes it's a tuple, which seems wrong? public T[] toArray(T, TC = typeof(T.tupleof[0]))() { T[] arr = new T[length()]; ListSG list = this; size_t count; while(list !is null && count < arr.length) { arr[count] = ObjectG.getDObject!(T)(cast(TC)list.data); list = list.next(); count++; } return arr; } foreach ( int i, Value selection ; fd.getFilenames().toArray!(Value)()) { writeln("File(s) selected [%d] %s",i,selection.getString); } crashes ;/ I'm not sure what types are what and it changes depending on the input. I think Value is the wrong type to use but string doesn't work so... ListG and ListSG are missing an toArray overload for string. And getFilenames returns a list of strings. I've added a string overload for toArray: https://github.com/gtkd-developers/GtkD/commit/ba20490b38e502a4d281226572c83c662a700858 -- Mike Wey
Gtk toArray List funkiness
https://github.com/gtkd-developers/GtkD/blob/master/demos/gtkD/TestWindow/TestWindow.d has the code foreach ( int i, string selection ; fs.getSelections()) { writeln("File(s) selected [%d] %s",i,selection); } which is invalid for the demo, but foreach ( int i, string selection ; fd.getFilenames().toArray!(string,?)) { writeln("File(s) selected [%d] %s",i,selection); } results in some funky code. Gives errors in ObjectG about uint when setting ? to string, string* or void* or even uint: GtkD\generated\gtkd\gobject\ObjectG.d(172): Error: incompatible types for ((obj) is (null)): 'uint' and 'typeof(null)' GtkD\generated\gtkd\glib\ListSG.d(98): Error: template instance gobject.ObjectG.ObjectG.getDObject!(string, string, uint) error instantiating test.d(91):instantiated from here: toArray!(string, uint) test.d(93): Error: invalid foreach aggregate `fd.getFilenames()`, define opApply(), range primitives, or use .tupleof without specifying ? it assumes it's a tuple, which seems wrong? public T[] toArray(T, TC = typeof(T.tupleof[0]))() { T[] arr = new T[length()]; ListSG list = this; size_t count; while(list !is null && count < arr.length) { arr[count] = ObjectG.getDObject!(T)(cast(TC)list.data); list = list.next(); count++; } return arr; } foreach ( int i, Value selection ; fd.getFilenames().toArray!(Value)()) { writeln("File(s) selected [%d] %s",i,selection.getString); } crashes ;/ I'm not sure what types are what and it changes depending on the input. I think Value is the wrong type to use but string doesn't work so...
Re: How to get DnD to work in GTKD?
On Saturday, 16 September 2017 at 17:08:52 UTC, Joseph wrote: On Saturday, 16 September 2017 at 14:33:53 UTC, Mike Wey wrote: On 16-09-17 06:33, Joseph wrote: [...] You will also need to set an TargetList to tell gtk that you want to receive text: ``` TargetList lst = new TargetList([]); lst.addTextTargets(0); w..dragDestSetTargetList(lst); ``` for simple cases only `addOnDragDataReceived` will be needed, `addOnDragDataGet` is only used for the source and `addOnDragDrop` can be used to filter the things that can be droped. List and Treeviews there are funtions like `getDragDestRow` available with the TreeView widget. Thanks, I added the code above but it didn't seem to get the handlers called. Is there anything else I'm suppose to be doing to initialize things or is it an issue with just getting the correct target setup? if I drag a file I get the drag icon but no "output" from the callbacks. If I drag selected text from firefox to it, I get the not valid drag sign. Ok, so I dragged some text from the same app and it worked! Even though I set TargetEntry te = new TargetEntry("text", GtkTargetFlags.OTHER_APP, 0); So, seems to be a settings/setup issue.
Re: How to get DnD to work in GTKD?
On Saturday, 16 September 2017 at 14:33:53 UTC, Mike Wey wrote: On 16-09-17 06:33, Joseph wrote: I've used null in place of [te]. I'm not sure what target entry is for and if that is the problem or what. I am trying to drag files from windows explorer to a grid or label(I duplicated the code above for the label) and none the callbacks are ever called. I only need the filename of the file being dragged. I will eventually also need to drag one list element to another(virtually so, I just need to know the index that was dragged). Thanks. You will also need to set an TargetList to tell gtk that you want to receive text: ``` TargetList lst = new TargetList([]); lst.addTextTargets(0); w..dragDestSetTargetList(lst); ``` for simple cases only `addOnDragDataReceived` will be needed, `addOnDragDataGet` is only used for the source and `addOnDragDrop` can be used to filter the things that can be droped. List and Treeviews there are funtions like `getDragDestRow` available with the TreeView widget. Thanks, I added the code above but it didn't seem to get the handlers called. Is there anything else I'm suppose to be doing to initialize things or is it an issue with just getting the correct target setup? if I drag a file I get the drag icon but no "output" from the callbacks. If I drag selected text from firefox to it, I get the not valid drag sign.
Re: Binary serialization of a struct
On Saturday, 16 September 2017 at 03:30:51 UTC, Joseph wrote: Are there any simple direct serialization libraries... I want something straight forward without allot of plumbing on my end. You may also take a look at https://github.com/sdegtiarev/persistentObject This is small module for binary serialization.
Re: How to use the Among method with a string array
On Saturday, 16 September 2017 at 12:09:28 UTC, Adam D. Ruppe wrote: On Saturday, 16 September 2017 at 11:18:45 UTC, Andrew Chapman wrote: string[] fruit = ["apple", "pear", "strawberry"]; How do I use "among" to see if "apple" is present. E.g. I want to do this: if ("apple".among(fruit)) among doesn't take an array, but rather a list of arguments: "bar".among("foo", "bar", "baz") For searching in an array, you can use canFind: if(fruit.canFind("apple")) Thanks Adam!
Re: How to get DnD to work in GTKD?
On 16-09-17 06:33, Joseph wrote: I've used null in place of [te]. I'm not sure what target entry is for and if that is the problem or what. I am trying to drag files from windows explorer to a grid or label(I duplicated the code above for the label) and none the callbacks are ever called. I only need the filename of the file being dragged. I will eventually also need to drag one list element to another(virtually so, I just need to know the index that was dragged). Thanks. You will also need to set an TargetList to tell gtk that you want to receive text: ``` TargetList lst = new TargetList([]); lst.addTextTargets(0); w..dragDestSetTargetList(lst); ``` for simple cases only `addOnDragDataReceived` will be needed, `addOnDragDataGet` is only used for the source and `addOnDragDrop` can be used to filter the things that can be droped. List and Treeviews there are funtions like `getDragDestRow` available with the TreeView widget. -- Mike Wey
Re: Binary serialization of a struct
On Saturday, 16 September 2017 at 03:30:51 UTC, Joseph wrote: Are there any simple direct serialization libraries where I can mark elements of a class or struct that I want serialized with an attribute and it will take care of all the rest(including recursive structures, arrays, etc) then deserialize back in to the structs? I want something straight forward without allot of plumbing on my end. Have you checked Cerealed ? From the looks of it, it supports a @NoCereal attribute which does the opposite of what you're looking for. Not sure how it handles nested structs, but there are examples in the test/directory : https://github.com/atilaneves/cerealed/
Re: extern(C) enum
On Saturday, 16 September 2017 at 03:06:24 UTC, Timothy Foster wrote: You are correct, however 6.7.2.2 "Enumeration specifiers" states: "Each enumerated type shall be compatible with char, a signed integer type, or an unsigned integer type. The choice of type is implementation-defined, but shall be capable of representing the values of all the members of the enumeration." I believe that means that if you have the following: enum ABC { A, B, C } Then A, B, and C are by themselves ints, but the enum type ABC can be a char if the compiler decides that's what it wants it to be. Oops, you're right. Then the situation must be the same as in C++? If enum ABC is by itself a parameter of a function, the argument will be int (and if it weren't, it would be promoted to int anyway), but if the enum is a part of a structure, then it can be anything... At least, if enumerators themselves are ints, the enum type probably won't be larger than an int... small consolation :)
Re: How to use the Among method with a string array
On Saturday, 16 September 2017 at 11:18:45 UTC, Andrew Chapman wrote: string[] fruit = ["apple", "pear", "strawberry"]; How do I use "among" to see if "apple" is present. E.g. I want to do this: if ("apple".among(fruit)) among doesn't take an array, but rather a list of arguments: "bar".among("foo", "bar", "baz") For searching in an array, you can use canFind: if(fruit.canFind("apple"))
How to use the Among method with a string array
Hi all, sorry for the very simple question, but I'm looking at the "among" function in std.comparison: https://dlang.org/phobos/std_algorithm_comparison.html#among If I have a string array: string[] fruit = ["apple", "pear", "strawberry"]; How do I use "among" to see if "apple" is present. E.g. I want to do this: if ("apple".among(fruit)) However that wont compile - I'm missing something fundamental in my knowledge. It seems fruit has to be a Tuple? Is there a way to use a string array instead?