; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "BSD 2-clause" license."          |
;|_______________________________________________________________________________________|
;
;  Description: TFreshEdit themes library.
;
;  Target OS: Any
;
;  Dependencies: None
;
;  Notes:
;_________________________________________________________________________________________

module "TFreshEdit default theme"


struct TShortcut
  .key        dd  ?     ; if .key is <> 0 the scancode and .kbdStatus are not used.
  .scancode   dd  ?
  .kbdStatus  dd  ?
  .maskStatus dd  ?     ; what bits from the kbdStatus to be compared
ends


macro Shortcut .key, .scancode, .kbdstatus, .maskstatus {
        dd  .key
        dd  .scancode
        dd  .kbdstatus
        dd  .maskstatus
}


eoAutoIndents       = 1
eoSaveWithTabs      = 2
eoVerticalCaret     = 4
eoStripedBackground = 8
eoLeftMargin        = 16
eoLineNumbers       = 32


struct TFETheme
; colors
  .clBackground      dd ?       ; background color of the editor field.
  .clAltBack         dd ?       ; althernative background (when eoStripedBackground is true)
  .clSimpleText      dd ?       ; The default color of the text, when no syntax highlighter is attached.
  .clProtectedText   dd ?       ; the color of the protected line text.

  .clSelBack         dd ?       ;
  .clSelMode         dd ?       ;

  .clLeftMargin      dd ?       ; the color of the left margin field.
  .clLeftMarginBorder dd ?       ; left margin border color.
  .clLeftMarginText  dd ?
  .clLeftMarginTree  dd ?

  .clBookmarkBack    dd ?       ; background of the left margin when the bookmark is set.
  .clWrapColumn      dd ?       ; color of the line that marks word wrap column.

; options and behavior
  .Options           dd ?       ; flags eoLineSeparator, eoAutoIndents, eoSaveWithTabs, eoVerticalCaret
  .MouseWheel        dd ?       ; the count of the lines, one mouse wheel event scrolls.
  .WrapPos           dd ?       ; word wrap position for the lines that have lfWordWrap flag set.
  .UndoLevels        dd ?       ; how many levels of undo/redo to be remembered.

; keyboard shortcuts:

; navigation
  .shortcuts:
  .keyUp             TShortcut
  .keyDown           TShortcut
  .keyLeft           TShortcut
  .keyRight          TShortcut
  .keyPgUp           TShortcut
  .keyPgDn           TShortcut
  .keyHome           TShortcut
  .keyEnd            TShortcut
  .keyPageBegin      TShortcut
  .keyPageEnd        TShortcut
  .keyTextBegin      TShortcut
  .keyTextEnd        TShortcut
  .keyWordLeft       TShortcut
  .keyWordRight      TShortcut

; Edit
  .Delete            TShortcut
  .DelLine           TShortcut
  .Backspace         TShortcut

; Formating
  .ToggleWordWrap    TShortcut
  .ToggleBookmark    TShortcut

; Control
  .ToggleInsMode     TShortcut
  .ToggleSelMode     TShortcut
  .shortcuts.count = ($ - .shortcuts)/sizeof.TShortcut
ends


