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:
ad58496
)
ttable delete up/left
author
Kevin Lamonte
<kevin.lamonte@gmail.com>
Thu, 1 Aug 2019 04:28:36 +0000
(23:28 -0500)
committer
Kevin Lamonte
<kevin.lamonte@gmail.com>
Thu, 1 Aug 2019 04:28:36 +0000
(23:28 -0500)
src/jexer/TTableWidget.java
patch
|
blob
|
blame
|
history
diff --git
a/src/jexer/TTableWidget.java
b/src/jexer/TTableWidget.java
index 548acf641203b90a76f0cce236208074ce92c482..f25f429d52b58bc916dab54329296a12686d9e2c 100644
(file)
--- a/
src/jexer/TTableWidget.java
+++ b/
src/jexer/TTableWidget.java
@@
-801,7
+801,7
@@
public class TTableWidget extends TWidget {
public void onResize(final TResizeEvent event) {
super.onResize(event);
public void onResize(final TResizeEvent event) {
super.onResize(event);
-
alignGrid
();
+
bottomRightCorner
();
}
/**
}
/**
@@
-1276,6
+1276,24
@@
public class TTableWidget extends TWidget {
return rows.size();
}
return rows.size();
}
+
+ /**
+ * Push top and left to the bottom-most right corner of the available
+ * grid.
+ */
+ private void bottomRightCorner() {
+ int viewColumns = getWidth();
+ if (showRowLabels == true) {
+ viewColumns -= ROW_LABEL_WIDTH;
+ }
+
+ // Set left and top such that the table stays on screen if possible.
+ top = rows.size() - getHeight();
+ left = columns.size() - (getWidth() / (viewColumns / (COLUMN_DEFAULT_WIDTH + 1)));
+ // Now ensure the selection is visible.
+ alignGrid();
+ }
+
/**
* Align the grid so that the selected cell is fully visible.
*/
/**
* Align the grid so that the selected cell is fully visible.
*/
@@
-1768,7
+1786,7
@@
public class TTableWidget extends TWidget {
if (selectedRow == rows.size()) {
selectedRow--;
}
if (selectedRow == rows.size()) {
selectedRow--;
}
-
alignGrid
();
+
bottomRightCorner
();
}
/**
}
/**
@@
-1878,21
+1896,29
@@
public class TTableWidget extends TWidget {
if (selectedColumn == columns.size()) {
selectedColumn--;
}
if (selectedColumn == columns.size()) {
selectedColumn--;
}
-
alignGrid
();
+
bottomRightCorner
();
}
/**
* Delete the selected cell, shifting cells over to the left.
*/
public void deleteCellShiftLeft() {
}
/**
* Delete the selected cell, shifting cells over to the left.
*/
public void deleteCellShiftLeft() {
- // TODO
+ // All we do is copy the text from every cell in this row over.
+ for (int i = selectedColumn + 1; i < columns.size(); i++) {
+ setCellText(i - 1, selectedRow, getCellText(i, selectedRow));
+ }
+ setCellText(columns.size() - 1, selectedRow, "");
}
/**
* Delete the selected cell, shifting cells from below up.
*/
public void deleteCellShiftUp() {
}
/**
* Delete the selected cell, shifting cells from below up.
*/
public void deleteCellShiftUp() {
- // TODO
+ // All we do is copy the text from every cell in this column up.
+ for (int i = selectedRow + 1; i < rows.size(); i++) {
+ setCellText(selectedColumn, i - 1, getCellText(selectedColumn, i));
+ }
+ setCellText(selectedColumn, rows.size() - 1, "");
}
/**
}
/**