Changeset 27575
- Timestamp:
- 11/16/08 20:19:07 (2 months ago)
- Files:
-
- lyx-devel/trunk/lib/ui/stdcontext.inc (modified) (1 diff)
- lyx-devel/trunk/src/BufferView.cpp (modified) (2 diffs)
- lyx-devel/trunk/src/CutAndPaste.cpp (modified) (1 diff)
- lyx-devel/trunk/src/CutAndPaste.h (modified) (1 diff)
- lyx-devel/trunk/src/FuncCode.h (modified) (1 diff)
- lyx-devel/trunk/src/LyXAction.cpp (modified) (1 diff)
- lyx-devel/trunk/src/insets/InsetLabel.cpp (modified) (3 diffs)
- lyx-devel/trunk/src/insets/InsetLabel.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lyx-devel/trunk/lib/ui/stdcontext.inc
r27136 r27575 90 90 Item "Next Cross-Reference|N" "reference-next" 91 91 Item "Go back to Reference|G" "bookmark-goto 0" 92 Separator 93 Item "Copy as Reference|C" "copy-label-as-reference" 92 94 Separator 93 95 Item "Settings...|S" "next-inset-toggle" lyx-devel/trunk/src/BufferView.cpp
r27562 r27575 898 898 break; 899 899 900 case LFUN_COPY_LABEL_AS_REF: 901 // if there is an inset at cursor, see whether it 902 // handles the lfun, other start from scratch 903 Inset * inset = cur.nextInset(); 904 if (!inset || !inset->getStatus(cur, cmd, flag)) 905 flag = lyx::getStatus(cmd); 906 break; 907 900 908 case LFUN_NEXT_INSET_TOGGLE: 901 909 case LFUN_NEXT_INSET_MODIFY: { … … 1339 1347 buffer_.params().compressed = !buffer_.params().compressed; 1340 1348 break; 1341 1349 case LFUN_COPY_LABEL_AS_REF: { 1350 // if there is an inset at cursor, try to copy it 1351 Inset * inset = cur.nextInset(); 1352 if (inset) { 1353 FuncRequest tmpcmd = cmd; 1354 inset->dispatch(cur, tmpcmd); 1355 } 1356 if (!cur.result().dispatched()) 1357 // It did not work too; no action needed. 1358 break; 1359 cur.clearSelection(); 1360 processUpdateFlags(Update::SinglePar | Update::FitCursor); 1361 break; 1362 } 1342 1363 case LFUN_NEXT_INSET_TOGGLE: { 1343 1364 // create the the real function we want to invoke lyx-devel/trunk/src/CutAndPaste.cpp
r27562 r27575 688 688 689 689 690 void copyInset(Cursor const & cur, Inset * inset, docstring const & plaintext) 691 { 692 ParagraphList pars; 693 Paragraph par; 694 BufferParams const & bp = cur.buffer().params(); 695 par.setLayout(bp.documentClass().plainLayout()); 696 par.insertInset(0, inset, Change(Change::UNCHANGED)); 697 pars.push_back(par); 698 theCuts.push(make_pair(pars, bp.documentClassPtr())); 699 700 // stuff the selection onto the X clipboard, from an explicit copy request 701 putClipboard(theCuts[0].first, theCuts[0].second, plaintext); 702 } 703 690 704 namespace { 691 705 lyx-devel/trunk/src/CutAndPaste.h
r27425 r27575 65 65 /// Push the current selection to the cut buffer and the system clipboard. 66 66 void copySelection(Cursor const & cur); 67 /// 68 void copyInset(Cursor const & cur, Inset * inset, docstring const & plaintext); 67 69 /** 68 70 * Push the current selection to the cut buffer and the system clipboard. lyx-devel/trunk/src/FuncCode.h
r27518 r27575 413 413 LFUN_WORD_FINDADV, // Tommaso, 20081003 414 414 LFUN_REGEXP_MODE, // Tommaso, 20081003 415 LFUN_COPY_LABEL_AS_REF, // sts, 20081116 415 416 416 417 LFUN_LASTACTION // end of the table lyx-devel/trunk/src/LyXAction.cpp
r27572 r27575 3090 3090 { LFUN_BRANCH_DEACTIVATE, "branch-deactivate", Argument, Buffer }, 3091 3091 3092 /*! 3093 * \var lyx::FuncCode lyx::LFUN_COPY_LABEL_AS_REF 3094 * \li Action: Copies the label at the cursor as a cross-reference to be paster elsewhere. 3095 * \li Syntax: copy-label-as-reference 3096 * \li Origin: sts, 16 Nov 2008 3097 * \endvar 3098 */ 3099 { LFUN_COPY_LABEL_AS_REF, "copy-label-as-reference", ReadOnly | NoUpdate, Edit }, 3100 3092 3101 { LFUN_NOACTION, "", Noop, Hidden } 3093 3102 #ifndef DOXYGEN_SHOULD_SKIP_THIS lyx-devel/trunk/src/insets/InsetLabel.cpp
r27562 r27575 18 18 #include "Buffer.h" 19 19 #include "BufferView.h" 20 #include "CutAndPaste.h" 20 21 #include "DispatchResult.h" 21 22 #include "FuncRequest.h" 23 #include "FuncStatus.h" 22 24 #include "InsetIterator.h" 23 25 #include "ParIterator.h" … … 131 133 toc.push_back(TocItem(ref_pit, 1, it->first->screenLabel())); 132 134 } 135 } 136 137 138 bool InsetLabel::getStatus(Cursor & cur, FuncRequest const & cmd, 139 FuncStatus & status) const 140 { 141 bool enabled; 142 switch (cmd.action) { 143 case LFUN_COPY_LABEL_AS_REF: 144 enabled = true; 145 break; 146 default: 147 return InsetCommand::getStatus(cur, cmd, status); 148 } 149 150 status.setEnabled(enabled); 151 return true; 133 152 } 134 153 … … 151 170 } 152 171 172 case LFUN_COPY_LABEL_AS_REF: { 173 InsetCommandParams p(REF_CODE, "ref"); 174 p["reference"] = getParam("name"); 175 cap::clearSelection(); 176 cap::copyInset(cur, new InsetRef(cur.buffer(), p), getParam("name")); 177 break; 178 } 179 153 180 default: 154 181 InsetCommand::doDispatch(cur, cmd); lyx-devel/trunk/src/insets/InsetLabel.h
r27425 r27575 57 57 /// 58 58 void updateCommand(docstring const & new_label, bool updaterefs = true); 59 /// 60 bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & status) const; 59 61 protected: 60 62 ///
