digitalmars.D.learn - Using CSS Data from Within My Code
- Ron Tarrant (9/17) Sep 12 2019 But when I try to use it, I get the following errors:
- Max Samukha (4/21) Sep 12 2019 q{} is a string that must only contain valid D tokens. D lexer
- Andrea Fontana (3/20) Sep 12 2019 They are named "token string" and contained code must be a valid
- Ron Tarrant (24/51) Sep 12 2019 Thanks, Andrea and Max.
- Ron Tarrant (17/52) Sep 12 2019 That should have been:
- Mike Parker (6/7) Sep 12 2019 enum will work just as well here and without the need for the
- Ron Tarrant (3/13) Sep 12 2019 Ah! Thanks for clearing that up, Mike. My D knowledge is still
- =?UTF-8?Q?Ali_=c3=87ehreli?= (4/5) Sep 12 2019 I think my index can be useful in such searches. Both q"" and q{} are th...
- Ron Tarrant (3/10) Sep 13 2019 Thanks, Ali. I suppose I should be looking in your book first
I found this presented as a solution in a 2016 post: On Wednesday, 15 June 2016 at 22:05:37 UTC, captaindet wrote:enum myCSS = q{ GtkNotebook { background-color: #e9e9e9; } GtkNotebook tab { background-color: #d6d6d6; } };But when I try to use it, I get the following errors: Warning: C preprocessor directive #e9e9e9 is not supported Warning: C preprocessor directive #d6d6d6 is not supported I thought it was odd having 'q' in front of the opening curly brace... is this a typo? Shorthand for "string quote"? Something like that? Or do I need to escape these somehow?
Sep 12 2019
On Thursday, 12 September 2019 at 09:54:35 UTC, Ron Tarrant wrote:I found this presented as a solution in a 2016 post: On Wednesday, 15 June 2016 at 22:05:37 UTC, captaindet wrote:q{} is a string that must only contain valid D tokens. D lexer does not like C directives. https://dlang.org/spec/lex.html#token_stringsenum myCSS = q{ GtkNotebook { background-color: #e9e9e9; } GtkNotebook tab { background-color: #d6d6d6; } };But when I try to use it, I get the following errors: Warning: C preprocessor directive #e9e9e9 is not supported Warning: C preprocessor directive #d6d6d6 is not supported I thought it was odd having 'q' in front of the opening curly brace... is this a typo? Shorthand for "string quote"? Something like that? Or do I need to escape these somehow?
Sep 12 2019
On Thursday, 12 September 2019 at 09:54:35 UTC, Ron Tarrant wrote:I found this presented as a solution in a 2016 post: On Wednesday, 15 June 2016 at 22:05:37 UTC, captaindet wrote:They are named "token string" and contained code must be a valid d code. See https://dlang.org/spec/lex.html#token_stringsenum myCSS = q{ GtkNotebook { background-color: #e9e9e9; } GtkNotebook tab { background-color: #d6d6d6; } };But when I try to use it, I get the following errors: Warning: C preprocessor directive #e9e9e9 is not supported Warning: C preprocessor directive #d6d6d6 is not supported I thought it was odd having 'q' in front of the opening curly brace... is this a typo? Shorthand for "string quote"? Something like that? Or do I need to escape these somehow?
Sep 12 2019
On Thursday, 12 September 2019 at 10:09:06 UTC, Andrea Fontana wrote:On Thursday, 12 September 2019 at 09:54:35 UTC, Ron Tarrant wrote:Thanks, Andrea and Max. Turns out there's a simpler way to inject CSS into D code. In case anyone else comes looking, I found that instead of an enum, a string will do. Here's the solution I came up with to make visible tabs in a Notebook: class CSS // GTK4 compliant { CssProvider provider; string cssPath = "./css/visible_tabs.css"; string myCSS = "tab { background-color: #f2f2f2; }"; this(StyleContext styleContext) { provider = new CssProvider(); provider.loadFromData(myCSS); styleContext.addProvider(provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } // this() } // class CSS And in the class that will use it, this line does it: css = new CSS(getStyleContext());I found this presented as a solution in a 2016 post: On Wednesday, 15 June 2016 at 22:05:37 UTC, captaindet wrote:They are named "token string" and contained code must be a valid d code. See https://dlang.org/spec/lex.html#token_stringsenum myCSS = q{ GtkNotebook { background-color: #e9e9e9; } GtkNotebook tab { background-color: #d6d6d6; } };But when I try to use it, I get the following errors: Warning: C preprocessor directive #e9e9e9 is not supported Warning: C preprocessor directive #d6d6d6 is not supported I thought it was odd having 'q' in front of the opening curly brace... is this a typo? Shorthand for "string quote"? Something like that? Or do I need to escape these somehow?
Sep 12 2019
On Thursday, 12 September 2019 at 11:35:04 UTC, Ron Tarrant wrote:On Thursday, 12 September 2019 at 10:09:06 UTC, Andrea Fontana wrote:That should have been: class CSS // GTK4 compliant { CssProvider provider; string myCSS = "tab { background-color: #f2f2f2; }"; this(StyleContext styleContext) { provider = new CssProvider(); provider.loadFromData(myCSS); styleContext.addProvider(provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } // this() } // class CSS The CSS path/file name isn't needed.On Thursday, 12 September 2019 at 09:54:35 UTC, Ron Tarrant wrote:Thanks, Andrea and Max. Turns out there's a simpler way to inject CSS into D code. In case anyone else comes looking, I found that instead of an enum, a string will do. Here's the solution I came up with to make visible tabs in a Notebook:I found this presented as a solution in a 2016 post: On Wednesday, 15 June 2016 at 22:05:37 UTC, captaindet wrote:They are named "token string" and contained code must be a valid d code. See https://dlang.org/spec/lex.html#token_stringsenum myCSS = q{ GtkNotebook { background-color: #e9e9e9; } GtkNotebook tab { background-color: #d6d6d6; } };But when I try to use it, I get the following errors: Warning: C preprocessor directive #e9e9e9 is not supported Warning: C preprocessor directive #d6d6d6 is not supported I thought it was odd having 'q' in front of the opening curly brace... is this a typo? Shorthand for "string quote"? Something like that? Or do I need to escape these somehow?
Sep 12 2019
On Thursday, 12 September 2019 at 11:40:33 UTC, Ron Tarrant wrote:string myCSS = "tab { background-color: #f2f2f2; }";enum will work just as well here and without the need for the variable: enum myCSS = "tab { background-color: #f2f2f2; }"; The original error was because q strings have to be valid D, not because of the enum.
Sep 12 2019
On Thursday, 12 September 2019 at 13:09:16 UTC, Mike Parker wrote:On Thursday, 12 September 2019 at 11:40:33 UTC, Ron Tarrant wrote:Ah! Thanks for clearing that up, Mike. My D knowledge is still rather sparse, so this fills in another blank for me.string myCSS = "tab { background-color: #f2f2f2; }";enum will work just as well here and without the need for the variable: enum myCSS = "tab { background-color: #f2f2f2; }"; The original error was because q strings have to be valid D, not because of the enum.
Sep 12 2019
On 09/12/2019 02:54 AM, Ron Tarrant wrote:I thought it was odd having 'q' in front of the opening curly brace...I think my index can be useful in such searches. Both q"" and q{} are there: http://ddili.org/ders/d.en/ix.html Ali
Sep 12 2019
On Thursday, 12 September 2019 at 19:14:26 UTC, Ali Çehreli wrote:On 09/12/2019 02:54 AM, Ron Tarrant wrote:Thanks, Ali. I suppose I should be looking in your book first when I have a question... as I so often do.I thought it was odd having 'q' in front of the opening curlybrace... I think my index can be useful in such searches. Both q"" and q{} are there: http://ddili.org/ders/d.en/ix.html Ali
Sep 13 2019