equal
deleted
inserted
replaced
17 |
17 |
18 object Text_Structure |
18 object Text_Structure |
19 { |
19 { |
20 /* token navigator */ |
20 /* token navigator */ |
21 |
21 |
22 class Navigator(syntax: Outer_Syntax, buffer: Buffer, comments: Boolean) |
22 class Navigator(syntax: Outer_Syntax, buffer: JEditBuffer, comments: Boolean) |
23 { |
23 { |
24 val limit = PIDE.options.value.int("jedit_structure_limit") max 0 |
24 val limit = PIDE.options.value.int("jedit_structure_limit") max 0 |
25 |
25 |
26 def iterator(line: Int, lim: Int = limit): Iterator[Text.Info[Token]] = |
26 def iterator(line: Int, lim: Int = limit): Iterator[Text.Info[Token]] = |
27 { |
27 { |
46 |
46 |
47 def apply(buffer: JEditBuffer, current_line: Int, prev_line0: Int, prev_prev_line0: Int, |
47 def apply(buffer: JEditBuffer, current_line: Int, prev_line0: Int, prev_prev_line0: Int, |
48 actions: java.util.List[IndentAction]) |
48 actions: java.util.List[IndentAction]) |
49 { |
49 { |
50 Isabelle.buffer_syntax(buffer) match { |
50 Isabelle.buffer_syntax(buffer) match { |
51 case Some(syntax) if buffer.isInstanceOf[Buffer] => |
51 case Some(syntax) => |
52 val keywords = syntax.keywords |
52 val keywords = syntax.keywords |
53 val nav = new Navigator(syntax, buffer.asInstanceOf[Buffer], true) |
53 val nav = new Navigator(syntax, buffer, true) |
54 |
54 |
55 val indent_size = buffer.getIndentSize |
55 val indent_size = buffer.getIndentSize |
56 |
56 |
57 |
57 |
58 def line_indent(line: Int): Int = |
58 def line_indent(line: Int): Int = |
182 } |
182 } |
183 } |
183 } |
184 |
184 |
185 actions.clear() |
185 actions.clear() |
186 actions.add(new IndentAction.AlignOffset(indent max 0)) |
186 actions.add(new IndentAction.AlignOffset(indent max 0)) |
187 case _ => |
187 case None => |
188 } |
188 } |
189 } |
189 } |
190 } |
190 } |
191 |
191 |
192 def line_content(buffer: JEditBuffer, keywords: Keyword.Keywords, |
192 def line_content(buffer: JEditBuffer, keywords: Keyword.Keywords, |
236 val buffer = text_area.getBuffer |
236 val buffer = text_area.getBuffer |
237 val caret_line = text_area.getCaretLine |
237 val caret_line = text_area.getCaretLine |
238 val caret = text_area.getCaretPosition |
238 val caret = text_area.getCaretPosition |
239 |
239 |
240 Isabelle.buffer_syntax(text_area.getBuffer) match { |
240 Isabelle.buffer_syntax(text_area.getBuffer) match { |
241 case Some(syntax) if buffer.isInstanceOf[Buffer] => |
241 case Some(syntax) => |
242 val keywords = syntax.keywords |
242 val keywords = syntax.keywords |
243 |
243 |
244 val nav = new Navigator(syntax, buffer.asInstanceOf[Buffer], false) |
244 val nav = new Navigator(syntax, buffer, false) |
245 |
245 |
246 def caret_iterator(): Iterator[Text.Info[Token]] = |
246 def caret_iterator(): Iterator[Text.Info[Token]] = |
247 nav.iterator(caret_line).dropWhile(info => !info.range.touches(caret)) |
247 nav.iterator(caret_line).dropWhile(info => !info.range.touches(caret)) |
248 |
248 |
249 def reverse_caret_iterator(): Iterator[Text.Info[Token]] = |
249 def reverse_caret_iterator(): Iterator[Text.Info[Token]] = |
312 case None => None |
312 case None => None |
313 } |
313 } |
314 |
314 |
315 case _ => None |
315 case _ => None |
316 } |
316 } |
317 case _ => None |
317 case None => None |
318 } |
318 } |
319 } |
319 } |
320 |
320 |
321 def getMatch(text_area: TextArea): StructureMatcher.Match = |
321 def getMatch(text_area: TextArea): StructureMatcher.Match = |
322 find_pair(text_area) match { |
322 find_pair(text_area) match { |