unless the user uses a very ancient or trivial terminal emulator, it will work. ssh doesn't even know - it just passes the data through transparently. It all depends on the actual terminal(emulator).
if ssh goes over a slow/laggy network, then other parts of lanterna might fail, though.
one more note: if you click inside the terminal drag outside and release there, you might get to see quite absurd pairs of coordinates, so don't assume it to be always sane.
if that happens, do you get a shell prompt? if so, then blindly type "stty sane".
lanterna shouldn't ever crash this way. Maybe you use an older version? If not, then we'd like a reproducible test case to see if we can fix it.
I am using the latest version, when the problem occurs if i type stty sane two times i can see the command i am typing but i can also see the mouse coordinates appearing when i use the mouse(i suppose the code of setting the mousecapturemode to null is not executed , but when for example i press enter on the exit button where it sets the mousecapturemode to null i still get the same problem but i need to type stty sane only once in this case) . How can i provide a test case? Do i need to put the code here?
Thanks.
Rajatt
if you could create a single class that does it all in its main method, then sharing that code here would be fine. So far I've only used TerminalInputTest, and that doesn't open windows, so I can't check this specific exiting behaviour.
in those cases where you needed stty sane twice, there probably were still some remainders of the mouse-sequences in the buffer. typing ctrl-u combo before stty sane would reset the input line.
import java.io.IOException;
import com.googlecode.lanterna.TerminalSize;
import com.googlecode.lanterna.gui2.BasicWindow;
import com.googlecode.lanterna.gui2.Button;
import com.googlecode.lanterna.gui2.Direction;
import com.googlecode.lanterna.gui2.LinearLayout;
import com.googlecode.lanterna.gui2.MultiWindowTextGUI;
import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.TextBox;
import com.googlecode.lanterna.gui2.Window;
import com.googlecode.lanterna.screen.Screen;
import com.googlecode.lanterna.screen.TerminalScreen;
import com.googlecode.lanterna.terminal.DefaultTerminalFactory;
import com.googlecode.lanterna.terminal.ExtendedTerminal;
import com.googlecode.lanterna.terminal.MouseCaptureMode;
/**
* testing mouse, application closes when click is performed in empty space of a window or on the screen
* (mouse reporting remains enabled and in the terminal mouse reporting is still visible).
* @author rajatt
*
*/
public class lanternagroup {
public static void main(String[] args) throws IOException, InterruptedException {
//is it better to create a terminal and calling the setMouseCaptureMode on the default factory and
//then setting it to null by casting terminal to EXtendedTerminal or same as I have done?
ExtendedTerminal ter = (ExtendedTerminal) new DefaultTerminalFactory().setForceTextTerminal(true).createTerminal();
ter.setMouseCaptureMode(MouseCaptureMode.CLICK);
final Screen screen = new TerminalScreen(ter);
screen.startScreen();
screen.clear();
MultiWindowTextGUI gui = new MultiWindowTextGUI(screen);
Panel menubar = new Panel();
menubar.setLayoutManager(new LinearLayout(Direction.HORIZONTAL).setSpacing(1));
TextBox text = new TextBox(new TerminalSize(10,10),TextBox.Style.MULTI_LINE);
menubar.addComponent(text);
menubar.addComponent(new Button("Open", new Runnable(){
@Override
public void run() {
Window op = new BasicWindow("Select file");
gui.addWindow(op);
op.setComponent(new Button("Close", new Runnable(){
@Override
public void run() {
op.close();
}
}));
}
}));
menubar.addComponent(new Button("Save"));
menubar.addComponent(new Button("Exit", new Runnable(){
public void run(){
try {
gui.getActiveWindow().close();
screen.stopScreen();
ter.setMouseCaptureMode(null);
} catch (IOException e) {
System.out.println("Error exit");
}
}
}));
Window main = new BasicWindow("Test");
main.setComponent(menubar);
gui.addWindowAndWait(main);
screen.stopScreen();
ter.setMouseCaptureMode(null);
}
}
Well spotted. Apparently, this path wasn't tested much, so far.
I'll add some push-requests on github to fix it, but I don't have any powers on the project, so we will have to wait for Martin to actually accept them.
PS: the reason why mouse mode isn't reset on crash is that you don't yet have the addWindowAndWait call inside a try-block, and the cleanup (stopScreen & setMouseCaptureMode) in its finally-block.
Martin has merged the fix, so you could get the sources from github, and hopefully see no more nullpointerexceptions.
--
Det här meddelandet skickas till dig eftersom du prenumererar på ett ämne i gruppen "lanterna-discuss" i Google Grupper.
Sluta prenumerera på det här ämnet genom att besöka https://groups.google.com/d/topic/lanterna-discuss/rrFrIqHUPDU/unsubscribe.
Om du vill sluta prenumerera på den här gruppen och på alla ämnen i den skickar du ett e-postmeddelande till lanterna-discuss+unsubscribe@googlegroups.com.
Fler alternativ finns på https://groups.google.com/d/optout.
An addition that I am doing is that there will be a command line as part of the editor where the user can input some commands to apply to the text, for example capitalise all the text, move the cursor to the end of the line and add a line and so on).
--
Ok , I will ask my teacher, but probabily the important thingh I will do is add the key to command bindings, undo redo functionality and a little language that can be applied to the text (in the TextBox :-) ) .Rajatt
--
Thaks, what I would like to achieve is dynamic binding for a particular component, do you think adding a hastable with keys and runnable events in handlekeystroke will help in achieving this? For example put a hastable inside textbox class and when a user press the button to bind a key, then this key is added to the hash table along with the runnable, so then in handlekeystroke it can check if there is a matching so it runs the runnable otherwise handle normally.
Is there a way to suppress ctrl c? As this closes the lanterna application?
Thanks for your reply and explanation.
Rajatt
--
Thanks,
I will download the new sources so i can have access to latest sources. :-)
Rajatt
Rajatt
--
--Det här meddelandet skickas till dig eftersom du prenumererar på gruppen "lanterna-discuss" i Google Grupper.
Om du vill sluta prenumerera på den här gruppen och inte längre få någon e-post från den skickar du ett e-postmeddelande till lanterna-discuss+unsubscribe@googlegroups.com.