68 case Some(Text.Info(_, tok)) => keywords.is_quasi_command(tok) |
68 case Some(Text.Info(_, tok)) => keywords.is_quasi_command(tok) |
69 } |
69 } |
70 |
70 |
71 val prev_line: Int = |
71 val prev_line: Int = |
72 Range.inclusive(current_line - 1, 0, -1).find(line => |
72 Range.inclusive(current_line - 1, 0, -1).find(line => |
73 Token_Markup.Line_Context.prev(buffer, line).get_context == Scan.Finished && |
73 Token_Markup.Line_Context.before(buffer, line).get_context == Scan.Finished && |
74 !Token_Markup.Line_Context.next(buffer, line).structure.improper) getOrElse -1 |
74 !Token_Markup.Line_Context.after(buffer, line).structure.improper) getOrElse -1 |
75 |
75 |
76 def prev_line_command: Option[Token] = |
76 def prev_line_command: Option[Token] = |
77 nav.reverse_iterator(prev_line, 1). |
77 nav.reverse_iterator(prev_line, 1). |
78 collectFirst({ case Text.Info(_, tok) if tok.is_begin_or_command => tok }) |
78 collectFirst({ case Text.Info(_, tok) if tok.is_begin_or_command => tok }) |
79 |
79 |
138 def indent_extra: Int = |
138 def indent_extra: Int = |
139 if (prev_span.exists(keywords.is_quasi_command(_))) indent_size |
139 if (prev_span.exists(keywords.is_quasi_command(_))) indent_size |
140 else 0 |
140 else 0 |
141 |
141 |
142 val indent = |
142 val indent = |
143 if (Token_Markup.Line_Context.prev(buffer, current_line).get_context == Scan.Finished) { |
143 if (Token_Markup.Line_Context.before(buffer, current_line).get_context == Scan.Finished) |
|
144 { |
144 line_head(current_line) match { |
145 line_head(current_line) match { |
145 case Some(info @ Text.Info(range, tok)) => |
146 case Some(info @ Text.Info(range, tok)) => |
146 if (tok.is_begin || |
147 if (tok.is_begin || |
147 keywords.is_before_command(tok) || |
148 keywords.is_before_command(tok) || |
148 keywords.is_command(tok, Keyword.theory)) 0 |
149 keywords.is_command(tok, Keyword.theory)) 0 |
197 |
198 |
198 def split_line_content(buffer: JEditBuffer, keywords: Keyword.Keywords, line: Int, caret: Int) |
199 def split_line_content(buffer: JEditBuffer, keywords: Keyword.Keywords, line: Int, caret: Int) |
199 : (List[Token], List[Token]) = |
200 : (List[Token], List[Token]) = |
200 { |
201 { |
201 val line_range = JEdit_Lib.line_range(buffer, line) |
202 val line_range = JEdit_Lib.line_range(buffer, line) |
202 val ctxt0 = Token_Markup.Line_Context.prev(buffer, line).get_context |
203 val ctxt0 = Token_Markup.Line_Context.before(buffer, line).get_context |
203 val (toks1, ctxt1) = line_content(buffer, keywords, Text.Range(line_range.start, caret), ctxt0) |
204 val (toks1, ctxt1) = line_content(buffer, keywords, Text.Range(line_range.start, caret), ctxt0) |
204 val (toks2, _) = line_content(buffer, keywords, Text.Range(caret, line_range.stop), ctxt1) |
205 val (toks2, _) = line_content(buffer, keywords, Text.Range(caret, line_range.stop), ctxt1) |
205 (toks1, toks2) |
206 (toks1, toks2) |
206 } |
207 } |
207 |
208 |