MCPcopy Create free account
hub / github.com/audacity/audacity / OnSplitCut

Function OnSplitCut

src/menus/EditMenus.cpp:769–801  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

767}
768
769void OnSplitCut(const CommandContext &context)
770{
771 auto &project = context.project;
772 auto &tracks = TrackList::Get(project);
773 auto &selectedRegion = ViewInfo::Get(project).selectedRegion;
774
775 auto &clipboard = Clipboard::Get();
776 clipboard.Clear();
777
778 auto pNewClipboard = TrackList::Create(nullptr);
779 auto &newClipboard = *pNewClipboard;
780
781 tracks.Selected().Visit(
782 [&](WaveTrack &n) {
783 auto track = n.SplitCut(selectedRegion.t0(), selectedRegion.t1());
784 newClipboard.Add(track);
785 },
786 [&](Track &n) {
787 if (n.SupportsBasicEditing()) {
788 auto dest = n.Copy(selectedRegion.t0(), selectedRegion.t1());
789 n.Silence(selectedRegion.t0(), selectedRegion.t1());
790 newClipboard.Add(dest);
791 }
792 }
793 );
794
795 // Survived possibility of exceptions. Commit changes to the clipboard now.
796 clipboard.Assign(std::move(newClipboard),
797 selectedRegion.t0(), selectedRegion.t1(), project.shared_from_this());
798
799 ProjectHistory::Get(project)
800 .PushState(XO("Cut to clipboard and leave gap"), XO("Cut and leave gap"));
801}
802
803void OnSplitDelete(const CommandContext &context)
804{

Callers

nothing calls this directly

Calls 12

GetFunction · 0.85
CreateFunction · 0.85
moveFunction · 0.85
ClearMethod · 0.45
VisitMethod · 0.45
SplitCutMethod · 0.45
AddMethod · 0.45
SupportsBasicEditingMethod · 0.45
CopyMethod · 0.45
SilenceMethod · 0.45
AssignMethod · 0.45
PushStateMethod · 0.45

Tested by

no test coverage detected