Codota Logo
TextIO
Code IndexAdd Codota to your IDE (free)

How to use
TextIO
in
org.beryx.textio

Best Java code snippets using org.beryx.textio.TextIO (Showing top 20 results out of 315)

  • Common ways to obtain TextIO
private void myMethod () {
TextIO t =
  • Codota IconTextTerminal textTerminal;new TextIO(textTerminal)
  • Smart code suggestions by Codota
}
origin: beryx/text-io

  public static void main(String[] args) {
    SystemTextTerminal sysTerminal = new SystemTextTerminal();
    TextIO sysTextIO = new TextIO(sysTerminal);

    BiConsumer<TextIO, RunnerData> app = chooseApp(sysTextIO);
    TextIO textIO = chooseTextIO();

    // Uncomment the line below to ignore user interrupts.
//        textIO.getTextTerminal().registerUserInterruptHandler(term -> System.out.println("\n\t### User interrupt ignored."), false);

    if(textIO.getTextTerminal() instanceof WebTextTerminal) {
      WebTextTerminal webTextTerm = (WebTextTerminal)textIO.getTextTerminal();
      TextIoApp<?> textIoApp = createTextIoApp(sysTextIO, app, webTextTerm);
      WebTextIoExecutor webTextIoExecutor = new WebTextIoExecutor();
      configurePort(sysTextIO, webTextIoExecutor, 8080);
      webTextIoExecutor.execute(textIoApp);
    } else {
      app.accept(textIO, null);
    }
  }

origin: beryx/text-io

@Override
public void accept(TextIO textIO, RunnerData runnerData) {
  TextTerminal<?> terminal = textIO.getTextTerminal();
  String initData = (runnerData == null) ? null : runnerData.getInitData();
  AppUtil.printGsonMessage(terminal, initData);
  String user = textIO.newStringInputReader()
      .withDefaultValue("admin")
      .read("Username");
  String password = textIO.newStringInputReader()
      .withMinLength(6)
      .withInputMasking(true)
      .read("Password");
  int age = textIO.newIntInputReader()
      .withMinVal(13)
      .read("Age");
  Month month = textIO.newEnumInputReader(Month.class)
      .read("What month were you born in?");
  terminal.printf("\nUser %s is %d years old, was born in %s and has the password %s.\n", user, age, month, password);
  textIO.newStringInputReader().withMinLength(0).read("\nPress enter to terminate...");
  textIO.dispose("User '" + user + "' has left the building.");
}
origin: mars-sim/mars-sim

@Override
public void accept(TextIO textIO, RunnerData runnerData) {
  terminal = (SwingTextTerminal)textIO.getTextTerminal();
  String initData = (runnerData == null) ? null : runnerData.getInitData();
  AppUtil.printGsonMessage(terminal, initData);
  boolean toSave = textIO.newBooleanInputReader()
      .read("Save now");
  if (toSave) {
    terminal.printf("Saving Simulation..." + System.lineSeparator());
    Simulation.instance().getMasterClock().setSaveSim(Simulation.SAVE_DEFAULT, null); 
  }
  else {
    terminal.printf("You don't want to save the Simulation." + System.lineSeparator());
  }
    
}
origin: mars-sim/mars-sim

