box drawing intersections
authorKevin Lamonte <kevin.lamonte@gmail.com>
Tue, 30 Jul 2019 12:48:47 +0000 (07:48 -0500)
committerKevin Lamonte <kevin.lamonte@gmail.com>
Tue, 30 Jul 2019 12:48:47 +0000 (07:48 -0500)
src/jexer/TApplication.java
src/jexer/TTableWidget.java
src/jexer/TTableWindow.java
src/jexer/menu/TMenu.java
src/jexer/menu/TMenu.properties

index 199fa1b66f41ced083466b7975d28233d8f24ff6..927f1f713a37c053ca4e0efbcbb2ed9cbbc8e5bc 100644 (file)
@@ -3127,6 +3127,8 @@ public class TApplication implements Runnable {
             getString("tableSubMenuBorders"));
         borderMenu.addDefaultItem(TMenu.MID_TABLE_BORDER_NONE, false);
         borderMenu.addDefaultItem(TMenu.MID_TABLE_BORDER_ALL, false);
+        borderMenu.addDefaultItem(TMenu.MID_TABLE_BORDER_CELL_NONE, false);
+        borderMenu.addDefaultItem(TMenu.MID_TABLE_BORDER_CELL_ALL, false);
         borderMenu.addDefaultItem(TMenu.MID_TABLE_BORDER_RIGHT, false);
         borderMenu.addDefaultItem(TMenu.MID_TABLE_BORDER_LEFT, false);
         borderMenu.addDefaultItem(TMenu.MID_TABLE_BORDER_TOP, false);
index 2a669dfb0edd2d80c2008283c66273040b22878e..13a37aa5a5d2dc6a9e6cc2de20810e958e38f3b1 100644 (file)
@@ -74,8 +74,7 @@ public class TTableWidget extends TWidget {
         DOUBLE,
 
         /**
-         * Thick bar: \u258C (vertical, left half block) and \u2580
-         * (horizontal, upper block).
+         * Thick bar: \u2503 (vertical heavy) and \u2501 (horizontal heavy).
          */
         THICK,
     }
