Sponsored Content
The Lounge What is on Your Mind? New Code Tags (Syntax Highlighting) Post 303019458 by Corona688 on Friday 29th of June 2018 01:11:45 PM
Old 06-29-2018
I may be in the minority here, but I'm not sure I like it - yet. It's a good idea, and the line numbering is especially helpful, but the feature needs to be thought through.

This disrupts our habitual use of [color=red] to highlight important changes, for one thing. Either it needs to be opt-in a la [code=bash] or the syntax highlighting colors should be more subdued.

And unless it's done very well, syntax highlighting can be misleading. The one thing which really needs to work perfectly here, the detection of lines and strings, has done a hash job. It looks great, until you think about it -- it's highlighting "shell code" inside quoted and unquoted string literals! It's finding strings inside strings! I really don't want to explain to new programmers why I'm right and the website is wrong.

Last edited by Corona688; 06-29-2018 at 02:58 PM..
This User Gave Thanks to Corona688 For This Post:
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Emacs color syntax highlighting

So... i cant get it to work. I had already posted this but it got deleted. Details: Im running SSH shell on Windows XP, connecting to a server whose term is vt100 (someone asked me that last time) Im trying to get the syntax highlighting in cc mode to work in color, but its black and... (0 Replies)
Discussion started by: viejid
0 Replies

2. UNIX for Dummies Questions & Answers

color highlighting with 'more','grep' and 'vi'

Hi all, i would to find out how can i turn on color hightlighting with the 'more' command. When i view a big file, i tend to use the 'more' command and i would search for a interested string with the '/' command. Something the search returns more than 1 line found on the screen, how can i... (0 Replies)
Discussion started by: new2ss
0 Replies

3. Programming

Vim highlighting annoyance

I was using vim about an hour ago doing abit of python (i only just started using vim). And I think i typed something wrong, and all of a sudden the letter i is always highlighted. Turning syntax off and on didn't work. and i couldent find the solution online. Thanks in advanced. (1 Reply)
Discussion started by: vimhelp
1 Replies

4. UNIX and Linux Applications

gedit/gtksourceview: Updating types for syntax highlighting?

I wrote a new .lang file for syntax highlighting a language I use frequently. It works fine, except that it doesn't glob onto the files automatically. Is there a utility I need to run to update a gtksourceview database? Here's the relevant portion of the code. <language id="pari"... (0 Replies)
Discussion started by: CRGreathouse
0 Replies

5. Shell Programming and Scripting

How to stop Vim from highlighting lines 73+

I am slowly developing my .vimrc and would like to know how to turn off the highlighting (black text on orange background) which starts at line 73. This doesn't seem to be controlled by any selected/customized colorscheme. I do CFD, and some older codes I use are written in F77, for which this... (2 Replies)
Discussion started by: drbones
2 Replies

6. AIX

[Vim] Question about syntax highlighting

Hi all, my sysadmin installed Vim packages (vim-enhanced-6.3-1 & vim-common-6.3-1) on an Aix system (7.1.0.0). I log in using Putty (vs 0.54) and got an annoying underline issue. All strings and var names are underlined as you can see on the attached file Is it possible to get rid of that... (4 Replies)
Discussion started by: Fundix
4 Replies

7. UNIX for Dummies Questions & Answers

Reapplying syntax highlighting in vim

I had a bash script (ma_report.sh) that I was editing when my VPN connection died. So, when I reconnected, I recovered my changes and reopened the file. Everything looks fine except that there is no longer any syntax highlighting. Using ':syntax on' does not work. Other bash scripts in vim do... (1 Reply)
Discussion started by: treesloth
1 Replies

8. Shell Programming and Scripting

Highlighting duplicate string on a line