public SwingHandler(TextIO textIO, String appName, Object dataObject) {
  this.textIO = textIO;
  this.terminal = (SwingTextTerminal)textIO.getTextTerminal();
  this.historyStore = new History(appName);
  this.dataObject = dataObject;
  this.stringInputReaderSupplier = () -> textIO.newStringInputReader();
  this.intInputReaderSupplier = () -> textIO.newIntInputReader();
  this.longInputReaderSupplier = () -> textIO.newLongInputReader();
  this.doubleInputReaderSupplier = () -> textIO.newDoubleInputReader();
origin: beryx/text-io

@Override
public void accept(TextIO textIO, RunnerData runnerData) {
  TextTerminal<?> terminal = textIO.getTextTerminal();
  String initData = (runnerData == null) ? null : runnerData.getInitData();
  AppUtil.printGsonMessage(terminal, initData);
  textIO.newStringInputReader().withMinLength(0).read("\nPress enter to terminate...");
  textIO.dispose();
origin: beryx/text-io

@Override
public void accept(TextIO textIO, RunnerData runnerData) {
  TextTerminal<?> terminal = textIO.getTextTerminal();
  String initData = (runnerData == null) ? null : runnerData.getInitData();
  AppUtil.printGsonMessage(terminal, initData);
  terminal.executeWithPropertiesPrefix("custom.title", t -> t.print("Cuboid dimensions: "));
  terminal.println();
  double length = textIO.newDoubleInputReader()
      .withMinVal(0.0)
      .withPropertiesPrefix("custom.length")
      .read("Length");
  double width = textIO.newDoubleInputReader()
      .withMinVal(0.0)
      .withPropertiesPrefix("custom.width")
      .read("Width");
  double height = textIO.newDoubleInputReader()
      .withMinVal(0.0)
      .withPropertiesPrefix("custom.height")
      .read("Height");
  terminal.executeWithPropertiesPrefix("custom.title",
      t -> t.print("The volume of your cuboid is: " + length * width * height));
  terminal.println();
  textIO.newStringInputReader()
      .withMinLength(0)
      .withPropertiesPrefix("custom.neutral")
      .read("\nPress enter to terminate...");
  textIO.dispose();
}
origin: mars-sim/mars-sim

public static void main(String[] args) {
  SwingTextTerminal terminal = new SwingTextTerminal();
  terminal.init();
  TextIO textIO = new TextIO(terminal);
  textIO.newStringInputReader().withMinLength(0).read("\nPress enter to terminate...");
  textIO.dispose();
origin: beryx/text-io

protected DataApi create(RatpackDataServer.ContextHolder ctxHolder, String initData) {
  String textTermSessionId = ctxHolder.contextId;
  logger.debug("Creating terminal for textTermSessionId: {}", textTermSessionId);
  WebTextTerminal terminal = termTemplate.createCopy();
  String mapKey = getSessionIdMapKey(textTermSessionId);
  terminal.setOnDispose(() -> {
    if(onDispose != null) {
      onDispose.accept(textTermSessionId);
    }
    Executors.newSingleThreadScheduledExecutor().schedule(() -> webTextTerminalCache.invalidate(mapKey), 5, TimeUnit.SECONDS);
  });
  terminal.setOnAbort(() -> {
    if(onAbort != null) {
      onAbort.accept(textTermSessionId);
    }
    Executors.newSingleThreadScheduledExecutor().schedule(() -> webTextTerminalCache.invalidate(mapKey), 5, TimeUnit.SECONDS);
  });
  webTextTerminalCache.put(mapKey, terminal);
  TextIO textIO = new TextIO(terminal);
  RunnerData runnerData = createRunnerData(initData, ctxHolder);
  Thread thread = new Thread(() -> textIoRunner.accept(textIO, runnerData));
  thread.setDaemon(true);
  thread.start();
  webTextTerminalCache.cleanUp();
  return terminal;
}
origin: beryx/text-io

private static TextIO chooseTextIO() {
  SystemTextTerminal terminal = new SystemTextTerminal();
  TextIO textIO = new TextIO(terminal);
  while(true) {
    TextTerminalProvider terminalProvider = textIO.<TextTerminalProvider>newGenericInputReader(null)
        .withNumberedPossibleValues(
            new NamedProvider("Default terminal (provided by TextIoFactory)", TextIoFactory::getTextTerminal),
    return new TextIO(chosenTerminal);
origin: beryx/text-io

@Override
public void accept(TextIO textIO, RunnerData runnerData) {
  TextTerminal<?> terminal = textIO.getTextTerminal();
  String initData = (runnerData == null) ? null : runnerData.getInitData();
  AppUtil.printGsonMessage(terminal, initData);
    useCelsius = textIO.newBooleanInputReader().withDefaultValue(true).read("Display temperature in Celsius (Press 'N' for Fahrenheit)");
    useKmh = textIO.newBooleanInputReader().withDefaultValue(true).read("Display wind speed in km/h (Press 'N' for mph)");
    useMbar = textIO.newBooleanInputReader().withDefaultValue(true).read("Display atmospheric pressure in mbar (Press 'N' for kPa)");
    terminal.resetToBookmark("MAIN");
    terminal.println();terminal.println();terminal.println();
    if(!textIO.newBooleanInputReader()
        .withPropertiesPrefix("exit")
        .withDefaultValue(true).read("Run again?")) break;
  textIO.dispose();
origin: mars-sim/mars-sim

    + "Would you like to change it?";
boolean change = sim.getTerm().getTextIO().newBooleanInputReader().read(prompt);
      + "Which timestamp do you want to use (1, 2 or 3)?";
  int choice = sim.getTerm().getTextIO().newIntInputReader().read(prompt1);
    + "Would you like to change it?";
boolean change = sim.getTerm().getTextIO().newBooleanInputReader().read(prompt);
origin: beryx/text-io

private void addTask(TextIO textIO, String prompt, Supplier<String> defaultValueSupplier, Consumer<String> valueSetter) {
  operations.add(() -> valueSetter.accept(textIO.newStringInputReader()
      .withDefaultValue(defaultValueSupplier.get())
      .read(prompt)));
}
origin: beryx/text-io

private static void configurePort(TextIO textIO, WebTextIoExecutor webTextIoExecutor, int defaultPort) {
  int port = textIO.newIntInputReader()
      .withDefaultValue(defaultPort)
      .read("Server port number");
  webTextIoExecutor.withPort(port);
}
origin: mars-sim/mars-sim

  private static BiConsumer<TextIO, RunnerData> chooseMenu(TextIO textIO) {
    List<BiConsumer<TextIO, RunnerData>> apps = Arrays.asList(
        chatMenu,
        new AutosaveMenu(),
        new SaveMenu(),
        new TimeRatioMenu(),
//                new Weather(),
        new ExitMenu()
    );
        BiConsumer<TextIO, RunnerData> app = textIO.<BiConsumer<TextIO, RunnerData>>newGenericInputReader(null)
      .withNumberedPossibleValues(apps)
      .read(System.lineSeparator() 
          + "-------------------  C O N S O L E   M E N U  -------------------" 
          + System.lineSeparator());
    String propsFileName = app.getClass().getSimpleName() + ".properties";
    System.setProperty(AbstractTextTerminal.SYSPROP_PROPERTIES_FILE_LOCATION, propsFileName);
//        profile.term().moveToLineStart();        
    return app;
  }
  
origin: mars-sim/mars-sim

@Override
public void accept(TextIO textIO, RunnerData runnerData) {
  terminal = (SwingTextTerminal)textIO.getTextTerminal();
  String initData = (runnerData == null) ? null : runnerData.getInitData();
  AppUtil.printGsonMessage(terminal, initData);
origin: mars-sim/mars-sim

UnitManager.setCommander(true);
boolean like = textIO.newBooleanInputReader().withDefaultValue(true).read("Would you like to us this profile ?");
origin: mars-sim/mars-sim

@Override
public void accept(TextIO textIO, RunnerData runnerData) {
  TextTerminal<?> terminal = textIO.getTextTerminal();
  String initData = (runnerData == null) ? null : runnerData.getInitData();
  AppUtil.printGsonMessage(terminal, initData);
  textIO.newStringInputReader().withMinLength(0).read("\nPress enter to terminate...");
  textIO.dispose();
origin: beryx/text-io

private Holder() {
  TextTerminal<?> t = getTerminalFromProperty();
  if(t == null) {
    t = getTerminalFromService();
  }
  if(t == null) {
    t = getDefaultTerminal();
  }
  t.init();
  this.terminal = t;
  this.textIO = new TextIO(t);
}
origin: mars-sim/mars-sim

private void addTask(TextIO textIO, String prompt, Supplier<String> defaultValueSupplier, Consumer<String> valueSetter) {
  operations.add(() -> valueSetter.accept(textIO.newStringInputReader()
      .withDefaultValue(defaultValueSupplier.get())
      .read(prompt)));
}
origin: mars-sim/mars-sim

private void addCountryTask(TextIO textIO, String prompt, Supplier<Integer> defaultValueSupplier, Consumer<Integer> valueSetter) {
  operations.add(() -> {
    setChoices();
    valueSetter.accept(textIO.newIntInputReader()
      .withDefaultValue(5)
      .withMinVal(1)
      .withMaxVal(28)//defaultValueSupplier.get())
      .read(prompt));
    });
}
org.beryx.textioTextIO

Javadoc

A factory for creating InputReaders. All InputReaders created by the same TextIO instance share the same TextTerminal.

Most used methods

  • <init>
  • dispose
  • getTextTerminal
  • newBooleanInputReader
  • newDoubleInputReader
  • newGenericInputReader
  • newIntInputReader
  • newStringInputReader
  • newEnumInputReader
  • newLongInputReader

Popular in Java

  • Reading from database using SQL prepared statement
  • setScale (BigDecimal)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • getApplicationContext (Context)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • BufferedInputStream (java.io)
    Wraps an existing InputStream and buffers the input. Expensive interaction with the underlying input
  • FileOutputStream (java.io)
    A file output stream is an output stream for writing data to aFile or to a FileDescriptor. Whether
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • LogFactory (org.apache.commons.logging)
    A minimal incarnation of Apache Commons Logging's LogFactory API, providing just the common Log look
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now