Package org.crsh.text

Examples of org.crsh.text.ScreenBuffer


  CRaSHProcessContext(CRaSHSession session, final ShellProcessContext processContext) {

    // We use this chunk buffer to buffer stuff
    // but also because it optimises the chunks
    // which provides better perormances on the client
    final ScreenBuffer buffer = new ScreenBuffer(processContext);

    //
    final ScreenContextConsumer adapter = new ScreenContextConsumer(new ScreenContext() {
      public int getWidth() {
        return processContext.getWidth();
      }

      public int getHeight() {
        return processContext.getHeight();
      }

      @Override
      public Screenable append(CharSequence s) throws IOException {
        buffer.append(s);
        return this;
      }

      @Override
      public Appendable append(char c) throws IOException {
        buffer.append(c);
        return this;
      }

      @Override
      public Screenable append(CharSequence csq, int start, int end) throws IOException {
        buffer.append(csq, start, end);
        return this;
      }

      @Override
      public Screenable append(Style style) throws IOException {
        buffer.append(style);
        return this;
      }

      @Override
      public Screenable cls() throws IOException {
        buffer.cls();
        return this;
      }

      public void flush() throws IOException {
        buffer.flush();
      }
    });

    //
    this.session = session;
View Full Code Here


    throw new UnsupportedOperationException();
  }

  public Screenable append(CharSequence s) throws IOException {
    if (reader == null) {
      reader = new ScreenBuffer();
    }
    reader.append(s);
    return this;
  }
View Full Code Here

    return this;
  }

  public Screenable append(char c) throws IOException {
    if (reader == null) {
      reader = new ScreenBuffer();
    }
    reader.append(c);
    return this;
  }
View Full Code Here

    return this;
  }

  public Screenable append(CharSequence csq, int start, int end) throws IOException {
    if (reader == null) {
      reader = new ScreenBuffer();
    }
    reader.append(csq, start, end);
    return this;
  }
View Full Code Here

    return this;
  }

  public Screenable append(Style style) throws IOException {
    if (reader == null) {
      reader = new ScreenBuffer();
    }
    reader.append(style);
    return this;
  }
View Full Code Here

    return this;
  }

  public Screenable cls() throws IOException {
    if (reader == null) {
      reader = new ScreenBuffer();
    }
    reader.cls();
    return this;
  }
View Full Code Here

  }

  public void provide(Object element) throws IOException {
    if (element instanceof Style || element instanceof CLS) {
      if (reader == null) {
        reader = new ScreenBuffer();
      }
      reader.append(element);
    } else {
      if (producedItems.isEmpty()) {
        producedItems = new LinkedList<Object>();
View Full Code Here

  public void testAdaptToChunk() {
    lifeCycle.bindClass("producer", Commands.ProduceValue.class);
    lifeCycle.bindClass("consumer", Commands.ConsumeChunk.class);
    Commands.list.clear();
    assertOk("producer | consumer");
    ScreenBuffer buffer = new ScreenBuffer().append(Commands.list);
    assertEquals("<value>abc</value>             \n", buffer.toString());
  }
View Full Code Here

public abstract class AbstractRendererTestCase extends AbstractTestCase {

  public List<String> render(final LineReader renderer, final int width) {
    ArrayList<String> result = new ArrayList<String>();
    while (renderer.hasLine()) {
      final ScreenBuffer buffer = new ScreenBuffer();
      renderer.renderLine(new RenderAppendable(new ScreenContext() {
        public int getWidth() {
          return width;
        }
        public int getHeight() {
          return 40;
        }
        public Screenable append(CharSequence s) throws IOException {
          buffer.append(s);
          return this;
        }
        public Appendable append(char c) throws IOException {
          buffer.append(c);
          return this;
        }
        public Appendable append(CharSequence csq, int start, int end) throws IOException {
          buffer.append(csq, start, end);
          return this;
        }
        public Screenable append(Style style) throws IOException {
          buffer.append(style);
          return this;
        }
        public Screenable cls() throws IOException {
          buffer.cls();
          return this;
        }
        public void flush() throws IOException {
          buffer.flush();
        }
      }));
      StringBuilder sb = new StringBuilder();
      try {
        buffer.format(Format.ANSI, sb);
      }
      catch (IOException e) {
        throw failure(e);
      }
      result.add(sb.toString());
View Full Code Here

TOP

Related Classes of org.crsh.text.ScreenBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.