kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #29918
Copy/Paste/Cut defaults to ctrl + c, v, x as most other software.
Hey!
I made the copy/paste/cut functionality work as someone new to the
software might expect. That is, the cut command now actually puts the
block in clipboard and then deletes the block, compared to just deleting
it (wtf)?
They are also bound to the almost universal defaults of ctrl+c/v/x.
- Kristoffer
>From 42b74018a3596ba2b1a8ea0289c8f924f9973655 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kristoffer=20=C3=96dmark?= <kristoffer.odmark90@xxxxxxxxx>
Date: Mon, 3 Jul 2017 13:46:59 +0200
Subject: [PATCH] Eeschema copy/cut/paste to ctrl+c/x/v cut is now undoable
Highlight net is now at ctrl+b by default
---
common/draw_frame.cpp | 4 ++++
eeschema/block.cpp | 17 +++++++++++++++++
eeschema/hotkeys.cpp | 8 +++++++-
eeschema/hotkeys.h | 2 ++
eeschema/schedit.cpp | 18 +++++++++---------
include/block_commande.h | 1 +
6 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp
index 42d99c758..b303b43c2 100644
--- a/common/draw_frame.cpp
+++ b/common/draw_frame.cpp
@@ -867,6 +867,8 @@ bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& a
DisplayError( this, wxT( "No block to paste" ), 20 );
GetScreen()->m_BlockLocate.SetCommand( BLOCK_IDLE );
m_canvas->SetMouseCaptureCallback( NULL );
+ block->SetState( STATE_NO_BLOCK );
+ block->SetMessageBlock( this );
return true;
}
@@ -875,6 +877,8 @@ bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& a
block->ClearItemsList();
DisplayError( this,
wxT( "EDA_DRAW_FRAME::HandleBlockBegin() Err: m_mouseCaptureCallback NULL" ) );
+ block->SetState( STATE_NO_BLOCK );
+ block->SetMessageBlock( this );
return true;
}
diff --git a/eeschema/block.cpp b/eeschema/block.cpp
index 7d8c2bfcc..4bfc76924 100644
--- a/eeschema/block.cpp
+++ b/eeschema/block.cpp
@@ -304,6 +304,23 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
block->ClearItemsList();
break;
+ case BLOCK_CUT:
+ GetScreen()->UpdatePickList();
+ DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
+
+ if( block->GetCount() )
+ {
+ wxPoint move_vector = -GetScreen()->m_BlockLocate.GetLastCursorPosition();
+ copyBlockItems( block->GetItems() );
+ MoveItemsInList( m_blockItems.GetItems(), move_vector );
+ DeleteItemsInList( m_canvas, block->GetItems() );
+ OnModify();
+ }
+ block->ClearItemsList();
+ GetScreen()->TestDanglingEnds();
+ m_canvas->Refresh();
+ break;
+
case BLOCK_PASTE:
block->SetState( STATE_BLOCK_MOVE );
break;
diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp
index 0a834fd00..5a33d59b1 100644
--- a/eeschema/hotkeys.cpp
+++ b/eeschema/hotkeys.cpp
@@ -194,6 +194,8 @@ static EDA_HOTKEY HkCopyComponentOrText( _HKI( "Copy Component or Label" ),
static EDA_HOTKEY HkDrag( _HKI( "Drag Item" ), HK_DRAG, 'G', ID_SCH_DRAG_ITEM );
static EDA_HOTKEY HkSaveBlock( _HKI( "Save Block" ), HK_SAVE_BLOCK, 'C' + GR_KB_CTRL, wxID_COPY );
+static EDA_HOTKEY HkPasteBlock( _HKI( "Paste Block" ), HK_PASTE_BLOCK, 'V' + GR_KB_CTRL, wxID_PASTE );
+static EDA_HOTKEY HkCutBlock( _HKI( "Cut Block" ), HK_CUT_BLOCK, 'X' + GR_KB_CTRL, wxID_CUT );
static EDA_HOTKEY HkMove2Drag( _HKI( "Move Block -> Drag Block" ),
HK_MOVEBLOCK_TO_DRAGBLOCK, '\t', ID_POPUP_DRAG_BLOCK );
static EDA_HOTKEY HkInsert( _HKI( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSERT );
@@ -230,7 +232,7 @@ static EDA_HOTKEY HkUpdatePcbFromSch( _HKI( "Update PCB from Schematic" ), HK_UP
// Higtlight connection
static EDA_HOTKEY HkHighlightConnection( _HKI( "Highlight Connection" ), ID_HOTKEY_HIGHLIGHT,
- 'X' + GR_KB_CTRL );
+ 'B' + GR_KB_CTRL );
// List of common hotkey descriptors
static EDA_HOTKEY* common_Hotkey_List[] =
@@ -281,6 +283,8 @@ static EDA_HOTKEY* schematic_Hotkey_List[] =
&HkInsert,
&HkMove2Drag,
&HkSaveBlock,
+ &HkPasteBlock,
+ &HkCutBlock,
&HkMove,
&HkCopyComponentOrText,
&HkAddComponent,
@@ -471,7 +475,9 @@ bool SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_ZOOM_AUTO:
case HK_ZOOM_SELECTION:
case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving
+ case HK_PASTE_BLOCK:
case HK_SAVE_BLOCK: // Copy block to paste buffer.
+ case HK_CUT_BLOCK:
cmd.SetId( hotKey->m_IdMenuEvent );
GetEventHandler()->ProcessEvent( cmd );
break;
diff --git a/eeschema/hotkeys.h b/eeschema/hotkeys.h
index 92211d3c7..9df3d982d 100644
--- a/eeschema/hotkeys.h
+++ b/eeschema/hotkeys.h
@@ -43,6 +43,8 @@ enum hotkey_id_commnand {
HK_LIBEDIT_MOVE_GRAPHIC_ITEM,
HK_MOVEBLOCK_TO_DRAGBLOCK,
HK_SAVE_BLOCK,
+ HK_PASTE_BLOCK,
+ HK_CUT_BLOCK,
HK_LIBEDIT_LOAD_PART,
HK_LIBEDIT_CREATE_PIN,
HK_DELETE_PIN,
diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp
index b59818763..17c700a93 100644
--- a/eeschema/schedit.cpp
+++ b/eeschema/schedit.cpp
@@ -123,17 +123,23 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
SetRepeatItem( NULL );
break;
- case wxID_CUT:
+ case wxID_CUT: // save and delete block
+
if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
break;
-
- screen->m_BlockLocate.SetCommand( BLOCK_DELETE );
+ screen->m_BlockLocate.SetCommand( BLOCK_CUT );
screen->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc );
SetRepeatItem( NULL );
SetSheetNumberAndCount();
break;
+ case wxID_COPY: // really this is a Save block for paste
+ screen->m_BlockLocate.SetCommand( BLOCK_SAVE );
+ screen->m_BlockLocate.SetMessageBlock( this );
+ HandleBlockEnd( &dc );
+ break;
+
case wxID_PASTE:
HandleBlockBegin( &dc, BLOCK_PASTE, GetCrossHairPosition() );
break;
@@ -329,12 +335,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
- case wxID_COPY: // really this is a Save block for paste
- screen->m_BlockLocate.SetCommand( BLOCK_SAVE );
- screen->m_BlockLocate.SetMessageBlock( this );
- HandleBlockEnd( &dc );
- break;
-
case ID_POPUP_PLACE_BLOCK:
m_canvas->SetAutoPanRequest( false );
m_canvas->MoveCursorToCrossHair();
diff --git a/include/block_commande.h b/include/block_commande.h
index 1e3c225f8..7d1493dad 100644
--- a/include/block_commande.h
+++ b/include/block_commande.h
@@ -56,6 +56,7 @@ typedef enum {
BLOCK_SAVE,
BLOCK_DELETE,
BLOCK_PASTE,
+ BLOCK_CUT,
BLOCK_DRAG,
BLOCK_DRAG_ITEM, // like BLOCK_DRAG, when used to drag a selected component
// and not using an area defined by a mouse drag
--
2.13.1
Follow ups