require "smartinput"

local lng = smartinput.new_language("手", "HandWrite")

local pkgname = ""
local chspkgname = ""

lng.support_mode = smartinput.context.MATH + smartinput.context.PHONE + smartinput.context.NUMBER

lng.surfaces = {
    {
        surface_id = pkgname .. "chs_handwrite.sur",
        surface_type = smartinput.surface_type.SOFT_KEYBOARD,
        surface_subtype = smartinput.surface_subtype.KEYBOARD_FULL,
        surface_display_name = "chs_handwrite",
    },

    {
        surface_id = pkgname .. "chs_handwrite_half.sur",
        surface_type = smartinput.surface_type.SOFT_KEYBOARD,
        surface_subtype = smartinput.surface_subtype.KEYBOARD_PHONEPAD,
        surface_display_name = "chs_handwrite",
    },

    {
        surface_id = "more.sur",
        surface_type = smartinput.surface_type.SOFT_FULLCANDIDATE,
        surface_display_name = "more",
    },

    {
        surface_id = "chs_sym_number.sur",
        surface_type = smartinput.surface_type.SOFT_SYMBOL,
        surface_display_name = "symbol",
    },

    {
        surface_id = "phone_special.sur",
        surface_type = smartinput.surface_type.SOFT_SPECIAL,
        support_mode = smartinput.context.PHONE,
        surface_display_name = "phone_special",
    },

    {
        surface_id = "edit.sur",
        surface_type = smartinput.surface_type.SOFT_SPECIAL,
        surface_display_name = "edit",
    },

    {
        surface_id = "voice.sur",
        surface_type = smartinput.surface_type.SOFT_SPECIAL,
        surface_display_name = "edit",
    },

    {
        surface_id = "number.sur",
        surface_type = smartinput.surface_type.SOFT_SYMBOL,
        support_mode = smartinput.context.NUMBER + smartinput.context.MATH,
        surface_display_name = "number",
    },

    {
        surface_id = "abc.sur",
        surface_type = smartinput.surface_type.SOFT_SPECIAL,
        surface_layout = smartinput.surface_layout.QW,
        surface_display_name = "abc",
    },

    {
        surface_id = "chs_soft_sym1.sur",
        surface_type = smartinput.surface_type.SOFT_SYMBOL,
            surface_display_name = "symbol",
    },

    {
        surface_id = "chs_soft_sym2.sur",
        surface_type = smartinput.surface_type.SOFT_SYMBOL,
        surface_display_name = "symbol",
    },

    {
        surface_id = "chs_soft_sym3.sur",
        surface_type = smartinput.surface_type.SOFT_SYMBOL,
        surface_display_name = "symbol",
    },

    {
        surface_id = "eng_soft_sym1.sur",
        surface_type = smartinput.surface_type.SOFT_SYMBOL,
        surface_display_name = "symbol",
    },

    {
        surface_id = "eng_soft_sym2.sur",
        surface_type = smartinput.surface_type.SOFT_SYMBOL,
        surface_display_name = "symbol",
    },

    {
        surface_id = "eng_soft_sym3.sur",
        surface_type = smartinput.surface_type.SOFT_SYMBOL,
        surface_display_name = "symbol",
    },

    {
        surface_id = "url_navigator.sur",
        surface_type = smartinput.surface_type.SOFT_SPECIAL,
        surface_display_name = "url_navigator",
    },
}

lng.support_keyboard = {
	smartinput.keyboard_type.SOFT_KEYBOARD
}

lng.categories[smartinput.language.category.FASTSWITCH] = "chinese"
lng.categories[smartinput.language.category.LAYOUT] = "handwrite"

lng.traits = "chspy_traits.trt"

lng.dictionary = smartinput.new_engine(smartinput.dictionary.engine_type.OCEAN, smartinput.dictionary.dict_type.CHS_PINYIN)

lng.dictionary.files = {
	{
		file_name = chspkgname .. "pinyin.rom3",
		file_type = smartinput.dictionary.image_type.ROM,
		open_mode = smartinput.file.READ,
		load_mode = smartinput.dictionary.load_mode.COMP_ARRAY,
	},
	{	
		file_name = chspkgname .. "chinese_simplified.usr",
		file_type = smartinput.dictionary.image_type.USR,
		open_mode = smartinput.file.READWRITE,
		load_mode = smartinput.dictionary.load_mode.PURE_FILE,
	},
	{
		file_name = chspkgname .. "simptrad.rom",
		file_type = smartinput.dictionary.image_type.ROM,
		open_mode = smartinput.file.READ,
		load_mode = smartinput.dictionary.load_mode.PURE_ARRAY,
	},
}

lng.handwrite = smartinput.new_engine(smartinput.dictionary.engine_type.MULTIHW, -1)

lng.handwrite.files = {
	{
		file_name = pkgname.."license.dat",
		open_mode = smartinput.file.READ
	},
	{
		file_name = pkgname.."handwrite.dat",
		open_mode = smartinput.file.READ
	},
}

lng.get_traits = function ()
    if not lng.loaded_traits then
        lng.loaded_traits = dofile(lng.traits)
    end
    return lng.loaded_traits
end

return lng
