
eventmap MODEL {
    key       [F1]      { ViewModeMap }
    key     [C+F2]      { FileSaveAll }
    key       [F3]      { FileOpen }
    key       [F4]      { WinNext }
    key     [C+F4]      { WinHSplit }
    key     [S+F4]      { WinPrev }
    key   [C+S+F4]      { WinClose }
    key       [F5]      { WinZoom }
    key       [F6]      { FileNext }
    key     [S+F6]      { FilePrev }
    key   [A+S-F6]      { FileLast }
    key       [F7]      { Find $Word }
    key       [F10]     { MainMenu }
    key     [C+F10]     { FileClose }
    key     [C+F9]      { RunProgram }
    key     [A+F9]      { RunProgram "" }
    key     [S+F10]     { LocalMenu }
    
    key   [A+G-Up]      { WinPrev }
    key   [A+G-Down]    { WinNext }
    key   [A+G-Left]    { FilePrev }
    key   [A+G-Right]   { FileNext }
    key   [A+C+G-Left]  { FramePrev }
    key   [A+C+G-Right] { FrameNext }
    
    key   [A+G-PgUp]    { WinPrev; MovePageUp; WinNext }
    key   [A+G-PgDn]    { WinNext; MovePageDown; WinPrev }
    key [A+C+G-PgUp]    { WinNext; MovePageUp; WinPrev }
    key [A+C+G-PgDn]    { WinPrev; MovePageDown; WinNext }
    
    key     [A+X]       { ExitEditor }
    key     [A+Q]       { FileClose }
    
    key   [C+S+G-Up]    { WinResize -1 }
    key   [C+S+G-Down]  { WinResize +1 }
    
    # this is also useful for 'grep -n' etc. if configured
    key       [F9]      { Compile; ViewMessages }
    key       [F11]     { CompilePrevError }
    key       [F12]     { CompileNextError }
    key       [S+F9]    { ViewMessages }
    
    key     [A+F5]      { ShowEntryScreen }
    
    key     [A+0]       { ViewBuffers }
    key     [A+1]       { SwitchTo 1 }
    key     [A+2]       { SwitchTo 2 }
    key     [A+3]       { SwitchTo 3 }
    key     [A+4]       { SwitchTo 4 }
    key     [A+5]       { SwitchTo 5 }
    key     [A+6]       { SwitchTo 6 }
    key     [A+7]       { SwitchTo 7 }
    key     [A+8]       { SwitchTo 8 }
    key     [A+9]       { SwitchTo 9 }

    key     [A+F]       { MainMenu 'F' }
    key     [A+T]       { MainMenu 'T' }
    key     [A+W]       { MainMenu 'W' }
    key     [A+H]       { MainMenu 'H' }
}
# List Viewers
eventmap MLIST: MODEL {
    key     [G-Left]    { MoveLeft }
    key     [G-Right]   { MoveRight }
    key     [G-Up]      { MoveUp }
    key     [G-Down]    { MoveDown }
    key     [G-Home]    { MoveFileStart }
    key   [C+G-Home]    { MovePageStart }
    key     [G-End]     { MoveFileEnd }
    key   [C+G-End]     { MovePageEnd }
    key     [G-PgUp]    { MovePageUp }
    key   [C+G-PgUp]    { MoveFileStart }
    key     [G-PgDn]    { MovePageDown }
    key   [C+G-PgDn]    { MoveFileEnd }
    key   [C+G-Left]    { ScrollRight }
    key   [C+G-Right]   { ScrollLeft }
    
    key     [G-Enter]   { Activate }
    key     [Space]     { ActivateInOtherWindow }
    key     [S+G-Enter] { CloseActivate }

    key     [C+R]       { Rescan }
}

eventmap CVSDIFF: MLIST {
    key     [C+G-Ins]   { BlockCopy }
    key         [Esc]   { FileClose }
}

eventmap CVS: MLIST {
    LocalMenu = "MCvs";
}

eventmap SVNDIFF: MLIST {
    key     [C+G-Ins]   { BlockCopy }
    key         [Esc]   { FileClose }
}

eventmap SVN: MLIST {
    LocalMenu = "MSvn";
}

