# vim: ft=python noexpandtab
*
def onReturn():
	if ra.isPlaying():
		ra.playStop()
	else:
		ra.playBlockFromStart()

def onEsc():
	ra.playStop()
	ra.setLastSongPosStart(ra.getSongPos())
	ra.midi_allNotesOff()
	ra.cancelRange()

def selOp(command):
	has_range = ra.hasRange()
	if command == "copy": (ra.copyRange if has_range else ra.copyGeneral)()
	elif command == "cut": (ra.cutRange if has_range else ra.cutGeneral)()
	elif command == "paste": ra.pasteRange()
	elif command == "delete": (ra.clearRange if has_range else ra.generalDelete)()
        elif command == "+1": (ra.generalTransposeRangeUp() if has_range else ra.generalTransposeEntryUp())
        elif command == "+12": (ra.generalTransposeRangeUp(True) if has_range else ra.generalTransposeEntryUp(True))
        elif command == "-1": (ra.generalTransposeRangeDown() if has_range else ra.generalTransposeEntryDown())
        elif command == "-12": (ra.generalTransposeRangeDown(True) if has_range else ra.generalTransposeEntryDown(True))
	else: raise Exception("???")

def adjustTracks():
	ntracks = ra.getNumTracks()
	for track in range(ntracks):
		ra.minimizeTrack(-1, -1, track)
		ra.setTrackNoteLength(3, track)
		ra.showVeltext(True, track)
*

B CTRL_L FOCUS_EDITOR : ra.markRange
C CTRL_L FOCUS_EDITOR : keybinding.selOp "copy"
X CTRL_L FOCUS_EDITOR : keybinding.selOp "cut"
V CTRL_L FOCUS_EDITOR : keybinding.selOp "paste"
DEL FOCUS_EDITOR : keybinding.selOp "delete"
TAB FOCUS_EDITOR : ra.generalDelete True
		
ESC FOCUS_EDITOR FOCUS_MIXER FOCUS_SEQUENCER : keybinding.onEsc
RETURN FOCUS_EDITOR FOCUS_MIXER FOCUS_SEQUENCER : keybinding.onReturn
RETURN CTRL_L FOCUS_EDITOR FOCUS_MIXER FOCUS_SEQUENCER : ra.playSongFromStart
RETURN SHIFT_L FOCUS_EDITOR FOCUS_MIXER FOCUS_SEQUENCER : ra.playSongFromCurrent

SPACE FOCUS_EDITOR : ra.switchEditOnOff

F4 CTRL_L FOCUS_EDITOR : keybinding.selOp "+12"
F3 CTRL_L FOCUS_EDITOR : keybinding.selOp "-12"
F2 CTRL_L FOCUS_EDITOR : keybinding.selOp "+1"
F1 CTRL_L FOCUS_EDITOR : keybinding.selOp "-1"

# F4 CTRL_L FOCUS_EDITOR : ra.generalTransposeRangeUp True
# F3 CTRL_L FOCUS_EDITOR : ra.generalTransposeRangeDown True
# F2 CTRL_L FOCUS_EDITOR : ra.generalTransposeRangeUp
# F1 CTRL_L FOCUS_EDITOR : ra.generalTransposeRangeDown

RIGHTARROW ALT_L FOCUS_EDITOR : ra.cursorNextTrack
LEFTARROW ALT_L FOCUS_EDITOR : ra.cursorPrevTrack
DOWNARROW ALT_L FOCUS_EDITOR : ra.cursorDown 8
UPARROW ALT_L FOCUS_EDITOR : ra.cursorUp 8

0 ALT_L FOCUS_EDITOR FOCUS_MIXER FOCUS_SEQUENCER : keybinding.adjustTracks
E CTRL_L FOCUS_EDITOR FOCUS_MIXER FOCUS_SEQUENCER : ra.saveSoundfile
F3 FOCUS_EDITOR : ra.decKeyAdd 12
F4 FOCUS_EDITOR : ra.incKeyAdd 12
F2 FOCUS_EDITOR : ra.switchTrackOn
F1 FOCUS_EDITOR : ra.switchSoloTrack
