Skip to content

Commit

Permalink
fix(terminal): fixed text copy operation
Browse files Browse the repository at this point in the history
  • Loading branch information
vhqtvn committed Nov 19, 2022
1 parent 589700a commit 7e24b4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.text.TextUtils
import android.util.Log
import com.termux.shared.interact.ShareUtils
import com.termux.shared.shell.TermuxSession
import com.termux.shared.terminal.TermuxTerminalSessionClientBase
import com.termux.terminal.TerminalSession
import com.termux.terminal.TextStyle
import vn.vhn.vhscode.R
import vn.vhn.vhscode.root.fragments.TerminalFragment


Expand Down Expand Up @@ -74,11 +77,9 @@ class TermuxTerminalSingleSessionClient(fragment: TerminalFragment) :
}

override fun onCopyTextToClipboard(session: TerminalSession, text: String) {
val clipboard: ClipboardManager? =
mFragment.context?.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager?
clipboard?.setPrimaryClip(ClipData(null,
arrayOf("text/plain"),
ClipData.Item(attr.text.toString())))
ShareUtils.copyTextToClipboard(mFragment.requireContext(),
text,
mFragment.getString(R.string.copied))

}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,5 @@
<string name="acquire_wifi_lock">Acquire wifi lock.</string>
<string name="release_wifi_lock">Release wifi lock.</string>
<string name="locking_orientation_rewrite_write_settings">\"Modify system settings\" permission needs to be enabled!</string>
<string name="copied">Copied!</string>
</resources>

0 comments on commit 7e24b4b

Please sign in to comment.