equal
deleted
inserted
replaced
150 (bytes, chunk) |
150 (bytes, chunk) |
151 } |
151 } |
152 val changed = pending_edits.is_pending() |
152 val changed = pending_edits.is_pending() |
153 Some(Document.Blob(bytes, chunk, changed)) |
153 Some(Document.Blob(bytes, chunk, changed)) |
154 } |
154 } |
|
155 } |
|
156 |
|
157 |
|
158 /* bibtex entries */ |
|
159 |
|
160 private var _bibtex: Option[List[(String, Text.Offset)]] = None // owned by GUI thread |
|
161 |
|
162 private def reset_bibtex(): Unit = GUI_Thread.require { _bibtex = None } |
|
163 |
|
164 def bibtex_entries(): List[(String, Text.Offset)] = |
|
165 GUI_Thread.require { |
|
166 if (Isabelle.is_bibtex(buffer)) { |
|
167 _bibtex match { |
|
168 case Some(entries) => entries |
|
169 case None => |
|
170 val chunks = |
|
171 try { Bibtex.parse(JEdit_Lib.buffer_text(buffer)) } |
|
172 catch { case ERROR(msg) => Output.warning(msg); Nil } |
|
173 val entries = |
|
174 { |
|
175 val result = new mutable.ListBuffer[(String, Text.Offset)] |
|
176 var offset = 0 |
|
177 for (chunk <- chunks) { |
|
178 if (chunk.name != "" && !chunk.is_command) result += ((chunk.name, offset)) |
|
179 offset += chunk.source.length |
|
180 } |
|
181 result.toList |
|
182 } |
|
183 _bibtex = Some(entries) |
|
184 entries |
|
185 } |
|
186 } |
|
187 else Nil |
155 } |
188 } |
156 |
189 |
157 |
190 |
158 /* edits */ |
191 /* edits */ |
159 |
192 |
209 } |
242 } |
210 |
243 |
211 def edit(clear: Boolean, e: Text.Edit) |
244 def edit(clear: Boolean, e: Text.Edit) |
212 { |
245 { |
213 reset_blob() |
246 reset_blob() |
|
247 reset_bibtex() |
214 |
248 |
215 if (clear) { |
249 if (clear) { |
216 pending_clear = true |
250 pending_clear = true |
217 pending.clear |
251 pending.clear |
218 } |
252 } |