color schemes
I hope user can change background color as well as the color of normal
text and highlighted text, and can save and load color schemes.
Original issue reported on code.google.com by [email protected] on 10 Aug 2009 at 12:29
Currently, the syntax highlighting colors are configurable (see the file
syntax-patterns.txt in the texworks configuration folder), but the basic text
and
background colors are not, they are simply black and white.
I guess some people like to edit with white (or green, or whatever) on black
instead,
so perhaps we should make this configurable. I'm not sure I'd want to bother
with
creating user interface just for this, though; more likely, just provide a
couple of
entries in texworks-config.txt.
Original comment by [email protected] on 19 Aug 2009 at 12:57
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
I'd like it if it were more configurable than it is now in syntax-patterns.txt;
for
example, I prefer to use the Tango palette for syntax highlighting, and I like
to be
able to specify that certain styles should be displayed bold or italic.
Original comment by [email protected] on 6 Nov 2009 at 1:00
I just read (http://doc.trolltech.com/4.5/qcolor.html#details) that you can use
the
"#rrggbb" notation for the colors as well. I'm not sure if this works for all
versions of Qt, but you could give it a try to see if you can get Tango colors.
Original comment by st.loeffler on 6 Nov 2009 at 6:27
Note that you must prefix a space character if defining a foreground color;
otherwise
the line will be interpreted as a comment line.
Original comment by st.loeffler on 6 Nov 2009 at 6:29
The attached patch should:
1) add the possibility for setting bold, italic, underline formats in
syntax-patterns.txt
2) update the comments in syntax-patterns.txt to include these new feature and
the
possibility of hex color values.
Original comment by st.loeffler on 6 Nov 2009 at 8:16
Attachments:
This looks fine, thanks! Just one thought - how about using comma rather than
vertical-bar as the separator
between colors and style flags? Seems to me that
blue/yellow,B
looks a lot more readable than
blue/yellow|B
in the config file. What do you think?
Original comment by [email protected] on 6 Nov 2009 at 8:31
You're right that the comma is more readable. I did experiment with additional
color
specifications first (in the form of "rgb(1,0,0)", among other things, before I
found
out about the possibility of natively specifying hex values. To not bar further
enhancements here with more elaborate style specifications, I thought a
not-so-common
character would be better. How about a semi-colon ";" as a separator?
Original comment by st.loeffler on 7 Nov 2009 at 8:10
The semicolon sounds good; I've committed it with this option. (Slightly edited
your patch, so I hope I didn't
break anything.... seems to work for me.)
Original comment by [email protected] on 21 Nov 2009 at 6:46
Any possibility of adding support for what was originally requested: changing
the
main editor background and text colors?
I've discovered that I can change them by globally changing the color settings
for
GNOME (I'm using Ubuntu 9.10 Karmic) under System > Preferences > Appearance >
Theme
> Customize > Color > Input Boxes, but then the change affects all programs,
not just
TeXworks.
Even then, however, I don't know how to change the colors on the currently
highlighted line, if that option is enabled.
Original comment by [email protected] on 21 Nov 2009 at 6:56
I'm aware that the request to configure the main text and background colors
hasn't been implemented yet;
one issue with this is that I think the Qt styling features vary across
platforms, so it needs to be checked
carefully to ensure uniform behavior.
The color used to highlight the line with the insertion point is (currently)
hard-coded, along with a few other
colors (e.g., the color used to indicate a tentative completion, and the color
used to highlight matching braces
as you type).
Ideally, all these should be made configurable, I guess.
Original comment by [email protected] on 21 Nov 2009 at 8:23
I just found out that it is already possible to change the color of the
background
and the color of the text using stylesheets (see
http://doc.trolltech.com/4.5/stylesheet.html). If you create, e.g., a file
test.css
in the directory of your Tw executable containing the following:
QTextEdit {
background-color: black;
color: white;
}
and then run Tw with `./texworks -stylesheet test.css` or `TeXworks.exe
-stylesheet
test.css` (depending on your platform) you will get white text on a black
background.
We could add this as a configuration option so that the stylesheet is loaded
automatically on startup, without the need to specify the "-stylesheet <file>"
parameter on the command line. However, I'd consider this a fairly expert option
which most normal users won't need/understand, and therefore am reluctant to
add this
to the preferences dialog.
Of course this doesn't provide a possibility to customize the hard-coded colors
Jonathan mentioned. I agree that we should make them customizable somehow, too.
Original comment by st.loeffler on 22 Nov 2009 at 8:46
Wow, that is really useful information. Thanks a lot.
You can even use a background image if you want with:
background-image: url('filename')
...though of course you need to choose really wisely.
At the moment you're still pretty limited in your choices if you want to
highlight
the current line, but I suppose I can live without that until you get around to
making those customizable.
Original comment by [email protected] on 27 Nov 2009 at 1:56
Hello,
I use Windows XP SP2 and Texworks 0.3 r670 installed with miktex 2.9.
I tried the stylesheet trick, and I have a problem: Texworks starts normally
with black background and white text, but it also opens test.css. I tried to
move the file to an another place and give the full path also with quotes (for
example "c:\test.css"), but Texworks still opens test.css.
I modified the file association settings of XP to Texworks opens .tex files
using the -stylesheet test.css argument too, but when I open something,
test.css opens too.
How to use the arguments to prevent opening the css file?
Original comment by [email protected] on 12 Nov 2010 at 7:11
Strange, AFAIK, the -stylesheet option should be handled automatically and not
passed to the Tw command line parser. Could you test this with a non-MiKTeX
build (like on http://web.student.tuwien.ac.at/~e0325258/projects/c/texworks/)
to see if this is only MiKTeX-related?
Original comment by st.loeffler on 13 Nov 2010 at 9:37
I tested with that build on XP and on Windows 7 too, and I get the same problem.
Original comment by [email protected] on 13 Nov 2010 at 7:23
OK, I can confirm this. While, e.g., on Linux, the complete "-stylesheet
test.css" string is handled automatically and removed from the command line
options that are passed to Tw itself, on Windows apparently only the
"-stylesheet" part is removed, but the filename is (erronously) retained.
As such, this seems to be a Qt problem and should be reported to its developers.
Original comment by st.loeffler on 14 Nov 2010 at 1:51
Would be great if TeXworks could read vim colour schemes.
Original comment by [email protected] on 21 Jan 2011 at 2:56
Hello Stefan,
I'm not entirely sure that this is a Qt problem, since with previous versions
of TW the trick worked just fine (in Windows). That is, until the recent update
of TW, Windows did not erroneously retain the filename and open the CSS file in
TW. But now - with the recent version of TW (0.4.0 r759) - Windows opens the
CSS file in TW.
I too would be very keen on having the option for background colour change
somehow implemented, since I prefer to work with a black background!
Thanks for the work you do on TW!
Craig
Original comment by [email protected] on 23 Apr 2011 at 6:02
I assume you mean it worked in Tw 0.2.3, but not in 0.4.0 - there has been
quite a while between these releases, and consequently they have been built
with different versions of Qt. Apparently, this bug was introduced in Qt at
some point.
I did some more testing, and reported the problem (with minimal example) at
http://bugreports.qt.nokia.com/browse/QTBUG-18935. We'll see.
In the meantime, you could try something like "-stylesheet=style.css". You
would likely get an error message, but this can be dismissed easily and Tw
should not open the stylesheet file. Or you stick with "-stylesheet style.css"
and close the style file every time. In any case, the _styles_ should be
respected.
Original comment by st.loeffler on 28 Apr 2011 at 5:09
Hi everyone, people are talking about "syntax-patterns.txt in the texworks
configuration folder" which I can't find on my Mac!. I can only find "cat
~/Library/Preferences/org.tug.TeXworks.plist" which is in binary. Where this
file in order to add some colors to my TexWorks editor?
Thank you,
Savanna
Original comment by [email protected] on 6 Apr 2012 at 7:17
This should actually read: syntax-patterns.txt in the configuration
subdirectory of the TeXworks resource folder.
According to the manual and the wiki page TipsAndTricks, the resources are
stored in ~/Library/TeXworks/ on Mac OS X. The file you found only stores the
preferences.
In recent versions of TeXworks, it should be easy to locate that resource
folder using "Help > Settings and Resources..."
Original comment by st.loeffler on 7 Apr 2012 at 7:20
Hi Guys,
is there a way to implement the syntax highlighting scheme from vim via
software or do you have to set up everything manually?
I'd really appreciate a faster way to do this, since I like the vim syntax
highlighting a lot.
Thanks, Jakob
Original comment by [email protected] on 20 Nov 2012 at 12:41
Could anyone be kind enough to stop mentioning http://doc.trolltech.com/ --
which seems to be a dead link -- and please either copy here the information,
or refer to a living link? I changed the text and background color to a shceme
that closer resembles Linux vi, but now the highlighted text doesn't show, as
it isn white on black, same as my environment.
I only wish to edit LaTeX with TexWorks r.1280. I don't want to learn QT, or
get lost in thousands of search results that don't really help.
Original comment by [email protected] on 18 Mar 2014 at 12:54
I'm also interested in getting a different "theme" for TeXworks, and also finding dead links in the thread above.
Just for info, the "trollltech" dead links can be found in the Wayback Machine:, e.g. http://doc.trolltech.com/4.5/stylesheet.html. It seems the current official "live" equivalent page is for QT 4.8.
I'm a bit surprised there isn't a collection of "themes" for TeXworks yet - it is such a common thing in the "editor" world!
A dark theme for the full editor (not just the text editor) would be awesome.
At the moment (using v0.5 r.1350 un Ubuntu 14.04), loading a css stylesheet as suggested seems to work initially but soon seg faults.
Using stylesheets is not so straightforward and "good". The theme support would be awesome. Especially a dark theme. Like the one of the comments above says, "I only wish to edit LaTeX with TexWorks r.1280. I don't want to learn QT, or get lost in thousands of search results that don't really help."