eventmap DIRECTORY: MLIST {
    MainMenu = 'DirectoryMain';
    LocalMenu = 'DirectoryLocal';
    
    key [C+G-PgUp]      { DirGoUp }
    key [C+G-PgDn]      { DirGoDown }
    key [C+\\]          { DirGoRoot }
    key [/]             { DirGoto }
    key [\\]            { DirGoto }
    key [C+D]           { DeleteFile }
    key [Esc]           { FileClose }
    
    key     [A+N]       { MainMenu 'N' }
    key     [C+O_C+V]   { ShowMenu 'MCvs' }
    key     [C+O_C+N]   { ShowMenu 'MSvn' }
}

# Buffer List
eventmap BUFFERS: MLIST {
    MainMenu = "BufferListMain";
    LocalMenu = "BufferListLocal";
    
    key  [Esc]   { FileClose 0 } # 0 = do not open directory when last closed, overrides OpenAfterClose default.

    key  [C+C]   { BufListFileClose }
    key  [G-Del] { BufListFileClose }
    key  [C+S]   { BufListFileSave }
    key  [F2]    { BufListFileSave }
    key     [C+O_C+V]   { ShowMenu 'MCvs' }
    key     [C+O_C+N]   { ShowMenu 'MSvn' }
}

# Routine List
eventmap ROUTINES: MLIST {
    MainMenu = "RoutinesMain";
    LocalMenu = "RoutinesLocal";
    
    key  [Esc]   { FileClose }
}

eventmap MESSAGES: MLIST {
    MainMenu = "MessagesMain";
    LocalMenu = "MessagesLocal";
    
    key  [C+C]    { ChildClose } # does NOT kill, just closes pipe
    key  [G-Home] { MoveLineStart }
    key  [G-End]  { MoveLineEnd }
}

# Event Map View
eventmap EVENTMAPVIEW: MLIST {
    MainMenu = "EventMapViewMain";
    LocalMenu = "EventMapViewLocal";
    
    key [Esc] { FileClose 0 }
}

