-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from melvic-ybanez/custom-color-scheme
Custom color scheme
- Loading branch information
Showing
3 changed files
with
105 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.melvic.chi.views | ||
|
||
import com.melvic.chi.views.ChiTokenMaker.extraTokens | ||
import org.fife.ui.rsyntaxtextarea.modes.CPlusPlusTokenMaker | ||
import org.fife.ui.rsyntaxtextarea.{TokenMap, TokenTypes} | ||
|
||
class ChiTokenMaker extends CPlusPlusTokenMaker { | ||
override def addToken(array: Array[Char], start: Int, end: Int, tokenType: Int, startOffset: Int): Unit = { | ||
val newTokenType = | ||
if (tokenType == TokenTypes.IDENTIFIER) { | ||
val newType = extraTokens.get(array, start, end) | ||
if (newType > -1) newType else tokenType | ||
} else tokenType | ||
super.addToken(array, start, end, newTokenType, startOffset) | ||
} | ||
} | ||
|
||
object ChiTokenMaker { | ||
lazy val extraTokens = { | ||
val tokens = new TokenMap(false) | ||
|
||
val reservedWords = List( | ||
"def", | ||
"case", | ||
"match", | ||
"if", | ||
"while", | ||
"for", | ||
"class", | ||
"public", | ||
"protected", | ||
"private", | ||
"abstract", | ||
"object", | ||
"val", | ||
"var", | ||
"import", | ||
"trait", | ||
"lazy", | ||
"return" | ||
) | ||
val functions = List("identity", "const", "compose", "andThen", "apply", "_1", "_2", "_3") | ||
val dataTypes = List( | ||
"int", | ||
"Int", | ||
"Integer", | ||
"float", | ||
"Float", | ||
"double", | ||
"Double", | ||
"char", | ||
"Char", | ||
"Character", | ||
"String", | ||
"List", | ||
"byte", | ||
"short", | ||
"Byte", | ||
"Short", | ||
"long", | ||
"Long", | ||
"Function", | ||
"BiFunction", | ||
"Either", | ||
"Left", | ||
"Right" | ||
) | ||
|
||
reservedWords.foreach(tokens.put(_, TokenTypes.RESERVED_WORD)) | ||
functions.foreach(tokens.put(_, TokenTypes.FUNCTION)) | ||
dataTypes.foreach(tokens.put(_, TokenTypes.DATA_TYPE)) | ||
|
||
tokens | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters