Skip to content

Commit

Permalink
Fix formatting in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
yisiox committed Feb 18, 2024
1 parent 6adb358 commit 64f4b9f
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/main/java/earl/gui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void handleExit() {
*/
private void displayDialog(String input, String response) {
dialogContainer.getChildren().addAll(
DialogBox.getUserDialog(input + " ".repeat(4), userImage),
DialogBox.getUserDialog(input, userImage),
DialogBox.getEarlDialog(response, earlImage));
userInput.clear();
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/earl/logic/DeleteHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public void handle(TaskList tasks, Ui ui) throws EarlException {

ui.makeResponse(getDisplayEntriesReversed());
} catch (ParserException e) {
throw new EarlException(
"The indices' format is fraught with invalidity."
+ " Example format: 1 4-7 9-10");
throw new EarlException(ui.appendNewline(
"The indices' format is fraught with invalidity.")
+ ui.leftPad("Example format: 1 4-7 9-10"));
} catch (Exception e) {
throw new EarlException("Command hath faltered: "
+ "obscure employment of delete.");
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/earl/logic/MarkHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public void handle(TaskList tasks, Ui ui) throws EarlException {

ui.makeResponse(getDisplayEntriesReversed());
} catch (ParserException e) {
throw new EarlException(
"The indices' format is fraught with invalidity."
+ " Example format: 1 4-7 9-10");
throw new EarlException(ui.appendNewline(
"The indices' format is fraught with invalidity.")
+ ui.leftPad("Example format: 1 4-7 9-10"));
} catch (Exception e) {
throw new EarlException("Command hath faltered: "
+ "obscure employment of mark.");
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/earl/logic/UnmarkHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public void handle(TaskList tasks, Ui ui) throws EarlException {

ui.makeResponse(getDisplayEntriesReversed());
} catch (ParserException e) {
throw new EarlException(
"The indices' format is fraught with invalidity."
+ " Example format: 1 4-7 9-10");
throw new EarlException(ui.appendNewline(
"The indices' format is fraught with invalidity.")
+ ui.leftPad("Example format: 1 4-7 9-10"));
} catch (Exception e) {
throw new EarlException("Command hath faltered: "
+ "obscure employment of unmark.");
+ "obscure employment of unmark.");
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/earl/util/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public String getResponse() {
assert n > 0;
StringBuilder res = new StringBuilder();
for (int i = 0; i < n - 1; ++i) {
res.append(PADDING).append(response[i]).append(NEWLINE);
res.append(response[i]).append(NEWLINE);
}
res.append(PADDING).append(response[n - 1]); // last line has no newline
res.append(response[n - 1]); // last line has no newline
return res.toString();
}
}
2 changes: 2 additions & 0 deletions src/main/resources/stylesheets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
.label {
-fx-font-family: 'Fira Code Bold';
-fx-font-size: 12;
-fx-padding: 0px 16px 0px 16px;
}

.user-dialog-box {
Expand All @@ -26,4 +27,5 @@
.earl-dialog-box .label {
-fx-font-family: 'Victor Mono Bold Oblique';
-fx-font-size: 12;
-fx-padding: 0px 10px 0px 10px;
}
6 changes: 4 additions & 2 deletions src/test/java/earl/logic/DeleteHandlerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
class DeleteHandlerTest {

private static final PrintStream originalOut = System.out;

private static final ByteArrayOutputStream testingOut =
new ByteArrayOutputStream();
private static final String NEWLINE = System.lineSeparator();
private static final String PADDING = " ".repeat(4);

@BeforeEach
void setUp() {
Expand All @@ -42,7 +43,8 @@ void handle_nonIntegerInput_exceptionThrown() {
fail();
} catch (Exception e) {
assertEquals("The indices' format is fraught with invalidity."
+ " Example format: 1 4-7 9-10", e.getMessage());
+ NEWLINE
+ PADDING + "Example format: 1 4-7 9-10", e.getMessage());
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/test/java/earl/logic/MarkHandlerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class MarkHandlerTest {
private static final PrintStream originalOut = System.out;
private static final ByteArrayOutputStream testingOut =
new ByteArrayOutputStream();
private static final String NEWLINE = System.lineSeparator();
private static final String PADDING = " ".repeat(4);

@BeforeEach
void setUp() {
Expand All @@ -42,7 +44,8 @@ void handle_nonIntegerInput_exceptionThrown() {
fail();
} catch (Exception e) {
assertEquals("The indices' format is fraught with invalidity."
+ " Example format: 1 4-7 9-10", e.getMessage());
+ NEWLINE
+ PADDING + "Example format: 1 4-7 9-10", e.getMessage());
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/test/java/earl/util/UiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ void setUp() {
void getResponse_singleLine_success() {
Ui ui = new Ui();
ui.makeResponse("A");
String expected = PADDING + "A";
assertEquals(expected, ui.getResponse());
assertEquals("A", ui.getResponse());
}

@Test
Expand Down

0 comments on commit 64f4b9f

Please sign in to comment.