Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/src/hoodui/PrettyNest.java

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


/*
 * Nesting operation for pretty printers
 *
 * Copyright 2000 Andy Gill
 *
 * $Revision: 1.1 $
 * $Date: 2000/09/15 16:14:17 $
 */

/**
 * @version 0.1
 * @author Andy Gill
 */

public class PrettyNest extends Pretty {
    int i;
    Pretty p;
    protected PrettyNest(int i,Pretty p) {
	this.i = i;
	this.p = p; 
    }
    /*
    public void render(PrettyContext pc) throws PrettyException {
	PrettyContextReader r = pc.getReader();
	int nestDepth = pc.column + i;
	PrettyContext pcSave = new PrettyContext(pc);
	switch(r.state) {
	case PrettyContextReader.ONE_LINE_NOHANDLE:
	    try {
		PrettyContextReader newR
		    = new PrettyContextReader(nestDepth,PrettyContextReader.ONE_LINE_HANDLE);
		pc.putReader(newR);
		p.render(pc);
	    } catch (PrettyException pe) {
		Message.message("caught pp");
		pc.restore(pcSave);
		PrettyContextReader newR
		    = new PrettyContextReader(nestDepth,PrettyContextReader.MULTI_LINE);
		pc.putReader(newR);
		p.render(pc);
	    }
	    break;
	case PrettyContextReader.ONE_LINE_HANDLE:  // Intended
	case PrettyContextReader.MULTI_LINE:
	    PrettyContextReader newR
		= new PrettyContextReader(nestDepth,r.state);
	    pc.putReader(newR);
	    p.render(pc);
	    break;
	}
	pc.putReader(r);
    }
    */
    public void render(int indent,boolean flatten,PrettyContext pc) {
	pc.pushNextCommand(new PrettyCommand(p,i+pc.currWidth,flatten));
    }

    public String toString() {
	return ("nest(" + i + "," + p.toString() + ")");
    }

}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.