32 #include "colors.h" |
33 #include "colors.h" |
33 #include "ui_replcoords.h" |
34 #include "ui_replcoords.h" |
34 #include "ui_editraw.h" |
35 #include "ui_editraw.h" |
35 #include "ui_flip.h" |
36 #include "ui_flip.h" |
36 |
37 |
37 vector<str> g_Clipboard; |
|
38 |
|
39 cfg (bool, edit_schemanticinline, false); |
38 cfg (bool, edit_schemanticinline, false); |
40 |
39 |
41 // ============================================================================= |
40 // ============================================================================= |
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
43 // ============================================================================= |
42 // ============================================================================= |
44 static int copyToClipboard () { |
43 static int copyToClipboard () { |
45 vector<LDObject*> objs = g_win->sel (); |
44 vector<LDObject*> objs = g_win->sel (); |
46 int num = 0; |
45 int num = 0; |
47 |
46 |
48 // Clear the clipboard first. |
47 // Clear the clipboard first. |
49 g_Clipboard.clear (); |
48 qApp->clipboard()->clear(); |
50 |
49 |
51 // Now, copy the contents into the clipboard. |
50 // Now, copy the contents into the clipboard. |
52 for (LDObject* obj : objs) |
51 str data; |
53 { |
52 for (LDObject* obj : objs) { |
54 g_Clipboard << obj->raw (); |
53 data += ( obj->raw () + "\n" ); |
55 ++num; |
54 ++num; |
56 } |
55 } |
|
56 |
|
57 qApp->clipboard()->setText( data ); |
57 |
58 |
58 return num; |
59 return num; |
59 } |
60 } |
60 |
61 |
61 // ============================================================================= |
62 // ============================================================================= |
78 |
79 |
79 // ============================================================================= |
80 // ============================================================================= |
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
81 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
81 // ============================================================================= |
82 // ============================================================================= |
82 MAKE_ACTION (paste, "Paste", "paste", "Paste clipboard contents.", CTRL (V)) { |
83 MAKE_ACTION (paste, "Paste", "paste", "Paste clipboard contents.", CTRL (V)) { |
|
84 const str clipboardText = qApp->clipboard()->text(); |
83 ulong idx = g_win->getInsertionPoint (); |
85 ulong idx = g_win->getInsertionPoint (); |
84 g_win->sel ().clear (); |
86 g_win->sel ().clear (); |
85 int num = 0; |
87 int num = 0; |
86 |
88 |
87 for (str line : g_Clipboard) { |
89 for( str line : clipboardText.split( "\n", QString::SkipEmptyParts )) |
|
90 { |
88 LDObject* pasted = parseLine (line); |
91 LDObject* pasted = parseLine (line); |
89 g_curfile->insertObj (idx++, pasted); |
92 g_curfile->insertObj (idx++, pasted); |
90 g_win->sel () << pasted; |
93 g_win->sel () << pasted; |
91 g_win->R ()->compileObject (pasted); |
94 g_win->R ()->compileObject (pasted); |
92 ++num; |
95 ++num; |