package org.CS2336;

import com.googlecode.lanterna.TerminalFacade;
import com.googlecode.lanterna.gui.GUIScreen;
import org.CS2336.btree.BinaryTree;
import org.CS2336.btree.Util;
import org.CS2336.gfx.MainWindow;

import java.io.File;
import java.io.IOException;

public class TreeSearch {
    public static BinaryTree<String> myTree = null;

    public static void main(String[] args) throws IOException {
        if(args.length == 1) {
            System.out.println(args[0]);
            if(!Util.buildTree(new File(args[0]))) {
                System.err.println("[ERROR] Could not build tree - duplicate node.");
                return;
            }

            try {
                Util.runAllReports(myTree);
            } catch(IOException e) {
                System.out.println("An error occured while writing reports: " + e.toString());
            }

            System.out.println(Util.explode(myTree));
            return;
        }

        if(System.console() != null) {
            //draw inline iff a console is available
            System.setProperty("java.awt.headless", "true");
        }

        GUIScreen textGUI = TerminalFacade.createGUIScreen();

        textGUI.getScreen().startScreen();
        textGUI.setTitle("GUI Test");
        //Do GUI logic here

        MainWindow mainWindow = new MainWindow(textGUI);
        textGUI.showWindow(mainWindow, GUIScreen.Position.CENTER);
        textGUI.getScreen().stopScreen();
    }
}




@@ -463,16 +463,37 @@
 println(
+%22Processing file %22 + 
 args%5B0%5D)
@@ -494,16 +494,16 @@
 gs%5B0%5D);%0A
-
         
@@ -706,16 +706,35 @@
         
+System.out.println(
 Util.run
@@ -751,16 +751,17 @@
 (myTree)
+)
 ;%0A      
@@ -893,32 +893,87 @@
 %0A            %7D%0A%0A
+            System.out.println(%22Tree visualization:%22);%0A
             Syst

improve output in non curses mode