39 cfg (bool, edit_schemanticinline, false); |
39 cfg (bool, edit_schemanticinline, false); |
40 |
40 |
41 // ============================================================================= |
41 // ============================================================================= |
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
43 // ============================================================================= |
43 // ============================================================================= |
44 static void copyToClipboard () { |
44 static int copyToClipboard () { |
45 vector<LDObject*> objs = g_win->sel (); |
45 vector<LDObject*> objs = g_win->sel (); |
|
46 int num = 0; |
46 |
47 |
47 // Clear the clipboard first. |
48 // Clear the clipboard first. |
48 g_Clipboard.clear (); |
49 g_Clipboard.clear (); |
49 |
50 |
50 // Now, copy the contents into the clipboard. |
51 // Now, copy the contents into the clipboard. |
51 for (LDObject* obj : objs) |
52 for (LDObject* obj : objs) |
|
53 { |
52 g_Clipboard << obj->raw (); |
54 g_Clipboard << obj->raw (); |
|
55 ++num; |
|
56 } |
|
57 |
|
58 return num; |
53 } |
59 } |
54 |
60 |
55 // ============================================================================= |
61 // ============================================================================= |
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
57 // ============================================================================= |
63 // ============================================================================= |
58 MAKE_ACTION (cut, "Cut", "cut", "Cut the current selection to clipboard.", CTRL (X)) { |
64 MAKE_ACTION (cut, "Cut", "cut", "Cut the current selection to clipboard.", CTRL (X)) { |
59 copyToClipboard (); |
65 int num = copyToClipboard (); |
60 g_win->deleteSelection (); |
66 g_win->deleteSelection (); |
|
67 |
|
68 log( ForgeWindow::tr( "%1 objects cut" ), num ); |
61 } |
69 } |
62 |
70 |
63 // ============================================================================= |
71 // ============================================================================= |
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
72 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
65 // ============================================================================= |
73 // ============================================================================= |
66 MAKE_ACTION (copy, "Copy", "copy", "Copy the current selection to clipboard.", CTRL (C)) { |
74 MAKE_ACTION (copy, "Copy", "copy", "Copy the current selection to clipboard.", CTRL (C)) { |
67 copyToClipboard (); |
75 int num = copyToClipboard (); |
|
76 log( ForgeWindow::tr( "%1 objects copied" ), num ); |
68 } |
77 } |
69 |
78 |
70 // ============================================================================= |
79 // ============================================================================= |
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
72 // ============================================================================= |
81 // ============================================================================= |
73 MAKE_ACTION (paste, "Paste", "paste", "Paste clipboard contents.", CTRL (V)) { |
82 MAKE_ACTION (paste, "Paste", "paste", "Paste clipboard contents.", CTRL (V)) { |
74 ulong idx = g_win->getInsertionPoint (); |
83 ulong idx = g_win->getInsertionPoint (); |
75 g_win->sel ().clear (); |
84 g_win->sel ().clear (); |
|
85 int num = 0; |
76 |
86 |
77 for (str line : g_Clipboard) { |
87 for (str line : g_Clipboard) { |
78 LDObject* pasted = parseLine (line); |
88 LDObject* pasted = parseLine (line); |
79 g_curfile->insertObj (idx++, pasted); |
89 g_curfile->insertObj (idx++, pasted); |
80 g_win->sel () << pasted; |
90 g_win->sel () << pasted; |
81 g_win->R ()->compileObject (pasted); |
91 g_win->R ()->compileObject (pasted); |
82 } |
92 ++num; |
83 |
93 } |
|
94 |
|
95 log( ForgeWindow::tr( "%1 objects pasted" ), num ); |
84 g_win->refresh (); |
96 g_win->refresh (); |
85 g_win->scrollToSelection (); |
97 g_win->scrollToSelection (); |
86 } |
98 } |
87 |
99 |
88 // ============================================================================= |
100 // ============================================================================= |
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
90 // ============================================================================= |
102 // ============================================================================= |
91 MAKE_ACTION (del, "Delete", "delete", "Delete the selection", KEY (Delete)) { |
103 MAKE_ACTION (del, "Delete", "delete", "Delete the selection", KEY (Delete)) { |
92 g_win->deleteSelection (); |
104 int num = g_win->deleteSelection (); |
|
105 log( ForgeWindow::tr( "%1 objects deleted" ), num ); |
93 } |
106 } |
94 |
107 |
95 // ============================================================================= |
108 // ============================================================================= |
96 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
97 // ============================================================================= |
110 // ============================================================================= |
509 |
526 |
510 // ============================================================================= |
527 // ============================================================================= |
511 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
528 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
512 // ============================================================================= |
529 // ============================================================================= |
513 MAKE_ACTION (uncolorize, "Uncolorize", "uncolorize", "Reduce colors of everything selected to main and edge colors", (0)) { |
530 MAKE_ACTION (uncolorize, "Uncolorize", "uncolorize", "Reduce colors of everything selected to main and edge colors", (0)) { |
|
531 int num = 0; |
|
532 |
514 for (LDObject* obj : g_win->sel ()) { |
533 for (LDObject* obj : g_win->sel ()) { |
515 if (obj->isColored () == false) |
534 if (obj->isColored () == false) |
516 continue; |
535 continue; |
517 |
536 |
518 obj->setColor ((obj->getType () == LDObject::Line || obj->getType () == LDObject::CondLine) ? edgecolor : maincolor); |
537 int col = maincolor; |
519 } |
538 if( obj->getType() == LDObject::Line || obj->getType() == LDObject::CondLine ) |
520 |
539 col = edgecolor; |
|
540 |
|
541 obj->setColor( col ); |
|
542 num++; |
|
543 } |
|
544 |
|
545 log( ForgeWindow::tr( "%1 objects uncolored" ), num ); |
521 g_win->fullRefresh (); |
546 g_win->fullRefresh (); |
522 } |
547 } |
523 |
548 |
524 // ============================================================================= |
549 // ============================================================================= |
525 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
550 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |