Sublime Forum

How do I add ignored characters to sublime-syntax / tmlanguage files so highlighting will process properly when the chars exist?

#1

This is in plugin development because it is for an upcoming feature - a new callback which lets you modify the indent-chars…

So

spaces or tabs Category
spaces or tabs indented level +1 from cat Entry
spaces or tabs indented level +1 from cat Entry
spaces or tabs indented level +1 from cat Entry

Although for the time being I’ve been converting it all to spaces so they can be copied / pasted into Steam chat client…

The new callback adds functionality to modify the spaces or tabs segment for all entries whether they’re categories, notes, standard entries in a category, nested category, etc…

The idea is to allow creating a tree-view for the output panel in order to provide a more compact view ( for those with smaller monitors or those who prefer it ) without making the data harder to read… With this type of tree-view everything is easy to follow and it’s clear where categories begin, end, and what entries belong to them… Using tabs or 2 to 4 spaces is also simple to follow, but with unlimited nesting support built-in ( and making the option to use it more user-friendly in the future ) depth can increase quite a bit so I needed an alternate view option for the reasons above…

For example instead of one of these ( depending on settings ):

	##	☼ Class Functions Table - Category...		|		##	☼ Class Functions Table - Category...		|	##	☼ Class Functions Table - Category..		|
	##		Vector Class							|		##		☼ Vector Class							|	##		☼ Vector Class							|
	##			ƒ X( )								|		##			function X( )						|	##			function X( )						|
	##			ƒ Y( )								|		##			function Y( )						|	##			function Y( )						|
	##			ƒ Z( )								|		##			function Z( )						|	##			function Z( )						|
	##												|		##												|	##												|
	##		☼ Angle Class							|		##		☼ Angle Class							|	##		☼ Angle Class							|
	##			ƒ P( )								|		##			function P( )						|	##			function P( )						|
	##			ƒ Y( )								|		##			function Y( )						|	##			function Y( )						|
	##			ƒ R( )								|		##			function R( )						|	##			function R( )						|
	##												|		##												|	##												|
	## 	☼ Functions Category						|		## 	☼ Functions Category						|	##	☼ Functions Category						|
	##		ƒ isstring( _data )						|		##		function isstring( _data )				|	##		function isstring( _data )				|
	##		ƒ isnumber( _data )						|		##		function isnumber( _data )				|	##		function isnumber( _data )				|
	##		ƒ isfunction( _data )					|		##		function isfunction( _data )			|	##		function isfunction( _data )			|
	##		ƒ isbool( _data )						|		##		function isbool( _data )				|	##		function isbool( _data )				|

It can look like any of these ( for the default tree output included - the ones with differing levels are to show that with the callback you can set which ones are inset deeper or not - or to have them all uniform depth per category / nested - etc… the whole purpose of a tree-view is to allow a more-compact display of data without making it harder to read )…

	##	┌─☼ Class Functions Table - Category...			|		##	┌─┬☼ Class Functions Table - Category...		|	##	┌─┬☼ Class Functions Table - Category..		|
	##	│ ├──☼ Vector Class								|		##	│ ├─┬☼ Vector Class								|	##	│ ├──☼ Vector Class							|
	##	│ │  ├─☼ ƒ X( )									|		##	│ │ ├──☼ function X( )							|	##	│ │  ├─☼ function X( )						|
	##	│ │  ├─☼ ƒ Y( )									|		##	│ │ ├──☼ function Y( )							|	##	│ │  ├─☼ function Y( )						|
	##	│ │  └─☼ ƒ Z( )									|		##	│ │ └──☼ function Z( )							|	##	│ │  └─☼ function Z( )						|
	##	│ │												|		##	│ │												|	##	│ │											|
	##	│ └──☼ Angle Class								|		##	│ └┬☼ Angle Class								|	##	│ └──☼ Angle Class							|
	##	│    ├─☼ ƒ P( )									|		##	│  ├☼ function P( )								|	##	│    ├─☼ function P( )						|
	##	│    ├─☼ ƒ Y( )									|		##	│  ├☼ function Y( )								|	##	│    ├─☼ function Y( )						|
	##	│    └─☼ ƒ R( )									|		##	│  └☼ function R( )								|	##	│    └─☼ function R( )						|
	##	│												|		##	│												|	##	│											|
	## 	└─☼ Functions Category							|		## 	└┬☼ Functions Category							|	##	└─☼ Functions Category						|
	##	  ├──☼ ƒ isstring( _data )						|		##	 ├─☼ function isstring( _data )					|	##	  ├──☼ function isstring( _data )			|
	##	  ├──☼ ƒ isnumber( _data )						|		##	 ├─☼ function isnumber( _data )					|	##	  ├──☼ function isnumber( _data )			|
	##	  ├──☼ ƒ isfunction( _data )					|		##	 ├─☼ function isfunction( _data )				|	##	  ├──☼ function isfunction( _data )			|
	##	  └──☼ ƒ isbool( _data )						|		##	 └─☼ function isbool( _data )					|	##	  └──☼ function isbool( _data )				|

The problem is by using any of these chars kills the highlighting… I don’t want to turn them into comment characters because syntax highlighting is important for the output to be easily readable…

The languages I’m going to modify for the initial release are Lua, GMod Lua, PHP, AHK, JavaScript, Python and possible others…

I haven’t been able to find out how to add characters to the whitespace flagged category - so I’m asking…

These are the chars I want to add to the whitespace character-list…

 ↨ ↕ ↑ ↓ → ← ↔ ▲ ▼ ► ◄
░ ▒ ▓
 █ ▄ ▌ ▐ ▀ ▬ ■
│ ┤ ┐ └ ┴ ├ ┬ ─ ┼ ┘ ┌ ∟ Γ
 ╣ ║ ╗ ╝ ╚ ╔ ╩ ╦ ╠ ═ ╬
╡ ╢ ╖ ╕ ╜ ╛ ╞ ╟ ╧ ╨ ╤ ╥ ╙ ╘ ╒ ╓ ╫ ╪

Does anyone know how to add characters to the whitespace registry for the purpose of syntax highlighting?

The only thing I can find is how to hide / show these characters in the editor - not modify them…

0 Likes