Skip to content

Commit

Permalink
fix: newLine in GetText of TextView
Browse files Browse the repository at this point in the history
After
rivo/tview@7344139,
the newLine problem has been fixed.
  • Loading branch information
eeeXun committed Apr 8, 2024
1 parent 42bed00 commit 024aa56
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,21 +528,15 @@ func translateWindowHandler(event *tcell.EventKey) *tcell.EventKey {

// only copy when text exist
if len(text) > 0 {
CopyToClipboard(text[:len(text)-1])
CopyToClipboard(text)
}
return nil
case keyMaps["swap_language"]:
translator.SwapLang()
updateCurrentLang()
srcText := srcInput.GetText()
dstText := dstOutput.GetText(false)
if len(dstText) > 0 {
// GetText of Box contains "\n" if it has words
srcInput.SetText(dstText[:len(dstText)-1], true)
} else {
srcInput.SetText(dstText, true)
}
dstOutput.SetText(srcText)
tmp := srcInput.GetText()
srcInput.SetText(dstOutput.GetText(false), true)
dstOutput.SetText(tmp)
return nil
case keyMaps["tts_source"]:
// Play text to speech on source of translation window.
Expand Down

0 comments on commit 024aa56

Please sign in to comment.