eventmap PLAIN: MODEL {
# keymap for plaintext mode
    MainMenu   = 'Main';    # menu for menubar
    LocalMenu  = 'Local';   # local menu

    key       [Esc]     { BlockMarkStream; BlockUnmark }
    key       [F2]      { FileSave }
    key     [S+F2]      { FileSaveAs }
    key   [A+S+F2]      { FileSave; FileClose }
    key     [S+F3]      { FileReload; WinRefresh }
    key     [C+F3]      { FileOpenInMode }
    key       [F7]      { BlockBegin }
    key     [S+F7]      { MoveBlockStart }
    key       [F8]      { BlockEnd }
    key     [S+F8]      { MoveBlockEnd }
    key     [G-Left]    { MoveLeft }
    key   [C+G-Left]    { MoveWordPrev }
    key     [G-Right]   { MoveRight }
    key   [C+G-Right]   { MoveWordNext }
    key     [G-Up]      { MoveUp }
    key     [G-Down]    { MoveDown }
    key     [G-Home]    { MoveLineStart }
    key   [C+G-Home]    { MovePageStart }
    key     [G-End]     { MoveLineEnd }
    key   [C+G-End]     { MovePageEnd }
    key     [G-PgUp]    { MovePageUp }
    key   [C+G-PgUp]    { MoveFileStart }
    key     [G-PgDn]    { MovePageDown }
    key   [C+G-PgDn]    { MoveFileEnd }
#    key   [A+G-Up]      { ScrollUp }
#    key   [A+G-Down]    { ScrollDown }
#    key   [A+G-Left]    { ScrollLeft }
#    key   [A+G-Right]   { ScrollRight }
    
    key   [S+G-Left]    { BlockExtendBegin; MoveLeft;      BlockExtendEnd }
    key   [S+G-Right]   { BlockExtendBegin; MoveRight;     BlockExtendEnd }
    key [C+G-S+Left]    { BlockExtendBegin; MoveWordPrev;  BlockExtendEnd }
    key [C+G-S+Right]   { BlockExtendBegin; MoveWordNext;  BlockExtendEnd }
    key   [G-S+Up]      { BlockExtendBegin; MoveUp;        BlockExtendEnd }
    key   [G-S+Down]    { BlockExtendBegin; MoveDown;      BlockExtendEnd }
    key   [G-S+Home]    { BlockExtendBegin; MoveLineStart; BlockExtendEnd }
    key   [G-S+End]     { BlockExtendBegin; MoveLineEnd;   BlockExtendEnd }
    key [C+G-S+Home]    { BlockExtendBegin; MovePageStart; BlockExtendEnd }
    key [C+G-S+End]     { BlockExtendBegin; MovePageEnd;   BlockExtendEnd }
    key   [G-S+PgUp]    { BlockExtendBegin; MovePageUp;    BlockExtendEnd }
    key   [G-S+PgDn]    { BlockExtendBegin; MovePageDown;  BlockExtendEnd }
    key [C+G-S+PgUp]    { BlockExtendBegin; MoveFileStart; BlockExtendEnd }
    key [C+G-S+PgDn]    { BlockExtendBegin; MoveFileEnd;   BlockExtendEnd }
#    key [A+G-S+Up]      { BlockExtendBegin; ScrollUp;      BlockExtendEnd }
#    key [A+G-S+Down]    { BlockExtendBegin; ScrollDown;    BlockExtendEnd }
#    key [A+G-S+Left]    { BlockExtendBegin; ScrollLeft;    BlockExtendEnd }
#    key [A+G-S+Right]   { BlockExtendBegin; ScrollRight;   BlockExtendEnd }
    key [A+G-C+Up]      { MovePrevEqualIndent }
    key [A+G-C+Down]    { MoveNextEqualIndent }
#    key [A+G-C+Left]    { MovePrevTab }
#    key [A+G-C+Right]   { MoveNextTab }
    key   [C+G-Ins]     { BlockCopy }
    key   [C+G-Del]     { BlockKill }
    key   [S+G-Ins]     { BlockPasteStream }
    key   [S+G-Del]     { BlockCut }
    key   [A+G-Ins]     { BlockPasteColumn }
    key [A+G-S+Ins]     { BlockPasteLine }
    key     [G-Enter]   { LineNew }
    key     [S-BackSp]  { BackSpace }
    key     [G-Ins]     { ToggleInsert }
    key     [G-Del]     { Delete }
    key       [Tab]     { InsertTab }
    key     [S+Tab]     { InsertSpacesToTab 10 }
    key     [C+Tab]     { CompleteWord }
#    key     [C+Tab]     { InsertTab }
    key     [C+BackSp]  { KillWordPrev }
    key   [C+S+BackSp]  { KillToLineStart }
    key   [C+G-Enter]   { LineSplit }
    key   [G-S+Enter]   { LineInsert }
    key   [A+G-Enter]   { LineAdd }
    key   [A+G-Del]     { KillWord }
    key   [A+G-End]     { KillToLineEnd }
    key     [A+BackSp]  { Undo }
    key   [A+S+BackSp]  { Redo }

    key     [C+C]       { BlockCopy }
    key     [C+V]       { BlockPaste }
    key     [C+X]       { BlockCut }
    key     [C+Z]       { Undo }
    key     [C+S+Z]     { Redo }
    
    key     [C+A_1]     { GotoBookmark "1" }
    key     [C+A_2]     { GotoBookmark "2" }
    key     [C+A_3]     { GotoBookmark "3" }
    key     [C+A_4]     { GotoBookmark "4" }
    key     [C+A_5]     { GotoBookmark "5" }
    key     [C+A_6]     { GotoBookmark "6" }
    key     [C+A_7]     { GotoBookmark "7" }
    key     [C+A_8]     { GotoBookmark "8" }
    key     [C+A_9]     { GotoBookmark "9" }
    key     [C+A_0]     { GotoBookmark "0" }
    
    key     [C+P_1]     { PlaceBookmark "1" }
    key     [C+P_2]     { PlaceBookmark "2" }
    key     [C+P_3]     { PlaceBookmark "3" }
    key     [C+P_4]     { PlaceBookmark "4" }
    key     [C+P_5]     { PlaceBookmark "5" }
    key     [C+P_6]     { PlaceBookmark "6" }
    key     [C+P_7]     { PlaceBookmark "7" }
    key     [C+P_8]     { PlaceBookmark "8" }
    key     [C+P_9]     { PlaceBookmark "9" }
    key     [C+P_0]     { PlaceBookmark "0" }
    
    #key     [C+C]       { MoveToColumn }
    key     [C+D]       { LineDuplicate }
    key     [C+F]       { Find }
    key     [C+G]       { FindRepeat }
    key     [C+I]       { ListRoutines }
    key     [C+J]       { LineJoin }
    key     [C+H]       { FindRepeatReverse }
    key     [C+M]       { DirOpen }
    key     [C+Q]       { InsertChar }
    key     [C+R]       { FindReplace }
    key     [C+T]       { KillWord }
    key     [C+Y]       { KillLine }
#    key     [C+E]       { LineTrim }
    key     [A+A]       { BlockMarkStream }
    key     [A+B]       { MainMenu 'B' }
    key     [A+C]       { BlockCopy }
    key     [A+D]       { MainMenu 'D' }
    key     [A+E]       { MainMenu 'E' }
    key     [A+G]       { BlockCut }
    key     [A+I]       { BlockIndent }
    key     [A+J]       { MoveToLine }
    key     [A+K]       { BlockMarkColumn }
    key     [A+L]       { BlockMarkLine }
    key     [A+O]       { MainMenu 'O' }
    key     [A+R]       { WrapPara }           # Reformat 
    key     [A+S]       { MainMenu 'S' }
    key     [A+U]       { BlockUnindent }
    key     [C+S]       { IncrementalSearch }
    
    key     [C+O_C+A]   { ToggleAutoIndent }
    key     [C+O_C+C]   { ToggleMatchCase }
    key     [C+O_C+E]   { ToggleTrim }
    key     [C+O_C+I]   { ToggleInsert }
    key     [C+O_C+M]   { ShowMenu 'MChangeMode' }
    key     [C+O_S-M]   { ChangeMode }
    key     [C+O_C+R]   { ToggleReadOnly }
    key     [C+O_C+S]   { ToggleSysClipboard }
    key     [C+O_C+T]   { ChangeTabSize }
    key     [C+O_C+U]   { ToggleUndo }
    key     [C+O_C+W]   { ToggleWordWrap }
    key     [C+O_C+V]   { ShowMenu 'MCvs' }
    key     [C+O_C+N]   { ShowMenu 'MSvn' }
    key     [C+O_.]     { ToggleShowMarkers }
    key     [C+O_[]     { SetLeftMargin }     # set margin to current cursor pos
    key     [C+O_\]]    { SetRightMargin }
    key     [C+O_A+[]   { ChangeLeftMargin }
    key     [C+O_A+\]]  { ChangeRightMargin }
    key     [C+O_Tab]   { ToggleShowTabs ; WinRefresh }
    key     [C+O_C+Tab] { ToggleExpandTabs ; WinRefresh }
    # Detection Control+Tab is not possible for terminal - so accept shift
    key     [C+O_S+Tab] { ToggleExpandTabs ; WinRefresh }
    key     [C+O_G-Del] { ToggleDeleteKillTab }
    key     [C+O_G-Ins] { ToggleInsert }
    key    [C+O_BackSp] { ToggleBackSpKillTab }
    key     [C+O_Space] { ToggleIndentWithTabs }
    key  [C+O_C+BackSp] { ToggleBackSpUnindents }
    key     [A+-]       { MatchBracket }
    key     [A+=]       { HilitMatchBracket }
    key     [C+Space]   { InsPrevLineChar }
    key     [A+Space]   { InsPrevLineToEol }
    key     [C+_]       { ShowPosition }
    key     [C+-]       { ShowPosition }
    key       [Center]  { MoveLineCenter }
    #key     [C+X]       { MovePrevPos }
    key   [C+S+A]       { ASCIITable }

#    key     [G+*]       { LineInsert ; MoveUp; ScrollUp }
    
    key     [A+G++]     { FoldCreate }
    key     [A+G+-]     { FoldDestroy }
    key     [G+S++]     { FoldPromote }
    key     [G+S+-]     { FoldDemote }
    key     [C+G++]     { FoldOpen }
    key     [C+G+-]     { FoldClose }
    key     [C+G+*]     { FoldOpenNested }
    key     [C+G+/]     { FoldToggleOpenClose }
    key     [A+G+*]     { FoldOpenAll }
    key     [A+G+/]     { FoldCloseAll }
    
#    key     [C+G-Up]    { MoveFoldPrev }
#    key     [C+G-Down]  { MoveFoldNext }
    
    key     [A+,]     { SearchWordPrev }
    key     [A+.]     { SearchWordNext }
    key     [A+/]     { HilitWord }

    key     [C+\]]    { TagFindWord }
    key     [C+S+\]]  { TagFind }
    key     [C+[]     { TagPop }
    key     [A+\]]    { TagNext }
    key     [A+[]     { TagPrev }
    key     [S+Tab]   { InsertTab; LineTrim }
}
