+2003-06-17 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * ui/stdmenus.ui: add submenu "Paste Recent" to edit. Also add
+ pasterecent menu.
+
2003-06-17 John Levon <levon@movementarian.org>
* examples/splash.lyx: remove mention of lyxrc
Item "Cut" "cut"
Item "Copy" "copy"
Item "Paste" "paste"
+ Submenu "Paste Recent" "pasterecent"
Item "Find & Replace...|F" "find-replace"
Separator
Item "Text Style...|S" "layout-character"
OptItem "Table Settings...|a" "layout-tabular"
End
+ Menu "pasterecent"
+ PasteRecent
+ End
+
# not much we can do to help here
Menu "edit_tabular"
Item "Add Row|A" "tabular-feature append-row"
if (!tracking) {
ParIterator const end = buf->par_iterator_end();
- for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
+ for (ParIterator it = buf->par_iterator_begin(); it != end; ++it)
it->trackChanges();
buf->params.tracking_changes = true;
+2003-06-17 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * text3.C (dispatch): handle arg to LFUN_PASTE, call
+ pasteSelection with index
+
+ * text2.C (pasteSelection): modify, call pasteSelection with index
+
+ * paragraph.C (asString): reimplement version with no interval to
+ call the one with interval.
+
+ * lyxtext.h: add index arg to pasteSelection
+
+ * MenuBackend.C (MenuItem): handle PasteRecent
+ (Menu::read::Menutags): add md_pasterecent
+ (read): handle it
+ (expandPasteRecent): new function
+ (expand): use it
+
+ * MenuBackend.h: add PasteRecent to MenuItem::Kind
+
+ * CutAndPaste.C: get rid of some stale comments. Add typdefe for
+ the limited stack
+ (availableSelections): new function
+
2003-06-17 Angus Leeming <leeming@lyx.org>
* lyxfunc.C (dispatch): s/showMathPanel/show("mathpanel")/
* lyxtext.h:
* text.C: implement accept/rejectChange()
- * lyxtext.h:
+ * lyxtext.h:
* text.C: paint changebars. Paint new/deleted text in the chosen
colours. Strike through deleted text.
using std::pair;
using std::make_pair;
using std::for_each;
+using std::vector;
using lyx::pos_type;
using lyx::textclass_type;
-// Jürgen, note that this means that you cannot currently have a list
-// of selections cut/copied. So IMHO later we should have a
-// list/vector/deque that we could store
-// struct selection_item {
-// ParagraphList copy_pars;
-// LyXTextClassList::size_type textclass;
-// };
-// in and some method of choosing beween them (based on the first few chars
-// in the selection probably.) This would be a nice feature and quite
-// easy to implement. (Lgb)
-//
-// Sure but I just cleaned up this code for now with the same functionality
-// as before. I also want to add a XClipboard function so that we can copy
-// text from LyX to some other X-application in the form of ASCII or in the
-// form of LaTeX (or Docbook depending on the document-class!). Think how nice
-// it could be to select a math-inset do a "Copy to X-Clipboard as LaTeX" and
-// then do a middle mouse button click in the application you want and have
-// the whole formula there in LaTeX-Code. (Jug)
+
+typedef limited_stack<pair<ParagraphList, textclass_type> > CutStack;
namespace {
-limited_stack<pair<ParagraphList, textclass_type> > cuts(10);
+CutStack cuts(10);
} // namespace anon
+vector<string>
+CutAndPaste::availableSelections(Buffer const & buffer)
+{
+ vector<string> selList;
+
+ CutStack::const_iterator cit = cuts.begin();
+ CutStack::const_iterator end = cuts.end();
+ for (; cit != end; ++cit) {
+ ParagraphList const & pars = cit->first;
+ string asciiPar(pars.front().asString(&buffer, false), 0, 25);
+ selList.push_back(asciiPar);
+ }
+
+ return selList;
+}
+
+
PitPosPair CutAndPaste::cutSelection(BufferParams const & params,
ParagraphList & pars,
ParagraphList::iterator startpit,
return pasteSelection(buffer, pars, pit, pos, tc, 0, errorlist);
}
+
pair<PitPosPair, ParagraphList::iterator>
CutAndPaste::pasteSelection(Buffer const & buffer,
ParagraphList & pars,
#include "support/types.h"
#include "ParagraphList.h"
+#include <vector>
+
class Paragraph;
class BufferParams;
class LyXTextClass;
///
namespace CutAndPaste {
+
+///
+std::vector<string>
+CutAndPaste::availableSelections(Buffer const & buffer);
+
///
PitPosPair cutSelection(BufferParams const & params,
ParagraphList & pars,
#include "importer.h"
#include "FloatList.h"
#include "toc.h"
+#include "CutAndPaste.h"
#include "frontends/LyXView.h"
#include "support/LAssert.h"
#include "support/filetools.h"
case ImportFormats:
case FloatListInsert:
case FloatInsert:
+ case PasteRecent:
break;
case Command:
action_ = lyxaction.LookupFunc(command);
md_viewformats,
md_floatlistinsert,
md_floatinsert,
+ md_pasterecent,
md_last
};
{ "lastfiles", md_lastfiles },
{ "optitem", md_optitem },
{ "optsubmenu", md_optsubmenu },
+ { "pasterecent", md_pasterecent },
{ "separator", md_separator },
{ "submenu", md_submenu },
{ "toc", md_toc },
add(MenuItem(MenuItem::FloatInsert));
break;
+ case md_pasterecent:
+ add(MenuItem(MenuItem::PasteRecent));
+ break;
+
case md_optsubmenu:
optional = true;
// fallback to md_submenu
}
+void expandPasteRecent(Menu & tomenu, LyXView const * view)
+{
+ vector<string> const selL =
+ CutAndPaste::availableSelections(*view->buffer());
+
+ vector<string>::const_iterator cit = selL.begin();
+ vector<string>::const_iterator end = selL.end();
+
+ for (unsigned int index = 0; cit != end; ++cit, ++index) {
+ int const action = lyxaction.getPseudoAction(LFUN_PASTE,
+ tostr(index));
+ tomenu.add(MenuItem(MenuItem::Command, *cit, action));
+ }
+}
+
+
} // namespace anon
expandFloatInsert(tomenu, view);
break;
+ case MenuItem::PasteRecent:
+ expandPasteRecent(tomenu, view);
+ break;
+
case MenuItem::Toc:
expandToc(tomenu, view);
break;
FloatListInsert,
/** This is the list of floats that we can
insert. */
- FloatInsert
+ FloatInsert,
+ /** This is the list of selections that can
+ be pasted. */
+ PasteRecent
};
/// Create a Command type MenuItem
MenuItem(Kind kind,
///
bool hasMenu(string const &) const;
///
- Menu & getMenu (string const &);
+ Menu & getMenu(string const &);
///
- Menu const & getMenu (string const &) const;
+ Menu const & getMenu(string const &) const;
///
Menu const & getMenubar() const;
///
Toolbar tb;
tb.name = lex.getString();
-
+
bool quit = false;
lex.pushTable(toolTags, TO_LAST - 1);
+2003-06-17 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * insettext.C (localDispatch): handle arg to LFUN_PASTE, call
+ pasteSelection with index
+
2003-06-13 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* insettext.C (localDispatch): fix call to cutSelection for LFUN_CUT
}
}
- lt->pasteSelection();
+ size_t sel_index = 0;
+ string const & arg = cmd.argument;
+ if (isStrUnsignedInt(arg)) {
+ size_t const paste_arg = strToUnsignedInt(arg);
+#warning FIXME Check if the arg is in the domain of available selections.
+ sel_index = paste_arg;
+ }
+ lt->pasteSelection(sel_index);
// bug 393
lt->clearSelection();
updwhat = CURSOR_PAR;
///
void copySelection();
///
- void pasteSelection();
+ void pasteSelection(size_t sel_index = 0);
/** the DTP switches for paragraphs. LyX will store the top settings
always in the first physical paragraph, the bottom settings in the
// Used for building the table of contents
string const Paragraph::asString(Buffer const * buffer, bool label) const
{
+#if 0
string s;
if (label && !params().labelString().empty())
s += params().labelString() + ' ';
}
return s;
+#else
+ // This should really be done by the caller and not here.
+ string ret(asString(buffer, 0, size(), label));
+ return subst(ret, '\n', ' ');
+#endif
}
+2003-06-17 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * limited_stack.h: make it have a const_iterator, add begin, and
+ end as interface.
+
2003-06-10 Angus Leeming <leeming@lyx.org>
* filetools.C (copyFileToDir): ensure that temp files have unique names.
typedef std::deque<T> container_type;
typedef typename container_type::value_type value_type;
typedef typename container_type::size_type size_type;
+ typedef typename container_type::const_iterator const_iterator;
/// limit is the maximum size of the stack
limited_stack(size_type limit = 100) {
size_type size() const {
return c_.size();
}
+
+ const_iterator begin() const {
+ return c_.begin();
+ }
+
+ const_iterator end() const {
+ return c_.end();
+ }
+
private:
/// Internal contents.
container_type c_;
}
-void LyXText::pasteSelection()
+void LyXText::pasteSelection(size_t sel_index)
{
// this does not make sense, if there is nothing to paste
if (!CutAndPaste::checkPastePossible())
ownerParagraphs(),
cursor.par(), cursor.pos(),
bv()->buffer()->params.textclass,
- el);
+ sel_index, el);
bv()->setErrorList(el);
bv()->showErrorList(_("Paste"));
#include "box.h"
#include "language.h"
#include "support/tostr.h"
+#include "support/lstrings.h"
#include "frontends/LyXView.h"
#include "frontends/screen.h"
#include "frontends/Dialogs.h"
update();
break;
- case LFUN_PASTE:
+ case LFUN_PASTE: {
cmd.message(_("Paste"));
// clear the selection
bv->toggleSelection();
clearSelection();
update();
- pasteSelection();
+ size_t sel_index = 0;
+ string const & arg = cmd.argument;
+ if (isStrUnsignedInt(arg)) {
+ size_t const paste_arg = strToUnsignedInt(arg);
+#warning FIXME Check if the arg is in the domain of available selections.
+ sel_index = paste_arg;
+ }
+ pasteSelection(sel_index);
clearSelection(); // bug 393
update();
bv->switchKeyMap();
break;
+ }
case LFUN_CUT:
update();