#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 偺偳偐 - emacsedit.nodoka
# Copyright (C) 1999-2005, TAGA Nayuta <nayuta@users.sourceforge.net>
#
# Modify by applet on Jul. 26, 2008


#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Emacs 晽堏摦僐儅儞僪
#

keymap	EmacsMove : Global
 key Home		= C-Home		# 暥摢
 key End		= C-End			# 暥枛
 key C-Space		= &Undefined		# Mark
 key C-A		= Home			# 峴摢
 key C-B		= Left			# 仼
 key M-B		= C-Left		# 仼(扨岅)
 key C-E		= End			# 峴枛
 key C-F		= Right			# 仺
 key M-F		= C-Right		# 仺(扨岅)
 key C-G		= Escape		# CANCEL
 key C-L		= &WindowRedraw &Recenter # 嵞昤夋
 key C-N		= Down			# 伀
 key C-P		= Up			# 仾
 key C-Q		= &Prefix(KeymapDefault) # mayu 偵嵍塃偝傟側偄僉乕擖椡
 key C-S		= C-F			# 専嶕
 if ( !ZXCV ) key C-V	= Next			# 師暸
 key M-V		= Prior			# 慜暸
 key S-Home		= S-C-Home		# 暥摢(慖戰)
 key S-End		= S-C-End		# 暥枛(慖戰)
 key S-M-Comma		= C-Home		# 暥摢
 key S-M-Period		= C-End			# 暥枛

 if ( EmacsMove/ShiftSelection )
   key S-C-A		= S-Home		# 峴摢(慖戰)
   key S-C-B		= S-Left		# 仼(慖戰)
   key S-C-E		= S-End			# 峴枛(慖戰)
   key S-C-F		= S-Right		# 仺(慖戰)
   key S-C-N		= S-Down		# 伀(慖戰)
   key S-C-P		= S-Up			# 仾(慖戰)
   key S-C-V		= S-Next		# 師暸(慖戰)
   key S-M-V		= S-Prior		# 慜暸(慖戰)
 endif


#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Emacs 晽曇廤僐儅儞僪
#

 keyseq	$EmacsEdit/kill-word		= S-C-Right C-X
 keyseq	$EmacsEdit/backward-kill-word	= S-C-Left C-X
 keyseq	$EmacsEdit/transpose-chars	= S-Right C-X Left C-V Right
 keyseq	$EmacsEdit/upcase-word		= S-C-Right C-C *&Sync \
					  &ClipboardUpcaseWord C-V
 keyseq	$EmacsEdit/downcase-word	= S-C-Right C-C *&Sync \
					  &ClipboardDowncaseWord C-V
 keyseq	$EmacsEdit/kill-line		= &EmacsEditKillLineFunc S-End C-X \
			&Sync &EmacsEditKillLinePred((Delete), (Return Left))
 keyseq	$EmacsMark/cancel		= Left Right


keymap	EmacsEdit : EmacsMove
keymap2	EmacsMark : EmacsEdit = $EmacsMark/cancel &KeymapWindow
keymap2 EmacsMarkEscape : EmacsMark = &KeymapParent

keymap2	EmacsC-X : EmacsEdit
 event prefixed		= &HelpMessage("EmacsEdit C-x-", "C-x u\tundo")
 event before-key-down	= &HelpMessage
 key *U			= C-Z					# UNDO

keymap2 EmacsC-U0_9C-U : Global \
		= &Repeat((&KeymapWindow), 100) &HelpMessage &Variable(0, 0)
 key C-G	= &HelpMessage &Variable(0, 0) &Ignore
 
keymap2 EmacsC-U0_9 : EmacsC-U0_9C-U
 event prefixed		= &HelpVariable("孞傝曉偟")
 key _0 Num0		= &Variable(10, 0) &Prefix(EmacsC-U0_9)
 key _1 Num1		= &Variable(10, 1) &Prefix(EmacsC-U0_9)
 key _2 Num2		= &Variable(10, 2) &Prefix(EmacsC-U0_9)
 key _3 Num3		= &Variable(10, 3) &Prefix(EmacsC-U0_9)
 key _4 Num4		= &Variable(10, 4) &Prefix(EmacsC-U0_9)
 key _5 Num5		= &Variable(10, 5) &Prefix(EmacsC-U0_9)
 key _6 Num6		= &Variable(10, 6) &Prefix(EmacsC-U0_9)
 key _7 Num7		= &Variable(10, 7) &Prefix(EmacsC-U0_9)
 key _8 Num8		= &Variable(10, 8) &Prefix(EmacsC-U0_9)
 key _9 Num9		= &Variable(10, 9) &Prefix(EmacsC-U0_9)
 key C-U		= &Prefix(EmacsC-U0_9C-U)

