equal
deleted
inserted
replaced
41 val text_area = view.getTextArea |
41 val text_area = view.getTextArea |
42 val (s1, s2) = |
42 val (s1, s2) = |
43 Completion.split_template(Isabelle_Encoding.perhaps_decode(text_area.getBuffer, txt)) |
43 Completion.split_template(Isabelle_Encoding.perhaps_decode(text_area.getBuffer, txt)) |
44 text_area.setSelectedText(s1 + s2) |
44 text_area.setSelectedText(s1 + s2) |
45 text_area.moveCaretPosition(text_area.getCaretPosition - s2.length) |
45 text_area.moveCaretPosition(text_area.getCaretPosition - s2.length) |
46 text_area.requestFocus |
46 text_area.requestFocus() |
47 } |
47 } |
48 tooltip = GUI.tooltip_lines(cat_lines(txt :: abbrs.map(a => "abbrev: " + a))) |
48 tooltip = GUI.tooltip_lines(cat_lines(txt :: abbrs.map(a => "abbrev: " + a))) |
49 } |
49 } |
50 |
50 |
51 private class Abbrevs_Panel extends Wrap_Panel(Nil, Wrap_Panel.Alignment.Center) |
51 private class Abbrevs_Panel extends Wrap_Panel(Nil, Wrap_Panel.Alignment.Center) |
65 txt = Symbol.encode(txt0) |
65 txt = Symbol.encode(txt0) |
66 if !Symbol.iterator(txt). |
66 if !Symbol.iterator(txt). |
67 forall(s => s.length == 1 && s(0) != Completion.caret_indicator) |
67 forall(s => s.length == 1 && s(0) != Completion.caret_indicator) |
68 } yield (txt, abbr)): _*).iterator_list.toList |
68 } yield (txt, abbr)): _*).iterator_list.toList |
69 |
69 |
70 contents.clear |
70 contents.clear() |
71 for ((txt, abbrs) <- entries.sortBy(_._1)) |
71 for ((txt, abbrs) <- entries.sortBy(_._1)) |
72 contents += new Abbrev_Component(txt, abbrs.filterNot(_ == "").sorted) |
72 contents += new Abbrev_Component(txt, abbrs.filterNot(_ == "").sorted) |
73 |
73 |
74 revalidate |
74 revalidate() |
75 repaint |
75 repaint() |
76 } |
76 } |
77 } |
77 } |
78 |
78 |
79 refresh |
79 refresh |
80 } |
80 } |
99 val text_area = view.getTextArea |
99 val text_area = view.getTextArea |
100 if (is_control && HTML.is_control(symbol)) |
100 if (is_control && HTML.is_control(symbol)) |
101 Syntax_Style.edit_control_style(text_area, symbol) |
101 Syntax_Style.edit_control_style(text_area, symbol) |
102 else |
102 else |
103 text_area.setSelectedText(Isabelle_Encoding.perhaps_decode(text_area.getBuffer, symbol)) |
103 text_area.setSelectedText(Isabelle_Encoding.perhaps_decode(text_area.getBuffer, symbol)) |
104 text_area.requestFocus |
104 text_area.requestFocus() |
105 } |
105 } |
106 tooltip = |
106 tooltip = |
107 GUI.tooltip_lines( |
107 GUI.tooltip_lines( |
108 cat_lines(symbol :: Symbol.abbrevs.get_list(symbol).map(a => "abbrev: " + a))) |
108 cat_lines(symbol :: Symbol.abbrevs.get_list(symbol).map(a => "abbrev: " + a))) |
109 } |
109 } |
111 private class Reset_Component extends Button |
111 private class Reset_Component extends Button |
112 { |
112 { |
113 action = Action("Reset") { |
113 action = Action("Reset") { |
114 val text_area = view.getTextArea |
114 val text_area = view.getTextArea |
115 Syntax_Style.edit_control_style(text_area, "") |
115 Syntax_Style.edit_control_style(text_area, "") |
116 text_area.requestFocus |
116 text_area.requestFocus() |
117 } |
117 } |
118 tooltip = "Reset control symbols within text" |
118 tooltip = "Reset control symbols within text" |
119 } |
119 } |
120 |
120 |
121 |
121 |
133 val search_words = Word.explode(Word.lowercase(search_field.text)) |
133 val search_words = Word.explode(Word.lowercase(search_field.text)) |
134 val search_limit = PIDE.options.int("jedit_symbols_search_limit") max 0 |
134 val search_limit = PIDE.options.int("jedit_symbols_search_limit") max 0 |
135 val results = |
135 val results = |
136 for ((sym, s) <- search_space; if search_words.forall(s.contains(_))) yield sym |
136 for ((sym, s) <- search_space; if search_words.forall(s.contains(_))) yield sym |
137 |
137 |
138 results_panel.contents.clear |
138 results_panel.contents.clear() |
139 for (sym <- results.take(search_limit)) |
139 for (sym <- results.take(search_limit)) |
140 results_panel.contents += new Symbol_Component(sym, false) |
140 results_panel.contents += new Symbol_Component(sym, false) |
141 if (results.length > search_limit) |
141 if (results.length > search_limit) |
142 results_panel.contents += |
142 results_panel.contents += |
143 new Label("...") { tooltip = "(" + (results.length - search_limit) + " more)" } |
143 new Label("...") { tooltip = "(" + (results.length - search_limit) + " more)" } |
144 revalidate |
144 revalidate() |
145 repaint |
145 repaint() |
146 } |
146 } |
147 search_field.reactions += { case ValueChanged(_) => search_delay.invoke() } |
147 search_field.reactions += { case ValueChanged(_) => search_delay.invoke() } |
148 } |
148 } |
149 |
149 |
150 |
150 |
168 pages += search_page |
168 pages += search_page |
169 |
169 |
170 listenTo(selection) |
170 listenTo(selection) |
171 reactions += { |
171 reactions += { |
172 case SelectionChanged(_) if selection.page == search_page => |
172 case SelectionChanged(_) if selection.page == search_page => |
173 search_panel.search_field.requestFocus |
173 search_panel.search_field.requestFocus() |
174 } |
174 } |
175 |
175 |
176 for (page <- pages) |
176 for (page <- pages) |
177 page.title = Word.implode(Word.explode('_', page.title).map(Word.perhaps_capitalize)) |
177 page.title = Word.implode(Word.explode('_', page.title).map(Word.perhaps_capitalize)) |
178 } |
178 } |