git://git.nikiroo.be
/
fanfix.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9f613a0
)
#35 wip
author
Kevin Lamonte
<kevin.lamonte@gmail.com>
Sat, 10 Aug 2019 05:33:08 +0000
(
00:33
-0500)
committer
Kevin Lamonte
<kevin.lamonte@gmail.com>
Sat, 10 Aug 2019 05:33:08 +0000
(
00:33
-0500)
src/jexer/TApplication.java
patch
|
blob
|
blame
|
history
src/jexer/TCalendar.java
patch
|
blob
|
blame
|
history
src/jexer/TDirectoryList.java
patch
|
blob
|
blame
|
history
src/jexer/TMessageBox.java
patch
|
blob
|
blame
|
history
src/jexer/TText.java
patch
|
blob
|
blame
|
history
src/jexer/bits/StringUtils.java
patch
|
blob
|
blame
|
history
src/jexer/ttree/TTreeViewWidget.java
patch
|
blob
|
blame
|
history
src/jexer/ttree/TTreeViewWindow.java
patch
|
blob
|
blame
|
history
diff --git
a/src/jexer/TApplication.java
b/src/jexer/TApplication.java
index 7c96258b4405c00a5660788262a235a3c69c74d9..bffe38e455f13658b4c7988c776e4c6af8d9b12a 100644
(file)
--- a/
src/jexer/TApplication.java
+++ b/
src/jexer/TApplication.java
@@
-48,6
+48,7
@@
import java.util.ResourceBundle;
import jexer.bits.Cell;
import jexer.bits.CellAttributes;
import jexer.bits.ColorTheme;
import jexer.bits.Cell;
import jexer.bits.CellAttributes;
import jexer.bits.ColorTheme;
+import jexer.bits.StringUtils;
import jexer.event.TCommandEvent;
import jexer.event.TInputEvent;
import jexer.event.TKeypressEvent;
import jexer.event.TCommandEvent;
import jexer.event.TInputEvent;
import jexer.event.TKeypressEvent;
@@
-518,9
+519,7
@@
public class TApplication implements Runnable {
}
} // while (!application.quit)
}
} // while (!application.quit)
- assert (dirty == true);
-
- // Flush the screen contents
+ // Flush the screen contents
if (debugThreads) {
System.err.printf("%d %s backend.flushScreen()\n",
System.currentTimeMillis(), Thread.currentThread());
if (debugThreads) {
System.err.printf("%d %s backend.flushScreen()\n",
System.currentTimeMillis(), Thread.currentThread());
@@
-1842,7
+1841,7
@@
public class TApplication implements Runnable {
menuMnemonicColor = theme.getColor("tmenu.mnemonic");
}
// Draw the menu title
menuMnemonicColor = theme.getColor("tmenu.mnemonic");
}
// Draw the menu title
- getScreen().hLineXY(x, 0,
menu.getTitle().length(
) + 2, ' ',
+ getScreen().hLineXY(x, 0,
StringUtils.width(menu.getTitle()
) + 2, ' ',
menuColor);
getScreen().putStringXY(x + 1, 0, menu.getTitle(), menuColor);
// Draw the highlight character
menuColor);
getScreen().putStringXY(x + 1, 0, menu.getTitle(), menuColor);
// Draw the highlight character
@@
-1854,7
+1853,7
@@
public class TApplication implements Runnable {
// Reset the screen clipping so we can draw the next title.
getScreen().resetClipping();
}
// Reset the screen clipping so we can draw the next title.
getScreen().resetClipping();
}
- x +=
menu.getTitle().length(
) + 2;
+ x +=
StringUtils.width(menu.getTitle()
) + 2;
}
for (TMenu menu: subMenus) {
}
for (TMenu menu: subMenus) {
@@
-2729,7
+2728,7
@@
public class TApplication implements Runnable {
for (TMenu menu: menus) {
if ((mouse.getAbsoluteX() >= menu.getTitleX())
&& (mouse.getAbsoluteX() < menu.getTitleX()
for (TMenu menu: menus) {
if ((mouse.getAbsoluteX() >= menu.getTitleX())
&& (mouse.getAbsoluteX() < menu.getTitleX()
- +
menu.getTitle().length(
) + 2)
+ +
StringUtils.width(menu.getTitle()
) + 2)
) {
menu.setActive(true);
activeMenu = menu;
) {
menu.setActive(true);
activeMenu = menu;
@@
-2757,7
+2756,7
@@
public class TApplication implements Runnable {
for (TMenu menu: menus) {
if ((mouse.getAbsoluteX() >= menu.getTitleX())
&& (mouse.getAbsoluteX() < menu.getTitleX()
for (TMenu menu: menus) {
if ((mouse.getAbsoluteX() >= menu.getTitleX())
&& (mouse.getAbsoluteX() < menu.getTitleX()
- +
menu.getTitle().length(
) + 2)
+ +
StringUtils.width(menu.getTitle()
) + 2)
) {
menu.setActive(true);
activeMenu = menu;
) {
menu.setActive(true);
activeMenu = menu;
@@
-3042,7
+3041,7
@@
public class TApplication implements Runnable {
for (TMenu menu: menus) {
menu.setX(x);
menu.setTitleX(x);
for (TMenu menu: menus) {
menu.setX(x);
menu.setTitleX(x);
- x +=
menu.getTitle().length(
) + 2;
+ x +=
StringUtils.width(menu.getTitle()
) + 2;
// Don't let the menu window exceed the screen width
int rightEdge = menu.getX() + menu.getWidth();
// Don't let the menu window exceed the screen width
int rightEdge = menu.getX() + menu.getWidth();
diff --git
a/src/jexer/TCalendar.java
b/src/jexer/TCalendar.java
index b5ecf4df4a3e4e381b7183a50ee0a444c03f6c99..580fb9f1c841d41189801e4b0dd71aa2ee78f624 100644
(file)
--- a/
src/jexer/TCalendar.java
+++ b/
src/jexer/TCalendar.java
@@
-33,6
+33,7
@@
import java.util.GregorianCalendar;
import jexer.bits.CellAttributes;
import jexer.bits.GraphicsChars;
import jexer.bits.CellAttributes;
import jexer.bits.GraphicsChars;
+import jexer.bits.StringUtils;
import jexer.event.TKeypressEvent;
import jexer.event.TMouseEvent;
import static jexer.TKeypress.*;
import jexer.event.TKeypressEvent;
import jexer.event.TMouseEvent;
import static jexer.TKeypress.*;
@@
-238,10
+239,13
@@
public class TCalendar extends TWidget {
// Draw the title
String title = String.format("%tB %tY", displayCalendar,
displayCalendar);
// Draw the title
String title = String.format("%tB %tY", displayCalendar,
displayCalendar);
- int titleLeft = (getWidth() - title.length() - 2) / 2;
+ // This particular title is always single-width (see format string
+ // above), but for completeness let's treat it the same as every
+ // other window title string.
+ int titleLeft = (getWidth() - StringUtils.width(title) - 2) / 2;
putCharXY(titleLeft, 0, ' ', titleColor);
putStringXY(titleLeft + 1, 0, title, titleColor);
putCharXY(titleLeft, 0, ' ', titleColor);
putStringXY(titleLeft + 1, 0, title, titleColor);
- putCharXY(titleLeft +
title.length(
) + 1, 0, ' ',
+ putCharXY(titleLeft +
StringUtils.width(title
) + 1, 0, ' ',
titleColor);
// Arrows
titleColor);
// Arrows
diff --git
a/src/jexer/TDirectoryList.java
b/src/jexer/TDirectoryList.java
index e00d14f696755d5a6756c7a031c0d8eda3cdca25..322ff5c4e5cb493f93cf356716117d2274156d26 100644
(file)
--- a/
src/jexer/TDirectoryList.java
+++ b/
src/jexer/TDirectoryList.java
@@
-34,6
+34,8
@@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.List;
import java.util.Map;
+import jexer.bits.StringUtils;
+
/**
* TDirectoryList shows the files within a directory.
*/
/**
* TDirectoryList shows the files within a directory.
*/
@@
-223,7
+225,7
@@
public class TDirectoryList extends TList {
*/
private String renderFile(final File file) {
String name = file.getName();
*/
private String renderFile(final File file) {
String name = file.getName();
- if (
name.length(
) > 20) {
+ if (
StringUtils.width(name
) > 20) {
name = name.substring(0, 17) + "...";
}
return String.format("%-20s %5dk", name, (file.length() / 1024));
name = name.substring(0, 17) + "...";
}
return String.format("%-20s %5dk", name, (file.length() / 1024));
diff --git
a/src/jexer/TMessageBox.java
b/src/jexer/TMessageBox.java
index c93ad832d06459b925687969327d77d50371a9db..6f1e8a69486b05141b085bda4b841ba474aef347 100644
(file)
--- a/
src/jexer/TMessageBox.java
+++ b/
src/jexer/TMessageBox.java
@@
-32,6
+32,7
@@
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
import java.util.List;
import java.util.ResourceBundle;
+import jexer.bits.StringUtils;
import jexer.event.TKeypressEvent;
import static jexer.TKeypress.*;
import jexer.event.TKeypressEvent;
import static jexer.TKeypress.*;
@@
-187,11
+188,11
@@
public class TMessageBox extends TWindow {
// Determine width and height
String [] lines = caption.split("\n");
// Determine width and height
String [] lines = caption.split("\n");
- int width =
title.length(
) + 12;
+ int width =
StringUtils.width(title
) + 12;
setHeight(6 + lines.length);
for (String line: lines) {
setHeight(6 + lines.length);
for (String line: lines) {
- if (
line.length(
) + 4 > width) {
- width =
line.length(
) + 4;
+ if (
StringUtils.width(line
) + 4 > width) {
+ width =
StringUtils.width(line
) + 4;
}
}
setWidth(width);
}
}
setWidth(width);
diff --git
a/src/jexer/TText.java
b/src/jexer/TText.java
index 60f0e585c9d4faede83c681011a97d8a27a4bbf0..4791fdc5e38e242e707a8ed97d64d618895463d1 100644
(file)
--- a/
src/jexer/TText.java
+++ b/
src/jexer/TText.java
@@
-33,6
+33,7
@@
import java.util.LinkedList;
import java.util.List;
import jexer.bits.CellAttributes;
import java.util.List;
import jexer.bits.CellAttributes;
+import jexer.bits.StringUtils;
import jexer.event.TKeypressEvent;
import jexer.event.TMouseEvent;
import static jexer.TKeypress.kbDown;
import jexer.event.TKeypressEvent;
import jexer.event.TMouseEvent;
import static jexer.TKeypress.kbDown;
@@
-184,7
+185,7
@@
public class TText extends TScrollableWidget {
int topY = 0;
for (int i = begin; i < lines.size(); i++) {
String line = lines.get(i);
int topY = 0;
for (int i = begin; i < lines.size(); i++) {
String line = lines.get(i);
- if (hScroller.getValue() <
line.length(
)) {
+ if (hScroller.getValue() <
StringUtils.width(line
)) {
line = line.substring(hScroller.getValue());
} else {
line = "";
line = line.substring(hScroller.getValue());
} else {
line = "";
@@
-323,7
+324,7
@@
public class TText extends TScrollableWidget {
* @param line new line to add
*/
public void addLine(final String line) {
* @param line new line to add
*/
public void addLine(final String line) {
- if (
text.length(
) == 0) {
+ if (
StringUtils.width(text
) == 0) {
text = line;
} else {
text += "\n\n";
text = line;
} else {
text += "\n\n";
@@
-338,8
+339,8
@@
public class TText extends TScrollableWidget {
private void computeBounds() {
maxLineWidth = 0;
for (String line : lines) {
private void computeBounds() {
maxLineWidth = 0;
for (String line : lines) {
- if (
line.length(
) > maxLineWidth) {
- maxLineWidth =
line.length(
);
+ if (
StringUtils.width(line
) > maxLineWidth) {
+ maxLineWidth =
StringUtils.width(line
);
}
}
}
}
diff --git
a/src/jexer/bits/StringUtils.java
b/src/jexer/bits/StringUtils.java
index d71fd31bf9be15548a68b18886e28a82b07790ad..f5e2d47362a62e9c76bc0f731141a7cf43810d62 100644
(file)
--- a/
src/jexer/bits/StringUtils.java
+++ b/
src/jexer/bits/StringUtils.java
@@
-80,14
+80,14
@@
public class StringUtils {
// We have just transitioned from a word to
// whitespace. See if we have enough space to add
// the word to the line.
// We have just transitioned from a word to
// whitespace. See if we have enough space to add
// the word to the line.
- if (w
ord.length() + line.length(
) > n) {
+ if (w
idth(word.toString()) + width(line.toString()
) > n) {
// This word will exceed the line length. Wrap
// at it instead.
result.add(line.toString());
line = new StringBuilder();
}
if ((word.toString().startsWith(" "))
// This word will exceed the line length. Wrap
// at it instead.
result.add(line.toString());
line = new StringBuilder();
}
if ((word.toString().startsWith(" "))
- && (
line.length(
) == 0)
+ && (
width(line.toString()
) == 0)
) {
line.append(word.substring(1));
} else {
) {
line.append(word.substring(1));
} else {
@@
-112,14
+112,14
@@
public class StringUtils {
}
} // for (int j = 0; j < rawLines[i].length(); j++)
}
} // for (int j = 0; j < rawLines[i].length(); j++)
- if (w
ord.length() + line.length(
) > n) {
+ if (w
idth(word.toString()) + width(line.toString()
) > n) {
// This word will exceed the line length. Wrap at it
// instead.
result.add(line.toString());
line = new StringBuilder();
}
if ((word.toString().startsWith(" "))
// This word will exceed the line length. Wrap at it
// instead.
result.add(line.toString());
line = new StringBuilder();
}
if ((word.toString().startsWith(" "))
- && (
line.length(
) == 0)
+ && (
width(line.toString()
) == 0)
) {
line.append(word.substring(1));
} else {
) {
line.append(word.substring(1));
} else {
@@
-148,7
+148,7
@@
public class StringUtils {
List<String> lines = left(str, n);
for (String line: lines) {
StringBuilder sb = new StringBuilder();
List<String> lines = left(str, n);
for (String line: lines) {
StringBuilder sb = new StringBuilder();
- for (int i = 0; i < n -
line.length(
); i++) {
+ for (int i = 0; i < n -
width(line
); i++) {
sb.append(' ');
}
sb.append(line);
sb.append(' ');
}
sb.append(line);
@@
-175,8
+175,8
@@
public class StringUtils {
List<String> lines = left(str, n);
for (String line: lines) {
StringBuilder sb = new StringBuilder();
List<String> lines = left(str, n);
for (String line: lines) {
StringBuilder sb = new StringBuilder();
- int l = (n -
line.length(
)) / 2;
- int r = n -
line.length(
) - l;
+ int l = (n -
width(line
)) / 2;
+ int r = n -
width(line
) - l;
for (int i = 0; i < l; i++) {
sb.append(' ');
}
for (int i = 0; i < l; i++) {
sb.append(' ');
}
diff --git
a/src/jexer/ttree/TTreeViewWidget.java
b/src/jexer/ttree/TTreeViewWidget.java
index ceb50ab9c38c1a1a14730031b5247f2b38af3b4f..9ffb72461709645a428886f944a63a55213db006 100644
(file)
--- a/
src/jexer/ttree/TTreeViewWidget.java
+++ b/
src/jexer/ttree/TTreeViewWidget.java
@@
-34,6
+34,7
@@
import jexer.TKeypress;
import jexer.TScrollableWidget;
import jexer.TVScroller;
import jexer.TWidget;
import jexer.TScrollableWidget;
import jexer.TVScroller;
import jexer.TWidget;
+import jexer.bits.StringUtils;
import jexer.event.TKeypressEvent;
import jexer.event.TMouseEvent;
import static jexer.TKeypress.*;
import jexer.event.TKeypressEvent;
import jexer.event.TMouseEvent;
import static jexer.TKeypress.*;
@@
-279,7
+280,7
@@
public class TTreeViewWidget extends TScrollableWidget {
selectedRow++;
}
selectedRow++;
}
- int lineWidth =
item.getText().length(
)
+ int lineWidth =
StringUtils.width(item.getText()
)
+ item.getPrefix().length() + 4;
if (lineWidth > maxLineWidth) {
maxLineWidth = lineWidth;
+ item.getPrefix().length() + 4;
if (lineWidth > maxLineWidth) {
maxLineWidth = lineWidth;
diff --git
a/src/jexer/ttree/TTreeViewWindow.java
b/src/jexer/ttree/TTreeViewWindow.java
index e570900051c820e243ef891891bfc40a6a18ef89..f418383ecf43d637c14b81cceedd914b44b54179 100644
(file)
--- a/
src/jexer/ttree/TTreeViewWindow.java
+++ b/
src/jexer/ttree/TTreeViewWindow.java
@@
-34,6
+34,7
@@
import jexer.THScroller;
import jexer.TScrollableWindow;
import jexer.TVScroller;
import jexer.TWidget;
import jexer.TScrollableWindow;
import jexer.TVScroller;
import jexer.TWidget;
+import jexer.bits.StringUtils;
import jexer.event.TKeypressEvent;
import jexer.event.TMouseEvent;
import jexer.event.TResizeEvent;
import jexer.event.TKeypressEvent;
import jexer.event.TMouseEvent;
import jexer.event.TResizeEvent;
@@
-301,7
+302,7
@@
public class TTreeViewWindow extends TScrollableWindow {
selectedRow++;
}
selectedRow++;
}
- int lineWidth =
item.getText().length(
)
+ int lineWidth =
StringUtils.width(item.getText()
)
+ item.getPrefix().length() + 4;
if (lineWidth > maxLineWidth) {
maxLineWidth = lineWidth;
+ item.getPrefix().length() + 4;
if (lineWidth > maxLineWidth) {
maxLineWidth = lineWidth;