package com.example.myapplication.keyboard

import android.content.Context
import android.content.res.ColorStateList
import android.media.AudioManager
import android.os.Handler
import android.view.LayoutInflater
import android.view.inputmethod.InputConnection

interface KeyboardEnvironment {
    val ctx: Context
    val mainHandler: Handler
    val audioManager: AudioManager

    // 只保留 layoutInflater 的默认实现，避免跟 MyInputMethodService 冲突
    val layoutInflater: LayoutInflater
        get() = LayoutInflater.from(ctx)

    // 主题色
    val currentTextColor: ColorStateList
    val currentBorderColor: ColorStateList
    val currentBackgroundColor: ColorStateList

    // 文本 / 联想
    fun getCurrentWordPrefix(maxLen: Int = 128): String
    fun updateCompletionsAndRender(prefix: String)
    fun commitKey(c: Char)
    fun deleteOne()
    fun performSendAction()

    //键盘关闭
    fun getInputConnection(): InputConnection?
    fun hideKeyboard()

    // 键盘切换
    fun showMainKeyboard()
    fun showNumberKeyboard()
    fun showSymbolKeyboard()
    fun showAiKeyboard()
    //emoji键盘
    fun showEmojiKeyboard()

    // 音效
    fun playKeyClick()
    
    // 回填上次清空的文本
    fun revokeLastClearedText()
    
    // 检查是否有可回填的文本
    fun hasClearedText(): Boolean
}
