23 object Syntax_Style |
23 object Syntax_Style |
24 { |
24 { |
25 /* extended syntax styles */ |
25 /* extended syntax styles */ |
26 |
26 |
27 private val plain_range: Int = JEditToken.ID_COUNT |
27 private val plain_range: Int = JEditToken.ID_COUNT |
28 private val full_range = 6 * plain_range + 1 |
28 private val full_range: Int = 6 * plain_range |
29 private def check_range(i: Int): Unit = |
29 private def check_range(i: Int): Unit = |
30 require(0 <= i && i < plain_range, "bad syntax style range") |
30 require(0 <= i && i < plain_range, "bad syntax style range") |
31 |
31 |
32 def subscript(i: Byte): Byte = { check_range(i); (i + plain_range).toByte } |
32 def subscript(i: Byte): Byte = { check_range(i); (i + plain_range).toByte } |
33 def superscript(i: Byte): Byte = { check_range(i); (i + 2 * plain_range).toByte } |
33 def superscript(i: Byte): Byte = { check_range(i); (i + 2 * plain_range).toByte } |
34 def bold(i: Byte): Byte = { check_range(i); (i + 3 * plain_range).toByte } |
34 def bold(i: Byte): Byte = { check_range(i); (i + 3 * plain_range).toByte } |
35 def user_font(idx: Int, i: Byte): Byte = { check_range(i); (i + (4 + idx) * plain_range).toByte } |
35 def user_font(idx: Int, i: Byte): Byte = { check_range(i); (i + (4 + idx) * plain_range).toByte } |
36 val hidden: Byte = (6 * plain_range).toByte |
36 val hidden: Byte = full_range.toByte |
37 val control: Byte = (hidden + JEditToken.DIGIT).toByte |
37 val control: Byte = (hidden + JEditToken.DIGIT).toByte |
38 |
38 |
39 private def font_style(style: SyntaxStyle, f: Font => Font): SyntaxStyle = |
39 private def font_style(style: SyntaxStyle, f: Font => Font): SyntaxStyle = |
40 new SyntaxStyle(style.getForegroundColor, style.getBackgroundColor, f(style.getFont)) |
40 new SyntaxStyle(style.getForegroundColor, style.getBackgroundColor, f(style.getFont)) |
41 |
41 |
71 |
71 |
72 object Base_Extender extends SyntaxUtilities.StyleExtender |
72 object Base_Extender extends SyntaxUtilities.StyleExtender |
73 { |
73 { |
74 override def extendStyles(styles: Array[SyntaxStyle]): Array[SyntaxStyle] = |
74 override def extendStyles(styles: Array[SyntaxStyle]): Array[SyntaxStyle] = |
75 { |
75 { |
76 val new_styles = new Array[SyntaxStyle](full_range) |
76 val new_styles = Array.fill[SyntaxStyle](java.lang.Byte.MAX_VALUE)(styles(0)) |
77 for (i <- 0 until full_range) { |
77 for (i <- 0 until full_range) { |
78 new_styles(i) = styles(i % plain_range) |
78 new_styles(i) = styles(i % plain_range) |
79 } |
79 } |
80 new_styles |
80 new_styles |
81 } |
81 } |