-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix scrolling issues and keybind issue, debug printouts, change event…
…Handler on kotlin to register automatically
- Loading branch information
Showing
24 changed files
with
182 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
modules/utils/src/main/java/org/polyfrost/oneconfig/utils/v1/TableHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.polyfrost.oneconfig.utils.v1; | ||
|
||
public final class TableHelper { | ||
public static String makeTableFromRows(String message, String[]... rows) { | ||
int[] widths = new int[rows[0].length]; | ||
for (String[] row : rows) { | ||
for (int i = 0; i < row.length; i++) { | ||
widths[i] = Math.max(widths[i], row[i].length()); | ||
} | ||
} | ||
int maxSize = 1; | ||
for (int width : widths) { | ||
maxSize += width + 3; | ||
} | ||
int cap = message.length() + maxSize * (rows.length + 4); | ||
StringBuilder sb = new StringBuilder(cap); | ||
sb.append(message).append('\n'); | ||
|
||
for (int i = 0; i < maxSize; i++) { | ||
sb.append('-'); | ||
} | ||
sb.append('\n'); | ||
boolean first = true; | ||
for (String[] row : rows) { | ||
sb.append("| "); | ||
for (int i = 0; i < row.length; i++) { | ||
sb.append(row[i]); | ||
for (int j = 0; j < widths[i] - row[i].length(); j++) { | ||
sb.append(' '); | ||
} | ||
sb.append(" | "); | ||
} | ||
sb.append('\n'); | ||
if (first) { | ||
for (int i = 0; i < maxSize; i++) { | ||
sb.append('-'); | ||
} | ||
sb.append('\n'); | ||
first = false; | ||
} | ||
} | ||
for (int i = 0; i < maxSize; i++) { | ||
sb.append('-'); | ||
} | ||
|
||
return sb.toString(); | ||
} | ||
|
||
public static String makeTableFromColumns(String message, String[]... columns) { | ||
String[][] rows = new String[columns[0].length][columns.length]; | ||
for (int i = 0; i < columns.length; i++) { | ||
for (int j = 0; j < columns[i].length; j++) { | ||
rows[j][i] = columns[i][j]; | ||
} | ||
} | ||
return makeTableFromRows(message, rows); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.