(require 'init-frame-hooks)

(defun fix-up-xterm-control-arrows ()
  (let ((map (if (boundp 'input-decode-map)
                 input-decode-map
               function-key-map)))
    (define-key map "\e[1;5A" [C-up])
    (define-key map "\e[1;5B" [C-down])
    (define-key map "\e[1;5C" [C-right])
    (define-key map "\e[1;5D" [C-left])
    (define-key map "\e[5A"   [C-up])
    (define-key map "\e[5B"   [C-down])
    (define-key map "\e[5C"   [C-right])
    (define-key map "\e[5D"   [C-left])))

(add-hook 'after-make-console-frame-hooks
          (lambda ()
            (when (< emacs-major-version 23)
              (fix-up-xterm-control-arrows))
            (xterm-mouse-mode 1) ; Mouse in a terminal (Use shift to paste with middle button)
            (mwheel-install)))

(provide 'init-xterm)
(require 'init-frame-hooks)

(defun fix-up-xterm-control-arrows ()
  (let ((map (if (boundp 'input-decode-map)
                 input-decode-map
               function-key-map)))
    (define-key map "\e[1;5A" [C-up])
    (define-key map "\e[1;5B" [C-down])
    (define-key map "\e[1;5C" [C-right])
    (define-key map "\e[1;5D" [C-left])
    (define-key map "\e[5A"   [C-up])
    (define-key map "\e[5B"   [C-down])
    (define-key map "\e[5C"   [C-right])
    (define-key map "\e[5D"   [C-left])))

(add-hook 'after-make-console-frame-hooks
          (lambda ()
            (when (< emacs-major-version 23)
              (fix-up-xterm-control-arrows))
            (xterm-mouse-mode 1) ; Mouse in a terminal (Use shift to paste with middle button)
            (when (fboundp 'mwheel-install)
              (mwheel-install))))

(provide 'init-xterm)

Handle console-only Emacs builds, which lack mwheel-install
Handle console-only Emacs builds, which lack mwheel-install

Closes #85

wenpincui/emacs.d,arthurl/emacs.d,hkcqr/emacs.d,DarkThrone/emacs.d,jhpx/emacs.d,baohaojun/emacs.d,svenyurgensson/emacs.d,kindoblue/emacs.d,krzysz00/emacs.d,gsmlg/emacs.d,farzadbekran/emacs.d,farzadbekran/emacs.d,ruiyang/emacs.d,jthetzel/emacs.d,46do14/emacs.d,kongfy/emacs.d,jachinpy/emacs.d,caoyuanqi/emacs.d,mpwang/emacs.d,LKI/emacs.d,hophacker/emacs.d,jachinpy/emacs.d,boblannon/emacs.d,zhuoyikang/emacs.d,danfengcao/emacs.d,blueabysm/emacs.d,modkzs/emcs.d,farzadbekran/emacs.d,lust4life/emacs.d,ernest-dzf/emacs.d,blueseason/emacs.d,scorpionis/emacs.d,Togal/emacs.d,dhanunjaya/emacs.d,LittleLmp/emacs.d,zenith-john/emacs.d,benkha/emacs.d,mmqmzk/emacs.d,roxolan/emacs.d,Werewolflsp/emacs.d,alant/emacs.d,zhaotai/.emacs.d,fengxl/emacs.d,qianwan/emacs.d,ruiyang/emacs.d,atreeyang/emacs.d,wegatron/emacs.d,lromang/emacs.d,purcell/emacs.d,whizzzkid/emacs.d,Jadecity/PurcellEmacs.d,Shanicky/emacs.d,shafayetkhan/emacs.d,me020523/emacs.d,sgarciac/emacs.d,farzadbekran/emacs.d,cjqw/emacs.d,dongdonghu/.emacs.d,farzadbekran/emacs.d,Guoozz/emacs.d,lujianmei/emacs.d,jkaessens/emacs.d,bibaijin/emacs.d,renatoriccio/emacs.d,braveoyster/emacs.d,carlosliu/emacs.d,qinshulei/emacs.d,exclamaforte/emacs.d,pairyo/emacs.d,haodaivshen/emacs.d,cyjia/emacs.d,dcorking/emacs.d,ilove0518/emacs.d,Enzo-Liu/emacs.d,emuio/emacs.d