Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5588
| From | "andre.robin3" <andre.robin3@wanadoo.fr> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Suppressing quotes around strings in Input style. |
| Date | 2011-10-11 08:26 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j70uk3$s3$1@smc.vnet.net> (permalink) |
| References | <j6uffk$ggg$1@smc.vnet.net> |
Concerning the colors, you may use :
$PrePrint = (# /. x_String :> Style[x, Red] &)
?
"mmausr" <opngid@gmail.com> a écrit dans le message de news:
j6uffk$ggg$1@smc.vnet.net...
> Mathematica suppresses the quotes surrounding a string by default in
> the Output style. Quotes surrounding strings in the Input style can
> be suppressed as well by setting the ShowStringCharacters option to
> False in the notebook's style sheet for the Input style.
>
> This approach is not entirely satisfactory, however, for the following
> reasons. (i) Entering a double quote in an Input style cell after
> setting the ShowStringCharacters flag to False will register an error
> in the front end. (ii) It would be helpful to retain the color
> change that is used for strings (gray by default) while the double
> quotes are suppressed, but this does not appear to be possible with
> the ShowStringCharacters flag set to False. In fact, manually
> attempting to change the color of a string with the
> ShowStringCharacters flag set to false will also register an error in
> the front end. (iii) Inserting a file path does does not work
> properly because of the explicit double quotes that surround the file
> path string; this appears to be a special case of (i).
>
> What would be useful is to have a special character that is invisible
> that functionally acts like the double quote. Special characters
> already exist as invisible equivalents for the @ symbol for function
> application, the comma for argument separation, and the times operator
> for multiplication. These invisible equivalents are respectively: \
> [InvisibleApplication] \[InvisibleComma] \[InvisibleTimes].
>
> It appears that the special character \:f3b5 somewhat plays the role
> of a non-existent \[InvisibleDoubleQuote] character, but its precise
> behavior depends on whether or not the ShowStringCharacters flag is
> set. For example, if the flag is True, then a single \:f3b5 is
> invisible, but entering a second (matching) \:f3b5 will make the pair
> of double quotes visible.
>
> Defining the following syntax transformation in
> KeyEventTransformations.tr creates a pair of invisible double quotes:
>
> Item[KeyEvent["`",Modifiers->{Control}],
> FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],"\:f3b5\
> [SelectionPlaceholder]
> \:f3b5"],FrontEndToken["MovePreviousPlaceHolder"]}]]
>
> Perhaps the color change could be defined in here, but I'm not sure
> how. I'd also like to have the ability to insert double quotes for
> certain situations into a notebook with the ShowStringCharacters flag
> set to False, not just to insert file paths (that's easy to clean up
> by just deleting the surrounding quotes and copying the result between
> two \:f3b5 characters) but for strings that represent text messages.
>
> My primary interest in being able to remove quotes around certain
> strings is because I'd prefer to use strings as field names for
> structs in an OO package that I'm developing instead of using
> Protected symbols -- much for the same reason that many built-in
> functions are using strings for option names instead of symbols in
> later versions of Mathematica.
>
> Any thoughts?
>
>
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Suppressing quotes around strings in Input style. mmausr <opngid@gmail.com> - 2011-10-10 09:56 +0000
Re: Suppressing quotes around strings in Input style. "Chris Degnen" <degnen@cwgsy.net> - 2011-10-11 08:26 +0000
Re: Suppressing quotes around strings in Input style. "andre.robin3" <andre.robin3@wanadoo.fr> - 2011-10-11 08:26 +0000
Re: Suppressing quotes around strings in Input style. mmausr <opngid@gmail.com> - 2011-10-16 11:14 +0000
csiph-web