Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import reactor.core.publisher.Flux;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.shell.jline.tui.component.TerminalEvent;
import org.springframework.shell.jline.tui.component.view.TerminalUI;
import org.springframework.shell.jline.tui.component.view.event.EventLoop;

Expand All @@ -34,7 +34,7 @@ void events() {
// tag::plainevents[]
TerminalUI ui = new TerminalUI(terminal);
EventLoop eventLoop = ui.getEventLoop();
Flux<? extends Message<?>> events = eventLoop.events();
Flux<? extends TerminalEvent<?>> events = eventLoop.events();
events.subscribe();
// end::plainevents[]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.jline.terminal.Terminal;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.shell.jline.tui.component.message.ShellMessageBuilder;
import org.springframework.shell.jline.tui.component.TerminalEvent;
import org.springframework.shell.jline.tui.component.view.TerminalUI;
import org.springframework.shell.jline.tui.component.view.TerminalUIBuilder;
import org.springframework.shell.jline.tui.component.view.control.BoxView;
Expand Down Expand Up @@ -65,7 +65,8 @@ void sample() {
EventLoop eventLoop = ui.getEventLoop();
eventLoop.keyEvents().subscribe(event -> {
if (event.getPlainKey() == Key.q && event.hasCtrl()) {
eventLoop.dispatch(ShellMessageBuilder.ofInterrupt());
TerminalEvent<String> terminalEvent = new TerminalEvent<>("int", EventLoop.Type.SYSTEM);
eventLoop.dispatch(terminalEvent);
}
});
ui.run();
Expand Down
5 changes: 0 additions & 5 deletions spring-shell-jline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@
<artifactId>ST4</artifactId>
<version>${antlr-st4.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
<version>${spring-framework.version}</version>
</dependency>

<!-- Test dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.springframework.shell.jline.tui.component;

import java.util.Map;

import org.jspecify.annotations.Nullable;

import org.springframework.shell.jline.tui.component.view.control.View;
import org.springframework.shell.jline.tui.component.view.event.EventLoop;

/**
* @author Piotr Olaszewski
*/
public record TerminalEvent<T>(T payload, EventLoop.Type type, @Nullable View view,
@Nullable Map<String, Object> attributes) {
public TerminalEvent(T payload, EventLoop.Type type) {
this(payload, type, null, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.shell.jline.tui.component.message.ShellMessageBuilder;
import org.springframework.shell.jline.tui.component.view.TerminalUI;
import org.springframework.shell.jline.tui.component.view.control.View;
import org.springframework.shell.jline.tui.component.view.control.ViewDoneEvent;
Expand All @@ -32,6 +31,7 @@
* Handles view execution in a non-fullscreen setup.
*
* @author Janne Valkealahti
* @author Piotr Olaszewski
*/
public class ViewComponent {

Expand Down Expand Up @@ -118,7 +118,8 @@ public EventLoop getEventLoop() {
* Request exit from an execution loop.
*/
public void exit() {
eventLoop.dispatch(ShellMessageBuilder.ofInterrupt());
TerminalEvent<String> terminalEvent = new TerminalEvent<>("int", EventLoop.Type.SYSTEM);
eventLoop.dispatch(terminalEvent);
}

/**
Expand Down

This file was deleted.

This file was deleted.

Loading