keymap2 EmacsC-U : EmacsC-U0_9C-U
 event prefixed		= &HelpVariable("孞傝曉偟")
 key _0 Num0		= &Variable(0, 0) &Prefix(EmacsC-U0_9)
 key _1 Num1		= &Variable(0, 1) &Prefix(EmacsC-U0_9)
 key _2 Num2		= &Variable(0, 2) &Prefix(EmacsC-U0_9)
 key _3 Num3		= &Variable(0, 3) &Prefix(EmacsC-U0_9)
 key _4 Num4		= &Variable(0, 4) &Prefix(EmacsC-U0_9)
 key _5 Num5		= &Variable(0, 5) &Prefix(EmacsC-U0_9)
 key _6 Num6		= &Variable(0, 6) &Prefix(EmacsC-U0_9)
 key _7 Num7		= &Variable(0, 7) &Prefix(EmacsC-U0_9)
 key _8 Num8		= &Variable(0, 8) &Prefix(EmacsC-U0_9)
 key _9 Num9		= &Variable(0, 9) &Prefix(EmacsC-U0_9)
 key C-U		= &Variable(4, 0) &Prefix(EmacsC-U)

keymap	EmacsEdit
 key C-Space		= &Prefix(EmacsMark)			# Mark
 key M-BackSpace	= $EmacsEdit/backward-kill-word		# BS(扨岅)
 key C-D		= Delete				# 嶍彍
 key M-D		= $EmacsEdit/kill-word			# 嶍彍(扨岅)
 key C-H		= BackSpace				# BS
 key C-J		= Return				# RETURN
 key C-K		= $EmacsEdit/kill-line			# 峴枛傑偱嶍彍
 key C-M		= Return				# RETURN
 key C-O		= Return Left				# 堦峴憹傗偡
 if ( !GANA ) key C-T	= $EmacsEdit/transpose-chars		# 暥帤擖傟懼偊
 key C-W		= C-X					# CUT
 key M-W		= C-C					# COPY
 key C-U		= &Variable(0, 4) &Prefix(EmacsC-U)
 if ( !ZXCV ) key C-X	= &Prefix(EmacsC-X)
 key C-Y		= C-V					# PASTE
 key C-Slash		= C-Z					# UNDO
 key M-U		= $EmacsEdit/upcase-word		# 戝暥帤
 key M-L		= $EmacsEdit/downcase-word		# 彫暥帤

keymap2	EmacsMark
 key Home		= S-C-Home	&Prefix(EmacsMark)	# 暥摢
 key End		= S-C-End	&Prefix(EmacsMark)	# 暥枛
 key C-A		= S-Home	&Prefix(EmacsMark)	# 峴摢
 key C-B		= S-Left	&Prefix(EmacsMark)	# 仼
 key M-B		= S-C-Left	&Prefix(EmacsMark)	# 仼(扨岅)
 key C-E		= S-End		&Prefix(EmacsMark)	# 峴枛
 key C-F		= S-Right	&Prefix(EmacsMark)	# 仺
 key M-F		= S-C-Right	&Prefix(EmacsMark)	# 仺(扨岅)
 key C-G		= $EmacsMark/cancel &Undefined		# 僉儍儞僙儖
 key C-N		= S-Down	&Prefix(EmacsMark)	# 伀
 key C-P		= S-Up		&Prefix(EmacsMark)	# 仾
 if ( !ZXCV ) key C-V	= S-Next	&Prefix(EmacsMark)	# 師暸
 key M-V		= S-Prior	&Prefix(EmacsMark)	# 慜暸
 key C-W		= C-X Left Right			# CUT
 key M-W		= C-C Left Right			# COPY
 key S-M-Comma		= S-C-Home	&Prefix(EmacsMark)	# 暥摢
 key S-M-Period		= S-C-End	&Prefix(EmacsMark)	# 暥枛
 key Left		= S-Left	&Prefix(EmacsMark)	# 仼
 key Up			= S-Up		&Prefix(EmacsMark)	# 仾
 key Right		= S-Right	&Prefix(EmacsMark)	# 仺
 key Down		= S-Down	&Prefix(EmacsMark)	# 伀
 if ( MAP-ESCAPE-TO-META )
   key Escape		= &Prefix(EmacsMarkEscape) &EditNextModifier(M-)
   if ( KBD109 ) and ( ! KBD104on109 )
     key 敿妏/慡妏	= &Prefix(EmacsMarkEscape) &EditNextModifier(M-)
   endif
 endif

keymap2 EmacsMarkEscape
 event prefixed		= &HelpMessage("EmacsMark ESC-", " ")
 event before-key-down	= &HelpMessage
 key M-C-G		= &Ignore
