Beginning implementation of newlines inside code blocks.
@@ -432,9 +432,17 @@ func NewWindow(doRestart chan bool, app *tview.Application, session *discordgo.S
if event.Key() == tcell.KeyEnter {
if window.selectedChannel != nil {
+ left := []rune(window.messageInput.internalTextView.GetRegionText("left"))
+ right := []rune(window.messageInput.internalTextView.GetRegionText("right"))
+ if window.IsCursorInsideCodeBlock(left, right) {
+ // Insert new line char
+ selection := []rune(window.messageInput.internalTextView.GetRegionText("selection"))
+ window.messageInput.InsertCharacter(left, right, selection, '\n')
+ } else {
window.TrySendMessage(window.selectedChannel, messageToSend)
}
}
+ }
return event
})
@@ -841,6 +849,11 @@ func NewWindow(doRestart chan bool, app *tview.Application, session *discordgo.S
return window, nil
}
+func (window *Window) IsCursorInsideCodeBlock(left, right []rune) bool {
+ // TODO: Implement based on existing client's functionality.
+ return false
+}
+
func (window *Window) insertQuoteOfMessage(message *discordgo.Message) {
time, parseError := message.Timestamp.Parse()
if parseError == nil {
