require "smartinput"

local lng = smartinput.new_language("En", "English")

lng.on_load = function ()
    local si = smartinput
    local pi = si.pending_input
    local ts = si.tri_status
    while not pi.empty() do
        pi.delete_range()
    end
    ts.set_tri_status(ts.CAPSLOCK, ts.AUTO)
end

lng.surfaces = {
    {
        surface_id = "eng_soft_qwerty.sur",
        surface_type = smartinput.surface_type.SOFT_KEYBOARD,
        surface_subtype = smartinput.surface_subtype.KEYBOARD_FULL,
        surface_layout = smartinput.surface_layout.QW,
        support_mode = smartinput.context.EMAIL + smartinput.context.DATE + smartinput.context.PASSWORD,
        surface_display_name = "eng_soft_qwerty",
    },
    
    {
        surface_id = "eng_soft_phonepad.sur",
        surface_type = smartinput.surface_type.SOFT_KEYBOARD,
        surface_subtype = smartinput.surface_subtype.KEYBOARD_PHONEPAD,
        surface_display_name = "eng_soft_phonepad",
    },

    {
        surface_id = "eng_soft_tplus.sur",
        surface_type = smartinput.surface_type.SOFT_KEYBOARD,
        surface_subtype = smartinput.surface_subtype.KEYBOARD_TPLUS,
        surface_layout = smartinput.surface_layout.QW,
        surface_display_name = "eng_soft_tplus",
    },

    {
        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,
        support_mode = smartinput.context.MATH,
        surface_display_name = "symbol",
    },

    {
        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 = "number_left.sur",
        surface_type = smartinput.surface_type.SOFT_SYMBOL,
        surface_display_name = "number_left",
    },

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

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



lng.support_keyboard = {
	smartinput.keyboard_type.SOFT_KEYBOARD
}

lng.categories[smartinput.language.category.FASTSWITCH] = "english"
lng.categories[smartinput.language.category.LAYOUT] = "western"
lng.categories[smartinput.language.category.MIXINPUT] = "english"
lng.categories[smartinput.language.category.NEXTWORD] = "western"
lng.categories[smartinput.language.category.USERWORD] = "western"

lng.traits = "english_traits.trt"

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

lng.dictionary.files = {
	{
		file_name = "english.rom",
		file_type = smartinput.dictionary.image_type.ROM,
		open_mode = smartinput.file.READ,
        load_mode = smartinput.dictionary.load_mode.PURE_ARRAY
	},
	{	
		file_name = "english.ram",
		file_type = smartinput.dictionary.image_type.RAM,
		open_mode = smartinput.file.READWRITE,
        load_mode = smartinput.dictionary.load_mode.PURE_ARRAY
	},
	{	
		file_name = "western.usr",
		file_type = smartinput.dictionary.image_type.USR,
		open_mode = smartinput.file.READWRITE
	},
}
 
lng.curve = smartinput.new_engine(smartinput.dictionary.engine_type.CURVE, smartinput.curve_dict.engine_type.WESTERN)

lng.curve.files = {
-- QWERTY

        {
                file_name = "qw_eng_curve_dict.imy",
                file_tag = smartinput.dictionary.image_tag.QWERTY + smartinput.dictionary.image_tag.FULL,
                open_mode = smartinput.file.READ
        },
        {
                file_name = "qw_eng_curve_prefix.imy",
                file_tag = smartinput.dictionary.image_tag.QWERTY + smartinput.dictionary.image_tag.FULL,
                open_mode = smartinput.file.READ
        },
        {
                file_name = "qw_eng_curve_full.imy",
                file_tag = smartinput.dictionary.image_tag.QWERTY + smartinput.dictionary.image_tag.FULL,
                open_mode = smartinput.file.READ
        },
        {
                file_name = "qw_eng_curve_layout.imy",
                file_tag = smartinput.dictionary.image_tag.QWERTY + smartinput.dictionary.image_tag.FULL,
                open_mode = smartinput.file.READ        
        },
        {
                file_name = "/var/mobile/Library/Keyboard/TouchPal/core/western_curve_qw.usr",
                file_tag = smartinput.dictionary.image_tag.QWERTY,
                open_mode = smartinput.file.NONE
        },
}


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

return lng

