-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathclipboard_block_paste.c
executable file
·163 lines (113 loc) · 4.46 KB
/
clipboard_block_paste.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/* Copyright 2000 Kjetil S. Matheussen
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <stddef.h>
#include "nsmtracker.h"
#include "windows_proc.h"
#include "clipboard_track_paste_proc.h"
#include "clipboard_localzooms_proc.h"
#include "clipboard_tempos_copy_proc.h"
#include "reallines_proc.h"
#include "wblocks_proc.h"
#include <string.h>
#include "block_properties_proc.h"
#include "time_proc.h"
#include "list_proc.h"
#include "undo_blocks_proc.h"
#include "player_proc.h"
#include "player_pause_proc.h"
#include "OS_Bs_edit_proc.h"
#include "Beats_proc.h"
#include "clipboard_block_paste_proc.h"
extern struct WBlocks *cb_wblock;
/* Note, 'wblock' MUST have been generated by CB_CopyBlock.
Note 2: Fixed. (can be copied from a normal wblock)
*/
void CB_PasteBlock(
struct Tracker_Windows *window,
struct WBlocks *wblock,
struct WBlocks *towblock
){
R_ASSERT(is_playing()==false);
struct Blocks *block=wblock->block;
struct Blocks *toblock=towblock->block;
struct WTracks *towtrack=towblock->wtracks;
struct WTracks *towtrack_wtrack=towblock->wtrack;
struct Tracks *totrack=toblock->tracks;
struct WTracks *wtrack;
NInt wblocknum=towblock->l.num;
struct ListHeader1 *nextwblock=towblock->l.next;
NInt blocknum=toblock->l.num;
struct ListHeader1 *nextblock=toblock->l.next;
unsigned int org_color = toblock->color;
NInt org_num_tracks=toblock->num_tracks;
memcpy(towblock,wblock,sizeof(struct WBlocks));
memcpy(toblock, block, offsetof(struct Blocks, cache_num_holder));
toblock->color = org_color; // Don't want to paste color.
towblock->l.next=nextwblock;
towblock->l.num=wblocknum;
towblock->block=toblock;
towblock->wtracks=towtrack;
towblock->wtrack=towtrack_wtrack;
toblock->tracks=totrack;
toblock->l.next=nextblock;
toblock->l.num=blocknum;
//printf("org num_tracks: %d, before: %d\n",org_num_tracks,toblock->num_tracks);
toblock->num_tracks=org_num_tracks;
Block_Set_num_tracks(toblock,block->num_tracks);
TIME_everything_in_block_has_changed(towblock->block); // UpdateReallines requires updated time values (for whether to show swing type track or not).
toblock->name=block->name;
towblock->localzooms=NULL;
CB_UnpackLocalZooms(&towblock->localzooms,wblock->localzooms,block->num_lines);
//towblock->reallines=NULL;
UpdateRealLines_dont_change_curr_realline(window, towblock);
//towblock->wtempos=NULL;
//towblock->wlpbs=NULL;
toblock->swings=CB_CopySwings(block->swings, NULL);
toblock->signatures=CB_CopySignatures(block->signatures);
toblock->lpbs=CB_CopyLPBs(block->lpbs);
toblock->tempos=CB_CopyTempos(block->tempos);
toblock->temponodes=CB_CopyTempoNodes(block->temponodes);
toblock->lasttemponode=(struct TempoNodes *)ListLast3(&toblock->temponodes->l);
UpdateReallinesDependens(window,towblock);
wtrack=wblock->wtracks;
towtrack=towblock->wtracks;
while(wtrack!=NULL){
if(towtrack==NULL){
RError("Error in funtion CB_PasteBlock in file clipboard_block_paste.c; towtrack=NULL\n");
break;
}
if(towtrack->l.num!=wtrack->l.num){
RError("Error in funtion CB_PasteBlock in file clipboard_block_paste.c; towtrack->l.num!=wtrack->l.num\n");
break;
}
co_CB_PasteTrack(towblock,wtrack,towtrack);
towtrack=NextWTrack(towtrack);
wtrack=NextWTrack(wtrack);
}
if(towtrack!=NULL){
RError("Error in funtion CB_PasteBlock in file clipboard_block_paste.c; towtrack!=NULL when wtrack==NULL\n");
}
g_editor_blocks_generation++;
BS_UpdateBlockList();
BS_UpdatePlayListForceUpdate();
}
void CB_PasteBlock_CurrPos(
struct Tracker_Windows *window
){
if(cb_wblock==NULL) return;
PC_Pause();{
ADD_UNDO(Block_CurrPos(window));
CB_PasteBlock(window,cb_wblock,window->wblock);
SelectWBlock(window, window->wblock, true);
}PC_StopPause(window);
}