@@ -793,6 +792,28 @@ public class TTableWidget extends TWidget {
             highlightColumn = getApplication().getMenuItem(menu.getId()).getChecked();
             break;
         case TMenu.MID_TABLE_BORDER_NONE:
+            topBorder = Border.NONE;
+            leftBorder = Border.NONE;
+            for (int i = 0; i < columns.size(); i++) {
+                columns.get(i).rightBorder = Border.NONE;
+            }
+            for (int i = 0; i < rows.size(); i++) {
+                rows.get(i).bottomBorder = Border.NONE;
+                rows.get(i).height = 1;
+            }
+            break;
+        case TMenu.MID_TABLE_BORDER_ALL:
+            topBorder = Border.SINGLE;
+            leftBorder = Border.SINGLE;
+            for (int i = 0; i < columns.size(); i++) {
+                columns.get(i).rightBorder = Border.SINGLE;
+            }
+            for (int i = 0; i < rows.size(); i++) {
+                rows.get(i).bottomBorder = Border.SINGLE;
+                rows.get(i).height = 2;
+            }
+            break;
+        case TMenu.MID_TABLE_BORDER_CELL_NONE:
             if (selectedRow == 0) {
                 topBorder = Border.NONE;
             }
@@ -803,7 +824,7 @@ public class TTableWidget extends TWidget {
             rows.get(selectedRow).bottomBorder = Border.NONE;
             rows.get(selectedRow).height = 1;
             break;
-        case TMenu.MID_TABLE_BORDER_ALL:
+        case TMenu.MID_TABLE_BORDER_CELL_ALL:
             if (selectedRow == 0) {
                 topBorder = Border.SINGLE;
             }
@@ -906,8 +927,7 @@ public class TTableWidget extends TWidget {
                 if (columns.get(i).get(top).isVisible() == false) {
                     break;
                 }
-                putStringXY(columns.get(i).get(top).getX(),
-                    (topBorder == Border.NONE ? 0 : 1),
+                putStringXY(columns.get(i).get(top).getX(), 0,
                     String.format(" %-" +
                         (columns.get(i).width - 2)
                         + "s ", columns.get(i).label),
@@ -929,7 +949,9 @@ public class TTableWidget extends TWidget {
 
         // Draw vertical borders.
         if (leftBorder == Border.SINGLE) {
-            vLineXY((showRowLabels ? ROW_LABEL_WIDTH : 0), 0,
+            vLineXY((showRowLabels ? ROW_LABEL_WIDTH : 0),
+                (topBorder == Border.NONE ? 0 : 1) +
+                    (showColumnLabels ? COLUMN_LABEL_HEIGHT : 0),
                 getHeight(), '\u2502', borderColor);
         }
         for (int i = left; i < columns.size(); i++) {
@@ -938,14 +960,16 @@ public class TTableWidget extends TWidget {
             }
             if (columns.get(i).rightBorder == Border.SINGLE) {
                 vLineXY(columns.get(i).getX() + columns.get(i).width,
-                    (topBorder == Border.NONE ? 0 : 1),
+                    (topBorder == Border.NONE ? 0 : 1) +
+                        (showColumnLabels ? COLUMN_LABEL_HEIGHT : 0),
                     getHeight(), '\u2502', borderColor);
             }
         }
 
         // Draw horizontal borders.
         if (topBorder == Border.SINGLE) {
-            hLineXY((showRowLabels ? ROW_LABEL_WIDTH : 0), 0,
+            hLineXY((showRowLabels ? ROW_LABEL_WIDTH : 0),
+                (showColumnLabels ? COLUMN_LABEL_HEIGHT : 0),
                 getWidth(), '\u2500', borderColor);
         }
         for (int i = top; i < rows.size(); i++) {
@@ -966,16 +990,85 @@ public class TTableWidget extends TWidget {
                 hLineXY((leftBorder == Border.NONE ? 0 : 1) +
                         (showRowLabels ? ROW_LABEL_WIDTH : 0),
                     rows.get(i).getY() + rows.get(i).height - 1,
-                    getWidth(), '\u2580', borderColor);
+                    getWidth(), '\u2501', borderColor);
             }
         }
         // Top-left corner if needed
         if ((topBorder == Border.SINGLE) && (leftBorder == Border.SINGLE)) {
-            putCharXY((showRowLabels ? ROW_LABEL_WIDTH : 0), 0,
+            putCharXY((showRowLabels ? ROW_LABEL_WIDTH : 0),
+                (showColumnLabels ? COLUMN_LABEL_HEIGHT : 0),
                 '\u250c', borderColor);
         }
 
-        // TODO: draw the correct corners between rows and columns
+        // Now draw the correct corners
+        for (int i = top; i < rows.size(); i++) {
+            if (rows.get(i).get(left).isVisible() == false) {
+                break;
+            }
+            for (int j = left; j < columns.size(); j++) {
+                if (columns.get(j).get(i).isVisible() == false) {
+                    break;
+                }
+                if ((i == top) && (topBorder == Border.SINGLE)
+                    && (columns.get(j).rightBorder == Border.SINGLE)
+                ) {
+                    // Top tee
+                    putCharXY(columns.get(j).getX() + columns.get(j).width,
+                        (showColumnLabels ? COLUMN_LABEL_HEIGHT : 0),
+                        '\u252c', borderColor);
+                }
+                if ((j == left) && (leftBorder == Border.SINGLE)
+                    && (rows.get(i).bottomBorder == Border.SINGLE)
+                ) {
+                    // Left tee
+                    putCharXY((showRowLabels ? ROW_LABEL_WIDTH : 0),
+                        rows.get(i).getY() + rows.get(i).height - 1,
+                        '\u251c', borderColor);
+                }
+                if ((columns.get(j).rightBorder == Border.SINGLE)
+                    && (rows.get(i).bottomBorder == Border.SINGLE)
+                ) {
+                    // Intersection of single bars
+                    putCharXY(columns.get(j).getX() + columns.get(j).width,
+                        rows.get(i).getY() + rows.get(i).height - 1,
+                        '\u253c', borderColor);
+                }
+                if ((j == left) && (leftBorder == Border.SINGLE)
+                    && (rows.get(i).bottomBorder == Border.DOUBLE)
+                ) {
+                    // Left tee: single bar vertical, double bar horizontal
+                    putCharXY((showRowLabels ? ROW_LABEL_WIDTH : 0),
+                        rows.get(i).getY() + rows.get(i).height - 1,
+                        '\u255e', borderColor);
+                }
+                if ((j == left) && (leftBorder == Border.SINGLE)
+                    && (rows.get(i).bottomBorder == Border.THICK)
+                ) {
+                    // Left tee: single bar vertical, thick bar horizontal
+                    putCharXY((showRowLabels ? ROW_LABEL_WIDTH : 0),
+                        rows.get(i).getY() + rows.get(i).height - 1,
+                        '\u251d', borderColor);
+                }
+                if ((columns.get(j).rightBorder == Border.SINGLE)
+                    && (rows.get(i).bottomBorder == Border.DOUBLE)
+                ) {
+                    // Intersection: single bar vertical, double bar
+                    // horizontal
+                    putCharXY(columns.get(j).getX() + columns.get(j).width,
+                        rows.get(i).getY() + rows.get(i).height - 1,
+                        '\u256a', borderColor);
+                }
+                if ((columns.get(j).rightBorder == Border.SINGLE)
+                    && (rows.get(i).bottomBorder == Border.THICK)
+                ) {
+                    // Intersection: single bar vertical, thick bar
+                    // horizontal
+                    putCharXY(columns.get(j).getX() + columns.get(j).width,
+                        rows.get(i).getY() + rows.get(i).height - 1,
+                        '\u253f', borderColor);
+                }
+            }
+        }
 
         // Now draw the window borders.
         super.draw();
index 47a5b9ec37368537e11c89afabb414c28f68a4bb..ad96543dbfe7e5750018bdbc2c6631403c10a3ee 100644 (file)
@@ -96,6 +96,8 @@ public class TTableWindow extends TScrollableWindow {
         getApplication().enableMenuItem(TMenu.MID_TABLE_VIEW_HIGHLIGHT_COLUMN);
         getApplication().enableMenuItem(TMenu.MID_TABLE_BORDER_NONE);
         getApplication().enableMenuItem(TMenu.MID_TABLE_BORDER_ALL);
+        getApplication().enableMenuItem(TMenu.MID_TABLE_BORDER_CELL_NONE);
+        getApplication().enableMenuItem(TMenu.MID_TABLE_BORDER_CELL_ALL);
         getApplication().enableMenuItem(TMenu.MID_TABLE_BORDER_RIGHT);
         getApplication().enableMenuItem(TMenu.MID_TABLE_BORDER_LEFT);
         getApplication().enableMenuItem(TMenu.MID_TABLE_BORDER_TOP);
@@ -129,6 +131,8 @@ public class TTableWindow extends TScrollableWindow {
         getApplication().disableMenuItem(TMenu.MID_TABLE_VIEW_HIGHLIGHT_COLUMN);
         getApplication().disableMenuItem(TMenu.MID_TABLE_BORDER_NONE);
         getApplication().disableMenuItem(TMenu.MID_TABLE_BORDER_ALL);
+        getApplication().disableMenuItem(TMenu.MID_TABLE_BORDER_CELL_NONE);
+        getApplication().disableMenuItem(TMenu.MID_TABLE_BORDER_CELL_ALL);
         getApplication().disableMenuItem(TMenu.MID_TABLE_BORDER_RIGHT);
         getApplication().disableMenuItem(TMenu.MID_TABLE_BORDER_LEFT);
         getApplication().disableMenuItem(TMenu.MID_TABLE_BORDER_TOP);
index 142045699e9601963c2d3356beaaf6a6c9898bff..8a8ec6be752d1443e60969baa5505671a567279f 100644 (file)
@@ -102,30 +102,34 @@ public class TMenu extends TWindow {
     public static final int MID_ABOUT                   = 56;
 
     // Table menu
-    public static final int MID_TABLE_VIEW_ROW_LABELS           = 60;
-    public static final int MID_TABLE_VIEW_COLUMN_LABELS        = 61;
-    public static final int MID_TABLE_VIEW_HIGHLIGHT_ROW        = 62;
-    public static final int MID_TABLE_VIEW_HIGHLIGHT_COLUMN     = 63;
-    public static final int MID_TABLE_BORDER_NONE               = 64;
-    public static final int MID_TABLE_BORDER_ALL                = 65;
-    public static final int MID_TABLE_BORDER_RIGHT              = 66;
-    public static final int MID_TABLE_BORDER_LEFT               = 67;
-    public static final int MID_TABLE_BORDER_TOP                = 68;
-    public static final int MID_TABLE_BORDER_BOTTOM             = 69;
-    public static final int MID_TABLE_BORDER_DOUBLE_BOTTOM      = 70;
-    public static final int MID_TABLE_BORDER_THICK_BOTTOM       = 71;
-    public static final int MID_TABLE_DELETE_LEFT               = 72;
-    public static final int MID_TABLE_DELETE_UP                 = 73;
-    public static final int MID_TABLE_DELETE_ROW                = 74;
-    public static final int MID_TABLE_DELETE_COLUMN             = 75;
-    public static final int MID_TABLE_INSERT_LEFT               = 76;
-    public static final int MID_TABLE_INSERT_RIGHT              = 77;
-    public static final int MID_TABLE_INSERT_ABOVE              = 78;
-    public static final int MID_TABLE_INSERT_BELOW              = 79;
-    public static final int MID_TABLE_COLUMN_NARROW             = 80;
-    public static final int MID_TABLE_COLUMN_WIDEN              = 81;
-    public static final int MID_TABLE_FILE_SAVE_CSV             = 82;
-    public static final int MID_TABLE_FILE_SAVE_TEXT            = 83;
+    public static final int MID_TABLE_RENAME_ROW                = 60;
+    public static final int MID_TABLE_RENAME_COLUMN             = 61;
+    public static final int MID_TABLE_VIEW_ROW_LABELS           = 70;
+    public static final int MID_TABLE_VIEW_COLUMN_LABELS        = 71;
+    public static final int MID_TABLE_VIEW_HIGHLIGHT_ROW        = 72;
+    public static final int MID_TABLE_VIEW_HIGHLIGHT_COLUMN     = 73;
+    public static final int MID_TABLE_BORDER_NONE               = 80;
+    public static final int MID_TABLE_BORDER_ALL                = 81;
+    public static final int MID_TABLE_BORDER_CELL_NONE          = 82;
+    public static final int MID_TABLE_BORDER_CELL_ALL           = 83;
+    public static final int MID_TABLE_BORDER_RIGHT              = 84;
+    public static final int MID_TABLE_BORDER_LEFT               = 85;
+    public static final int MID_TABLE_BORDER_TOP                = 86;
+    public static final int MID_TABLE_BORDER_BOTTOM             = 87;
+    public static final int MID_TABLE_BORDER_DOUBLE_BOTTOM      = 88;
+    public static final int MID_TABLE_BORDER_THICK_BOTTOM       = 89;
+    public static final int MID_TABLE_DELETE_LEFT               = 100;
+    public static final int MID_TABLE_DELETE_UP                 = 101;
+    public static final int MID_TABLE_DELETE_ROW                = 102;
+    public static final int MID_TABLE_DELETE_COLUMN             = 103;
+    public static final int MID_TABLE_INSERT_LEFT               = 104;
+    public static final int MID_TABLE_INSERT_RIGHT              = 105;
+    public static final int MID_TABLE_INSERT_ABOVE              = 106;
+    public static final int MID_TABLE_INSERT_BELOW              = 107;
+    public static final int MID_TABLE_COLUMN_NARROW             = 110;
+    public static final int MID_TABLE_COLUMN_WIDEN              = 111;
+    public static final int MID_TABLE_FILE_SAVE_CSV             = 115;
+    public static final int MID_TABLE_FILE_SAVE_TEXT            = 116;
 
     // ------------------------------------------------------------------------
     // Variables --------------------------------------------------------------
@@ -682,6 +686,12 @@ public class TMenu extends TWindow {
         case MID_TABLE_BORDER_ALL:
             label = i18n.getString("menuTableBorderAll");
             break;
+        case MID_TABLE_BORDER_CELL_NONE:
+            label = i18n.getString("menuTableBorderCellNone");
+            break;
+        case MID_TABLE_BORDER_CELL_ALL:
+            label = i18n.getString("menuTableBorderCellAll");
+            break;
         case MID_TABLE_BORDER_RIGHT:
             label = i18n.getString("menuTableBorderRight");
             break;
index 327415756bf2bf7b68a00bd8f7c87513e17d4935..4471d6340b9151fbd403a7865d1140a52ed2de71 100644 (file)
@@ -30,14 +30,16 @@ menuTableViewRowLabels=&Row Labels
 menuTableViewColumnLabels=&Column Labels
 menuTableViewHighlightRow=Highlight Selected R&ow
 menuTableViewHighlightColumn=Highlight Selected Co&lumn
-menuTableBorderNone=&None
-menuTableBorderAll=&All
+menuTableBorderNone=N&one (Entire Table)
+menuTableBorderAll=&All (Entire Table)
+menuTableBorderCellNone=&None (Selected Cell)
+menuTableBorderCellAll=All (&Selected Cell)
 menuTableBorderRight=&Right
 menuTableBorderLeft=&Left
 menuTableBorderTop=&Top
 menuTableBorderBottom=&Bottom
-menuTableBorderDoubleBottom=Bottom (&double)
-menuTableBorderThickBottom=Bottom (t&hick)
+menuTableBorderDoubleBottom=Bottom (&Double)
+menuTableBorderThickBottom=Bottom (T&hick)
 menuTableDeleteLeft=Cell (Shift &Left)
 menuTableDeleteUp=Cell (Shift &Up)
 menuTableDeleteRow=Entire &Row