Examples of TerminalSize


Examples of org.jboss.aesh.terminal.TerminalSize

   @Override
   public Result execute(UIExecutionContext context) throws Exception
   {
      UIContext uiContext = context.getUIContext();
      Shell shell = (Shell) uiContext.getProvider();
      TerminalSize terminalSize = shell.getConsole().getShell().getSize();
      List<String> display = new ArrayList<>();

      Iterable<UICommand> commands = commandFactory.getCommands();
      for (UICommand command : commands)
      {
         UICommandMetadata metadata = command.getMetadata(uiContext);
         String name = commandFactory.getCommandName(uiContext, command);
         boolean enabled = command.isEnabled(uiContext);
         display.add(metadata.getCategory()
                  + " > "
                  + new TerminalString(name, new TerminalColor(enabled ? Color.CYAN : Color.RED,
                           Color.DEFAULT)).toString() + " - " + metadata.getDescription());
      }
      UIOutput output = uiContext.getProvider().getOutput();
      PrintStream out = output.out();
      out.println(Parser.formatDisplayList(display.toArray(new String[display.size()]),
               terminalSize.getHeight(), terminalSize.getWidth()));

      return Results.success();
   }
View Full Code Here

Examples of org.jboss.aesh.terminal.TerminalSize

        shell.out().print('x');
    }


    private void drawHorizontalLine(int x, int y, int width) {
        TerminalSize terminalSize = graphicsConfiguration.getBounds();
        if(terminalSize.getHeight() > y && terminalSize.getWidth() > y) {
            if(terminalSize.getWidth() < x + width)
                width = terminalSize.getWidth() - x-1;
            shell.setCursor(new CursorPosition(y,x));
            char[] line = new char[width];
            for(int i=0; i < line.length; i++) {
                if(i == 0 || i == line.length-1)
                    line[i] = 'x';
View Full Code Here

Examples of org.jboss.aesh.terminal.TerminalSize

            shell.out().print(line);
        }
    }

    private void drawVerticalLine(int x, int y, int length) {
        TerminalSize terminalSize = graphicsConfiguration.getBounds();
        if(terminalSize.getHeight() > y && terminalSize.getWidth() > y) {
            if(terminalSize.getHeight() < y + length)
                length = terminalSize.getHeight() - y-1;
            shell.setCursor(new CursorPosition(y,x));
            for(int i=0; i < length; i++) {
                shell.out().print('|');
                shell.out().print(CURSOR_DOWN);
            }
View Full Code Here

Examples of org.jboss.aesh.terminal.TerminalSize

      return result;
   }

   private String listMany(Iterable<Resource<?>> files, ShellContext context)
   {
      TerminalSize terminalSize = context.getProvider().getConsole().getShell().getSize();
      List<String> display = new ArrayList<String>();
      boolean showAll = all.getValue();
      if (files != null)
      {
         for (Resource<?> file : files)
         {
            String name;
            if (file instanceof FileResource)
            {
               FileResource<?> fileResource = (FileResource<?>) file;
               if (!showAll && fileResource.getName().startsWith("."))
               {
                  continue;
               }
               name = ShellUtil.colorizeResource(fileResource);
            }
            else
            {
               name = file.getName();
            }
            display.add(name);
         }
      }
      return Parser.formatDisplayList(display, terminalSize.getHeight(), terminalSize.getWidth());
   }
View Full Code Here

Examples of org.jboss.aesh.terminal.TerminalSize

      if (resources == null)
      {
         return "";
      }

      TerminalSize terminalSize = shell.getConsole().getShell().getSize();

      List<FileResource> fileResources = new ArrayList<>();
      List<JavaFieldResource> fieldResources = new ArrayList<>();
      List<JavaMethodResource> methodResources = new ArrayList<>();
      List<Resource> otherResources = new ArrayList<>();

      for (Resource<?> resource : resources)
      {
         if (resource instanceof FileResource)
         {
            fileResources.add((FileResource) resource);
         }
         else if (resource instanceof JavaFieldResource)
         {
            fieldResources.add((JavaFieldResource) resource);
         }
         else if (resource instanceof JavaMethodResource)
         {
            methodResources.add((JavaMethodResource) resource);
         }
         else
         {
            otherResources.add(resource);
         }
      }

      StringBuilder sb = new StringBuilder();

      if (fileResources.size() > 0)
      {
         sb.append(getFileFormattedList(fileResources, terminalSize.getHeight(), terminalSize.getWidth()));
      }

      if (fieldResources.size() > 0)
      {
         sb.append(Config.getLineSeparator());
         sb.append(ShellUtil.colorizeLabel("[fields]"));
         sb.append(Config.getLineSeparator());
         sb.append(getJavaFieldFormattedList(fieldResources, terminalSize.getHeight(), terminalSize.getWidth()));
      }

      if (methodResources.size() > 0)
      {
         sb.append(Config.getLineSeparator());
         sb.append(ShellUtil.colorizeLabel("[methods]"));
         sb.append(Config.getLineSeparator());
         sb.append(getJavaMethodFormattedList(methodResources, terminalSize.getHeight(), terminalSize.getWidth()));
      }

      if (otherResources.size() > 0)
      {
         sb.append(getFormattedList(otherResources, terminalSize.getHeight(), terminalSize.getWidth()));
      }

      return sb.toString();
   }
View Full Code Here

Examples of org.jboss.aesh.terminal.TerminalSize

                  PrintStream stdout = new UncloseablePrintStream(output.out());
                  PrintStream stderr = new UncloseablePrintStream(output.err());
                 
                  Shell currentShell = (Shell) uiContext.getProvider();
                  final TerminalSize terminalSize = currentShell.getConsole().getShell().getSize();
                  ForgeTerminal terminal = new ForgeTerminal(
                           new Terminal()
                           {

                              @Override
                              public void close() throws IOException
                              {

                              }

                              @Override
                              public void initialize()
                              {

                              }

                              @Override
                              public int getWidth()
                              {
                                 return terminalSize.getWidth();
                              }

                              @Override
                              public int getHeight()
                              {
                                 return terminalSize.getHeight();
                              }
                           });

                  Settings settings = new SettingsBuilder()
                           .inputStream(new PipedInputStream(stdin))
View Full Code Here

Examples of org.jboss.aesh.terminal.TerminalSize

      return result;
   }

   private String listMany(Iterable<Resource<?>> resources, Shell shell)
   {
      TerminalSize terminalSize = shell.getConsole().getShell().getSize();
      List<String> display = new ArrayList<>();
      boolean showAll = all.getValue();
      if (resources != null)
      {
         for (Resource<?> resource : resources)
         {
            String name;
            if (resource instanceof FileResource)
            {
               FileResource<?> fileResource = (FileResource<?>) resource;
               if (!showAll && fileResource.getName().startsWith("."))
               {
                  continue;
               }
               name = ShellUtil.colorizeResource(fileResource);
            }
            else
            {
               name = resource.getName();
            }
            display.add(name);
         }
      }
      return Parser.formatDisplayList(display, terminalSize.getHeight(), terminalSize.getWidth());
   }
