Don't fail writing text outside screen
- Adding np check not to try using item outside of a screen - This fix essentially discards text write beyond screen bounds - Fixes #993
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2023 the original author or authors.
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -300,12 +300,14 @@ public class DefaultScreen implements Screen, DisplayLines {
|
||||
for (int i = 0; i < text.length() && i < columns; i++) {
|
||||
char c = text.charAt(i);
|
||||
DefaultScreenItem item = layer.getScreenItem(x + i, y);
|
||||
item.content = Character.toString(c);
|
||||
if (color > -1) {
|
||||
item.foreground = color;
|
||||
}
|
||||
if (style > -1) {
|
||||
item.style = style;
|
||||
if (item != null) {
|
||||
item.content = Character.toString(c);
|
||||
if (color > -1) {
|
||||
item.foreground = color;
|
||||
}
|
||||
if (style > -1) {
|
||||
item.style = style;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user