Scope Selectors are similar to CSS selectors and are used throughout CodeRunner to match text. The most notable application of scope selectors is in syntax highlighting themes.
A syntax highlighted document in CodeRunner's editor has a number of scopes applied to different ranges of text. Scopes are nested in a hierarchical tree structure and define the syntax of the document. In syntax highlighting, a scope selector is used to apply a set of visual attributes (colors, fonts, italics, etc.) to those scopes that are matched by the scope selector.
Scope names are constructed as a number of words separated by a dot (.), ordered from highest to lowest significance. For example, the scope for a double-quoted string in the C language is string.quoted.double.c.
You can discover which scopes are active at the current selection in a document by using .
The most basic scope selector is simply a scope name prefix. For example, the scope selector string matches all strings in all languages, independent of how they are defined. The more specific scope selector string.quoted.double only matches double-quoted strings.
Similar to CSS selectors, you can construct a scope selector to match a scope which is nested inside another scope by separating the scope names with a space. For example, the scope selector meta.function-call string will match all strings that appear inside function calls.
Multiple scope selectors can be combined using operators and parentheses. For example, to match the contents of a string but exclude the punctuation (usually quotes) that define it, you would use the subtraction operator - like this: string - punctuation.definition.string.
meta.function-call stringmeta.function-call ‣ string-) string - punctuation.definition.string (Note that - must be preceded by a space)|) string | comment&) string & comment*) string.quoted.*.c**) string.**.c$) string$=) source|text|string|comment = source (This scope selector will only match where the highest ranked match of source|text|string|comment is a match of source. See Rankings below.)When applying multiple scope selectors to a document, such as during syntax highlighting, each match is assigned a ranking. Higher ranked matches take precedence over lower ranked matches. The ranking of a more deeply nested match will always be higher than that of an ancestor match. If matches are at equal depth, a scope selector with higher specificity will take precedence over one with lower specificity. For example, the low-specificity scope selector string will rank lower and be applied before the higher-specificity scope selector string.quoted.double.
source programming language source code. Examples: source.python, source.c++text natural language text. Examples: text.plain, text.htmlcommentconstantconstant.numericentityentity.namekeywordkeyword.operatormarkupmetameta.tagpunctuationpunctuation.definitionstoragestringsupportvariableconsoleconsole.errorconsole.warningconsole.noticeconsole.debuggerconsole.promptconsole.commandconsole.stdoutconsole.stderrconsole.linkconsole.ansiThere are numerous examples of scope selectors in CodeRunner's theme definitions. These can be found in Preferences ‣ Themes.