iglobal
  if used FreshEditThemeKeys
    FreshEditThemeKeys:
        ; colors
          dd    TFETheme.clBackground,          'cBKG'
          dd    TFETheme.clAltBack,             'cABK'
          dd    TFETheme.clSimpleText,          'cTXT'
          dd    TFETheme.clProtectedText,       'cPRT'
          dd    TFETheme.clSelBack,             'cSBK'
          dd    TFETheme.clSelMode,             'cSMD'
          dd    TFETheme.clLeftMargin,          'cMrg'
          dd    TFETheme.clLeftMarginBorder,    'cMBr'
          dd    TFETheme.clLeftMarginText,      'cMTx'
          dd    TFETheme.clLeftMarginTree,      'cMTr'
          dd    TFETheme.clBookmarkBack,        'cBMB'
          dd    TFETheme.clWrapColumn,          'cWrC'

          dd    TFETheme.Options,               'Opts'
          dd    TFETheme.MouseWheel             'nWhl'
          dd    TFETheme.WrapPos,               'WrPs'
          dd    TFETheme.UndoLevels,            'UdLv'

        ; keyboard shortcuts:
        ; navigation
          dd    TFETheme.keyUp,                 'kkUp'
          dd    TFETheme.keyDown,               'kkDn'
          dd    TFETheme.keyLeft,               'kLft'
          dd    TFETheme.keyRight,              'kRgt'
          dd    TFETheme.keyPgUp,               'kPUp'
          dd    TFETheme.keyPgDn,               'kPDn'
          dd    TFETheme.keyHome,               'kHom'
          dd    TFETheme.keyEnd,                'kEnd'
          dd    TFETheme.keyPageBegin,          'kPgB'
          dd    TFETheme.keyPageEnd,            'kPgE'
          dd    TFETheme.keyTextBegin,          'kTxB'
          dd    TFETheme.keyTextEnd,            'kTxE'
          dd    TFETheme.keyWordLeft,           'kWdL'
          dd    TFETheme.keyWordRight,          'kWdR'

        ; Edit
          dd    TFETheme.Delete,                'kDel'
          dd    TFETheme.DelLine,               'kDLn'
          dd    TFETheme.Backspace,             'kBkS'

        ; Formating
          dd    TFETheme.ToggleWordWrap,        'kWWr'
          dd    TFETheme.ToggleBookmark,        'kBkm'
          dd    TFETheme.ToggleInsMode,         'kIMd'
          dd    TFETheme.ToggleSelMode,         'kSMd'
          dd    0
  end if
endg



iglobal
  if used TFETheme.DefaultShortcuts
    TFETheme.DefaultShortcuts:
          Shortcut 0,   keyUp,     0,        maskCtrl or maskAlt    ; up
          Shortcut 0,   keyDown,   0,        maskCtrl or maskAlt    ; down
          Shortcut 0,   keyLeft,   0,        maskCtrl or maskAlt    ; left
          Shortcut 0,   keyRight,  0,        maskCtrl or maskAlt    ; right
          Shortcut 0,   keyPgUp,   0,        maskCtrl or maskAlt    ; pg up
          Shortcut 0,   keyPgDown, 0,        maskCtrl or maskAlt    ; pg dn
          Shortcut 0,   keyHome,   0,        maskCtrl or maskAlt    ; home
          Shortcut 0,   keyEnd,    0,        maskCtrl or maskAlt    ; end
          Shortcut 0,   keyHome,   maskCtrl, maskCtrl or maskAlt    ; page begin
          Shortcut 0,   keyEnd,    maskCtrl, maskCtrl or maskAlt    ; page end
          Shortcut 0,   keyPgUp,   maskCtrl, maskCtrl or maskAlt    ; text begin
          Shortcut 0,   keyPgDown, maskCtrl, maskCtrl or maskAlt    ; text end
          Shortcut 0,   keyLeft,   maskCtrl, maskCtrl or maskAlt    ; word left
          Shortcut 0,   keyRight,  maskCtrl, maskCtrl or maskAlt    ; word right
          Shortcut 0,   keyDelete, 0,        maskCtrl or maskAlt    ; delete
          Shortcut $19, 0,         0,        0                      ; del line = ctrl+Y
          Shortcut $08, 0,         0,        0                      ; back space = ctrl+H = backspace
          Shortcut $17, 0,         0,        0                      ; Toggle word wrap = ctrl+W
          Shortcut $02, 0,         0,        0                      ; Toggle bookmark = ctrl+B
          Shortcut 0,   keyInsert, 0,        maskAlt                ; Toggle insert mode
          Shortcut 0,   keyInsert, maskAlt,  maskAlt                ; Toggle selection mode
    TFETheme.DefaultShortcuts.size = ($ - TFETheme.DefaultShortcuts)/4
  end if
endg

uglobal
  FreshEditTheme TFETheme
endg

if used vtables.TFreshEdit
initialize InitFreshEditTheme
begin
        stdcall TFETheme.SetDefaultThemeWindows, FreshEditTheme
        return
endp
end if




endmodule