#include "insets/InsetRef.h"
#include "insets/InsetText.h"
+#include "mathed/InsetMath.h"
#include "mathed/MathData.h"
+#include "mathed/MathRow.h"
#include "frontends/alert.h"
#include "frontends/CaretGeometry.h"
#include "frontends/NullPainter.h"
#include "frontends/Painter.h"
#include "frontends/Selection.h"
+#include "frontends/Clipboard.h"
#include "support/convert.h"
#include "support/debug.h"
*/
frontend::GuiBufferViewDelegate * gui_;
- /// Cache for Find Next
- FuncRequest search_request_cache_;
-
///
map<string, Inset *> edited_insets_;
int BufferView::topMargin() const
{
- // original value was 20px, which is 0.2in at 100dpi
- return zoomedPixels(20);
+ // Original value was 20px at 100dpi. For internal buffers like in
+ // advanced search and replace, a value of 5px is enough.
+ return zoomedPixels(buffer().isInternal() ? 5 : 20);
}
int BufferView::bottomMargin() const
{
- // original value was 20px, which is 0.2in at 100dpi
- return zoomedPixels(20);
+ return topMargin();
}
}
+docstring const & BufferView::searchRequestCache() const
+{
+ return theClipboard().getFindBuffer();
+}
+
+
+void BufferView::setSearchRequestCache(docstring const & text)
+{
+ bool casesensitive;
+ bool matchword;
+ bool forward;
+ bool wrap;
+ bool instant;
+ bool onlysel;
+ docstring const search = string2find(text, casesensitive, matchword,
+ forward, wrap, instant, onlysel);
+ theClipboard().setFindBuffer(search);
+}
+
+
bool BufferView::needsFitCursor() const
{
if (cursorStatus(d->cursor_) == CUR_INSIDE) {
void BufferView::saveBookmark(unsigned int idx)
{
+ if (buffer().isInternal())
+ return;
+
// tentatively save bookmark, id and pos will be used to
// acturately locate a bookmark in a 'live' lyx session.
// pit and pos will be updated with bottom level pit/pos
// when lyx exits.
- if (!buffer_.isInternal()) {
- theSession().bookmarks().save(
- buffer_.fileName(),
- d->cursor_.bottom().pit(),
- d->cursor_.bottom().pos(),
- d->cursor_.paragraph().id(),
- d->cursor_.pos(),
- idx
- );
- if (idx)
- // emit message signal.
- message(_("Save bookmark"));
- }
+ theSession().bookmarks().save(
+ buffer_.fileName(),
+ d->cursor_.bottom().pit(),
+ d->cursor_.bottom().pos(),
+ d->cursor_.paragraph().id(),
+ d->cursor_.pos(),
+ idx
+ );
+ if (idx)
+ // emit message signal.
+ message(_("Save bookmark"));
}
void BufferView::makeDocumentClass()
{
DocumentClassConstPtr olddc = buffer_.params().documentClassPtr();
- buffer_.params().makeDocumentClass();
+ buffer_.params().makeDocumentClass(buffer_.isClone(), buffer_.isInternal());
updateDocumentClass(olddc);
}
case LFUN_MARK_OFF:
case LFUN_MARK_ON:
case LFUN_MARK_TOGGLE:
+ case LFUN_SEARCH_STRING_SET:
case LFUN_SCREEN_RECENTER:
case LFUN_SCREEN_SHOW_CURSOR:
case LFUN_BIBTEX_DATABASE_ADD:
break;
}
+ case LFUN_COPY:
+ flag.setEnabled(cur.selection());
+ break;
+
default:
return false;
}
break;
case LFUN_BOOKMARK_SAVE:
+ dr.screenUpdate(Update::Force);
saveBookmark(convert<unsigned int>(to_utf8(cmd.argument())));
break;
case LFUN_WORD_FIND_FORWARD:
case LFUN_WORD_FIND_BACKWARD: {
- // FIXME THREAD
- // Would it maybe be better if this variable were view specific anyway?
- static docstring last_search;
docstring searched_string;
if (!cmd.argument().empty()) {
- last_search = cmd.argument();
+ setSearchRequestCache(cmd.argument());
searched_string = cmd.argument();
} else {
- searched_string = last_search;
+ searched_string = searchRequestCache();
}
if (searched_string.empty())
break;
- bool const fw = act == LFUN_WORD_FIND_FORWARD;
docstring const data =
- find2string(searched_string, true, false, fw);
+ find2string(searched_string, false, false,
+ act == LFUN_WORD_FIND_FORWARD, false, false, false);
bool found = lyxfind(this, FuncRequest(LFUN_WORD_FIND, data));
if (found)
dr.screenUpdate(Update::Force | Update::FitCursor);
+ else
+ dr.setMessage(_("Search string not found!"));
break;
}
case LFUN_WORD_FIND: {
- FuncRequest req = cmd;
- if (cmd.argument().empty() && !d->search_request_cache_.argument().empty())
- req = d->search_request_cache_;
- if (req.argument().empty()) {
+ docstring arg = cmd.argument();
+ if (arg.empty())
+ arg = searchRequestCache();
+ if (arg.empty()) {
lyx::dispatch(FuncRequest(LFUN_DIALOG_SHOW, "findreplace"));
break;
}
- if (lyxfind(this, req))
+ if (lyxfind(this, FuncRequest(act, arg)))
dr.screenUpdate(Update::Force | Update::FitCursor);
+ else
+ dr.setMessage(_("Search string not found!"));
- d->search_request_cache_ = req;
+ setSearchRequestCache(arg);
break;
}
- case LFUN_WORD_REPLACE: {
- bool has_deleted = false;
- if (cur.selection()) {
- DocIterator beg = cur.selectionBegin();
- DocIterator end = cur.selectionEnd();
- if (beg.pit() == end.pit()) {
- for (pos_type p = beg.pos() ; p < end.pos() ; ++p) {
- if (!cur.inMathed() && cur.paragraph().isDeleted(p)) {
- has_deleted = true;
- break;
- }
- }
- }
+ case LFUN_SEARCH_STRING_SET: {
+ docstring pattern = cmd.argument();
+ if (!pattern.empty()) {
+ setSearchRequestCache(pattern);
+ break;
+ }
+ if (cur.selection())
+ pattern = cur.selectionAsString(false);
+ else {
+ pos_type spos = cur.pos();
+ cur.innerText()->selectWord(cur, WHOLE_WORD);
+ pattern = cur.selectionAsString(false);
+ cur.selection(false);
+ cur.pos() = spos;
}
- if (lyxreplace(this, cmd, has_deleted)) {
+ setSearchRequestCache(pattern);
+ break;
+ }
+
+ case LFUN_WORD_REPLACE: {
+ if (lyxreplace(this, cmd)) {
dr.forceBufferUpdate();
dr.screenUpdate(Update::Force | Update::FitCursor);
}
+ else
+ dr.setMessage(_("Search string not found!"));
break;
}
cur.setCursor(doc_iterator_begin(cur.buffer()));
cur.selHandle(false);
// Force an immediate computation of metrics because we need it below
- processUpdateFlags(Update::Force);
+ updateMetrics();
d->text_metrics_[&buffer_.text()].editXY(cur, p.x_, p.y_,
true, act == LFUN_SCREEN_UP);
break;
}
+ case LFUN_COPY:
+ cap::copySelection(cur);
+ cur.message(_("Copy"));
+ break;
+
default:
// OK, so try the Buffer itself...
buffer_.dispatch(cmd, dr);
// Do we have a selection?
theSelection().haveSelection(cursor().selection());
- if (cur.needBufferUpdate()) {
+ if (cur.needBufferUpdate() || buffer().needUpdate()) {
cur.clearBufferUpdate();
buffer().updateBuffer();
}
buf.changeLanguage(buf.language(), d->cursor_.getFont().language());
buffer_.undo().recordUndo(d->cursor_);
cap::pasteParagraphList(d->cursor_, pars,
- buf.params().documentClassPtr(), el);
+ buf.params().documentClassPtr(),
+ buf.params().authors(), el);
res = _("Document %1$s inserted.");
} else {
res = _("Could not insert document %1$s");