update room scrollback limit to new api, update TODO
This commit is contained in:
1
TODO.md
1
TODO.md
@ -25,7 +25,6 @@ This helps with scalability
|
||||
### Chat
|
||||
* echo "unknown/innappropriate command" in the console
|
||||
* break up lines on CR/LF, send multiple messages
|
||||
* Style timestamps and persona names
|
||||
* enforce # in room names or ignore it
|
||||
* auto-create/join channel on server start
|
||||
* jump from notification window to room with message
|
||||
|
@ -246,12 +246,8 @@ class ChatRoomController {
|
||||
private void trimLines() {
|
||||
if (model.settings.maxChatLines < 0)
|
||||
return
|
||||
// TODO: update to JTextPane api
|
||||
// while(view.roomTextArea.getLineCount() > model.settings.maxChatLines) {
|
||||
// int line0Start = view.roomTextArea.getLineStartOffset(0)
|
||||
// int line0End = view.roomTextArea.getLineEndOffset(0)
|
||||
// view.roomTextArea.replaceRange(null, line0Start, line0End)
|
||||
// }
|
||||
while(view.getLineCount() > model.settings.maxChatLines)
|
||||
view.removeFirstLine()
|
||||
}
|
||||
|
||||
void rejoinRoom() {
|
||||
|
@ -11,6 +11,7 @@ import javax.swing.JSplitPane
|
||||
import javax.swing.JTextPane
|
||||
import javax.swing.ListSelectionModel
|
||||
import javax.swing.SwingConstants
|
||||
import javax.swing.text.Element
|
||||
import javax.swing.text.Style
|
||||
import javax.swing.text.StyleConstants
|
||||
import javax.swing.text.StyleContext
|
||||
@ -208,4 +209,15 @@ class ChatRoomView {
|
||||
doc.insertString(doc.getEndPosition().getOffset() - 1, text, doc.getStyle("regular"))
|
||||
doc.insertString(doc.getEndPosition().getOffset() - 1, "\n", doc.getStyle("regular"))
|
||||
}
|
||||
|
||||
int getLineCount() {
|
||||
StyledDocument doc = roomTextArea.getStyledDocument()
|
||||
doc.getDefaultRootElement().getElementCount() - 1
|
||||
}
|
||||
|
||||
void removeFirstLine() {
|
||||
StyledDocument doc = roomTextArea.getStyledDocument()
|
||||
Element element = doc.getParagraphElement(0)
|
||||
doc.remove(0, element.getEndOffset())
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user