View Full Code Here

Examples of org.jboss.aesh.terminal.TerminalSize

        shell.out().print('x');
    }


    private void drawHorizontalLine(int x, int y, int width) {
        TerminalSize terminalSize = graphicsConfiguration.getBounds();
        if(terminalSize.getHeight() > y && terminalSize.getWidth() > y) {
            if(terminalSize.getWidth() < x + width)
                width = terminalSize.getWidth() - x-1;
            shell.setCursor(new CursorPosition(y,x));
            char[] line = new char[width];
            for(int i=0; i < line.length; i++) {
                if(i == 0 || i == line.length-1)
                    line[i] = 'x';
View Full Code Here

Examples of org.jboss.aesh.terminal.TerminalSize

            shell.out().print(line);
        }
    }

    private void drawVerticalLine(int x, int y, int length) {
        TerminalSize terminalSize = graphicsConfiguration.getBounds();
        if(terminalSize.getHeight() > y && terminalSize.getWidth() > y) {
            if(terminalSize.getHeight() < y + length)
                length = terminalSize.getHeight() - y-1;
            shell.setCursor(new CursorPosition(y,x));
            for(int i=0; i < length; i++) {
                shell.out().print('|');
                shell.out().print(CURSOR_DOWN);
            }
View Full Code Here

Examples of org.jboss.aesh.terminal.TerminalSize

   {
      int height = delegate.getHeight();
      int width = delegate.getWidth();
      if (terminalSize == null || (terminalSize.getHeight() != height || terminalSize.getWidth() != width))
      {
         terminalSize = new TerminalSize(height, width);
      }
      return terminalSize;
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.