Hi all I have a grep written to pull out values; below (in the code snip-it) is an example of the output. What I'm struggling to do, and looking for assistance on, is identifying the lines that have duplicate strings. For example 74859915K74859915K in the below is 74859915K repeated twice but... (8 Replies)
Discussion started by: brighty
8 Replies
ctext(n)					   Ctext a text widget with highlighting support					  ctext(n)

__________________________________________________________________________________________________________________________________________________

NAME
ctext - Ctext a text widget with highlighting support SYNOPSIS
package require Tk package require ctext ?3.2? ctext pathName ?options? ::ctext::addHighlightClass pathName class color keywordlist ::ctext::addHighlightClassWithOnlyCharStart pathName class color char ::ctext::addHighlightClassForSpecialChars pathName class color charstring ::ctext::addHighlightClassForRegexp pathName class color pattern ::ctext::clearHighlightClasses pathName ::ctext::getHighlightClasses pathName ::ctext::deleteHighlightClass pathName class ::ctext::enableComments enable ::ctext::disableComments enable pathName highlight startIndex endIndex pathName fastdelete index1 ?index2? pathName fastinsert pathName copy pathName cut pathName paste pathName append pathName configure option value ?...? _________________________________________________________________ DESCRIPTION
The ctext package provides the ctext widget which is an enhanced text widget with support for configurable syntax highlighting and some extra commands. Ctext overloads the text widget and provides new commands, named highlight, copy, paste,cut, append, and edit. It also provides several commands that allow you to define classes. Each class corresponds to a tag in the widget. COMMANDS
ctext pathName ?options? Creates and configures a ctext widget. HIGHLIGHTING
Highlighting is controlled with text widget tags, that are called highlight classes. The class is a tag name and can be configured like any text widget tag. Four types of highlight classes are supported. All highlight classes are automatically used by the highlight method of the widget. ::ctext::addHighlightClass pathName class color keywordlist Add a highlighting class class to the ctext widget pathName. The highligthing will be done with the color color. All words in the keywordlist will be highlighted. # highlight some tcl keywords ::ctext::addHighlightClass .t tclkeywords red [list set info interp uplevel upvar]] ::ctext::addHighlightClassWithOnlyCharStart pathName class color char Add a highlighting class class to the ctext widget pathName. The highligthing will be done with the color color. All words starting with char will be highlighted. ::ctext::addHighlightClassWithOnlyCharStart .t vars blue $ ::ctext::addHighlightClassForSpecialChars pathName class color charstring Add a highlighting class class to the ctext widget pathName. The highligthing will be done with the color color. All chars in charstring will be highlighted. ::ctext::addHighlightClassForRegexp pathName class color pattern Add a highlighting class class to the ctext widget pathName. The highligthing will be done with the color color. All text parts matching the regexp pattern will be highligthed. ::ctext::clearHighlightClasses pathName Remove all highlight classes from the widget pathName. ::ctext::getHighlightClasses pathName List all highlight classes for the widget pathName. ::ctext::deleteHighlightClass pathName class Delete the highlight class class from the widget pathName ::ctext::enableComments enable Enable C comment highlighting. The class for c-style comments is _cComment. The C comment highlighting is disabled by default. ::ctext::disableComments enable Disable C comment highlighting. WIDGET COMMANDS
Each ctext widget created with the above command supports the following commands and options in addition to the standard text widget com- mands and options. pathName highlight startIndex endIndex Highlight the text between startIndex and endIndex. pathName fastdelete index1 ?index2? Delete text range without updating the highlighting. Arguments are identical to the pathName delete command inherited from the stan- dard text widget. pathName fastinsert Insert text without updating the highlighting. Arguments are identical to the pathName insert command inherited from the standard text widget. pathName copy Call tk_textCopy for the ctext instance. pathName cut Call tk_textCut for the ctext instance. pathName paste Call tk_textPaste for the ctext instance. pathName append Append the current selection to the clipboard. pathName configure option value ?...? Set the options for the ctext widget. Each option name must be followed the new value. WIDGET OPTIONS
Command-Line Switch: -linemap Database Name: Database Class: Creates (-linemap 1) or deletes (-linemap 0) a line number list on the left of the widget. The default is to have a linemap dis- played. Command-Line Switch: -linemapfg Database Name: Database Class: Changes the foreground of the linemap. The default is the same color as the main text widget. Command-Line Switch: -linemapbg Database Name: Database Class: Changes the background of the linemap. The default is the same color as the main text widget. Command-Line Switch: -linemap_select_fg Database Name: Database Class: Changes the selected line foreground. The default is black. Command-Line Switch: -linemap_select_bg Database Name: Database Class: Changes the selected line background. The default is yellow. Command-Line Switch: -linemap_mark_command Database Name: Database Class: Calls a procedure or command with the pathName of the ctext window, the type which is either marked or unmarked, and finally the line number selected. The proc prototype is: proc linemark_cmd {win type line}. See also ctext_test_interactive.tcl Command-Line Switch: -highlight Database Name: Database Class: Takes a boolean value which defines whether or not to highlight text which is inserted or deleted. The default is 1. Command-Line Switch: -linemap_markable Database Name: Database Class: Takes a boolean value which specifies whether or not lines in the linemap are markable with the mouse. The default is 1. EXAMPLE
package require Tk package require ctext proc main {} { pack [frame .f] -fill both -expand 1 pack [scrollbar .f.s -command {.f.t yview}] -side right -fill y pack [ctext .f.t -bg black -fg white -insertbackground yellow -yscrollcommand {.f.s set}] -fill both -expand 1 ctext::addHighlightClass .f.t widgets purple [list ctext button label text frame toplevel scrollbar checkbutton canvas listbox menu menubar menubutton radiobutton scale entry message tk_chooseDir tk_getSaveFile tk_getOpenFile tk_chooseColor tk_optionMenu] ctext::addHighlightClass .f.t flags orange [list -text -command -yscrollcommand -xscrollcommand -background -foreground -fg -bg -highlightbackground -y -x -highlightcolor -relief -width -height -wrap -font -fill -side -outline -style -insertwidth -textvariable -activebackground -activeforeground -insertbackground -anchor -orient -troughcolor -nonewline -expand -type -message -title -offset -in -after -yscroll -xscroll -forward -regexp -count -exact -padx -ipadx -filetypes -all -from -to -label -value -variable -regexp -backwards -forwards -bd -pady -ipady -state -row -column -cursor -highlightcolors -linemap -menu -tearoff -displayof -cursor -underline -tags -tag] ctext::addHighlightClass .f.t stackControl red {proc uplevel namespace while for foreach if else} ctext::addHighlightClassWithOnlyCharStart .f.t vars mediumspringgreen "$" ctext::addHighlightClass .f.t variable_funcs gold {set global variable unset} ctext::addHighlightClassForSpecialChars .f.t brackets green {[]{}} ctext::addHighlightClassForRegexp .f.t paths lightblue {.[a-zA-Z0-9\_-]+} ctext::addHighlightClassForRegexp .f.t comments khaki {#[^ ]*} .f.t fastinsert end [info body main] pack [frame .f1] -fill x .f.t highlight 1.0 end pack [button .f1.exit -text Exit -command exit] -side left pack [entry .e] -side bottom -fill x .e insert end "ctext::deleteHighlightClass .f.t " bind .e <Return> {eval [.e get]} } main Further examples are in the source package for ctext. THANKS
Kevin Kenny, Neil Madden, Jeffrey Hobbs, Richard Suchenwirth, Johan Bengtsson, Mac Cody, Gunther, Andreas Sievers, and Michael Schlenker. SEE ALSO
re_syntax, text KEYWORDS
syntax highlighting, text, widget COPYRIGHT
Copyright (c) George Peter Staplin <GeorgePS@XMission.com> ctext 3.2 ctext(n)
All times are GMT -4. The time now is 05:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy