forgot to deal with cursor: is it possible to move dispatching to the
cursor inside BufferView::dispatch() ?
T.
Tommaso Cucinotta ha scritto:
Vincent van Ravesteijn ha scritto:
Tommaso Cucinotta schreef:
+ case LFUN_BUFFER_CHKTEX: // TODO: test if doc_buffer here
+ LASSERT(doc_buffer, /**/);
+ doc_buffer->runChktex();
break;
What do you mean with the TODO.. doc_buffer is OK here if that's what
you want to know.
I didn't know what chktex is. Just installed, so I'm missing why we
run a latex checker, if we auto-generate the latex code (is that due
to ERTs ?). Guess doc_buffer is ok here.
Do not use /// but // and just // FIXME. Why the \TODO ?
Because I was assuming that the code documentation is for developers,
and if I put a "///" and a "@todo", then in the "Todo List page"
generated by Doxygen I get this item included. Now that you make me
think of this, I see I picked the wrong case: it should have been
"\todo", otherwise it doesn't work.
In the lines below it is checked whether the buffer is still loaded,
so we already chack for that. What is the todo about ?
+ if (buffer && theBufferList().isLoaded(buffer))
buffer->undo().endUndoGroup();
just didn't know if it is safe to call isLoaded(buffer) with a
deallocated buffer. So, if a buffer isLoaded(), then it must also be
non-null, good.
Now that I saw the code, I have another doubt: isLoaded() should
find() also within binternal, in addition to bstore, shouldn't it ?
if (theBufferList().isLoaded(buffer))
+ if (doc_buffer && doc_buffer != buffer &&
theBufferList().isLoaded(doc_buffer))
+ buffer->undo().endUndoGroup();
if (doc_buffer != buffer && theBufferList().isLoaded(doc_buffer))
- case LFUN_BUFFER_LANGUAGE: {
- LASSERT(lyx_view_, /**/);
- Language const * oldL = buffer->params().language;
+ case LFUN_BUFFER_LANGUAGE: { // Check if this is for buffer
or doc_buffer
This is doc_buffer, as an internal buffer doesn't have params.. well
it has params, but you can't set them. I'd guess that you use the
doc_buffer's params when you need params in your internal buffer.
Everytime you (adv)search, the (search)buffer->params() should be
overwritten with (a copy of) the currentDocumentBuffer()->params,
shouldn't they ? How to do that safely ? Can we have two buffers using
the same buffer params ?
This is not really correct, because we don't know whether we have to
dispatch to buffer or doc_buffer.
this is a heuristics: try the current buffer first, if it fails then
try the document buffer. Of course, all LFUNs should be checked in
order to check whether it makes sense or not.
We should somehow make sure that BufferView->dispatch returns false
if it is an internal buffer and we dispatched an LFUN meant for
doc_buffer. Now, nothing will be succesfully dispatched to doc_buffer.
seems to me that it is already working that way: if
currentBV()->dispatch() returns false, then documentBV()->dispatch()
is tried.
While testing, I've run into this problem: clicking on the TOC issues
a LFUN_PARAGRAPH_GOTO (or smth. like that). Now, I guess this is quite
a general LFUN, used for multiple purposes within LyX (cursor
movements like up/down, Ctrl+Home/End, perhaps also clicking ?). So,
when clicking on the TOC, it should go to the doc_buffer. When
performing other movements, it should go to the curr_buffer.
Would it be meaningful to add to the LFUN a field saying if to
dispatch here or there ? It would have a value of smth. like DEFAULT
for most cases, except when the GUI wants to force dispatching of the
LFUN to the non-default buffer.
+ LASSERT(buffer, /**/);
+
Why this ?
because the code that follows...
// OK, so try the Buffer itself
DispatchResult dr;
BufferView * bv = lyx_view_->currentBufferView();
...seems to rely on the current view
@@ -1732,10 +1762,11 @@
}
// if we executed a mutating lfun, mark the buffer as dirty
- if (theBufferList().isLoaded(buffer) && flag.enabled()
+ if (doc_buffer && !doc_buffer->isInternal()
How can the doc_buffer be internal ? doc_buffer may be 0 because the
next condition will then be false.
right.
Rework in progress... here you go (attachement).
T.