Esempio n. 1
0
void InsetMathFrac::draw(PainterInfo & pi, int x, int y) const
{
	setPosCache(pi, x, y);
	Dimension const dim = dimension(*pi.base.bv);
	Dimension const dim0 = cell(0).dimension(*pi.base.bv);
	if (kind_ == UNIT || (kind_ == UNITFRAC && nargs() == 3)) {
		if (nargs() == 1) {
			ShapeChanger dummy2(pi.base.font, UP_SHAPE);
			cell(0).draw(pi, x + 1, y);
		} else if (nargs() == 2) {
			cell(0).draw(pi, x + 1, y);
			ShapeChanger dummy2(pi.base.font, UP_SHAPE);
			cell(1).draw(pi, x + dim0.width() + 5, y);
		} else {
			cell(2).draw(pi, x + 1, y);
			ShapeChanger dummy2(pi.base.font, UP_SHAPE);
			FracChanger dummy(pi.base);
			Dimension const dim1 = cell(1).dimension(*pi.base.bv);
			Dimension const dim2 = cell(2).dimension(*pi.base.bv);
			int xx = x + dim2.wid + 5;
			cell(0).draw(pi, xx + 2, 
					 y - dim0.des - 5);
			cell(1).draw(pi, xx  + dim0.width() + 5, 
					 y + dim1.asc / 2);
		}
	} else {
		FracChanger dummy(pi.base);
		Dimension const dim1 = cell(1).dimension(*pi.base.bv);
		int m = x + dim.wid / 2;
		if (kind_ == NICEFRAC) {
			cell(0).draw(pi, x + 2,
					y - dim0.des - 5);
			cell(1).draw(pi, x + dim0.width() + 5,
					y + dim1.asc / 2);
		} else if (kind_ == UNITFRAC) {
			ShapeChanger dummy2(pi.base.font, UP_SHAPE);
			cell(0).draw(pi, x + 2,	y - dim0.des - 5);
			cell(1).draw(pi, x + dim0.width() + 5, y + dim1.asc / 2);
		} else if (kind_ == FRAC || kind_ == ATOP || kind_ == OVER) {
			cell(0).draw(pi, m - dim0.wid / 2, y - dim0.des - 2 - 5);
			cell(1).draw(pi, m - dim1.wid / 2, y + dim1.asc + 2 - 5);
		} else if (kind_ == TFRAC) {
			// tfrac is in always in text size
			StyleChanger dummy2(pi.base, LM_ST_SCRIPT);
			cell(0).draw(pi, m - dim0.wid / 2, y - dim0.des - 2 - 5);
			cell(1).draw(pi, m - dim1.wid / 2, y + dim1.asc + 2 - 5);
		} else {
			// \cfrac and \dfrac are always in display size
			StyleChanger dummy2(pi.base, LM_ST_DISPLAY);
			if (kind_ == CFRAC || kind_ == DFRAC)
				cell(0).draw(pi, m - dim0.wid / 2, y - dim0.des - 2 - 5);
			else if (kind_ == CFRACLEFT)
				cell(0).draw(pi, x + 2, y - dim0.des - 2 - 5);
			else if (kind_ == CFRACRIGHT)
				cell(0).draw(pi, x + dim.wid - dim0.wid - 2,
					y - dim0.des - 2 - 5);
			cell(1).draw(pi, m - dim1.wid / 2, y + dim1.asc + 2 - 5);
		}
	}
	if (kind_ == NICEFRAC || kind_ == UNITFRAC) {
		// Diag line:
		int xx = x;
		if (nargs() == 3)
			xx += cell(2).dimension(*pi.base.bv).wid + 5;
		pi.pain.line(xx + dim0.wid,
				y + dim.des - 2,
				xx + dim0.wid + 5,
				y - dim.asc + 2, pi.base.font.color());
	}
	if (kind_ == FRAC || kind_ == CFRAC || kind_ == CFRACLEFT
		|| kind_ == CFRACRIGHT || kind_ == DFRAC
		|| kind_ == TFRAC || kind_ == OVER)
		pi.pain.line(x + 1, y - 5,
				x + dim.wid - 2, y - 5, pi.base.font.color());
	drawMarkers(pi, x, y);
}
Esempio n. 2
0
void InsetMathFrac::metrics(MetricsInfo & mi, Dimension & dim) const
{
	Dimension dim0, dim1, dim2;

	if (kind_ == UNIT || (kind_ == UNITFRAC && nargs() == 3)) {
		if (nargs() == 1) {
			ShapeChanger dummy2(mi.base.font, UP_SHAPE);
			cell(0).metrics(mi, dim0);
			dim.wid = dim0.width()+ 3;
			dim.asc = dim0.asc;
			dim.des = dim0.des;
		} else if (nargs() == 2) {
			cell(0).metrics(mi, dim0);
			ShapeChanger dummy2(mi.base.font, UP_SHAPE);
			cell(1).metrics(mi, dim1);
			dim.wid = dim0.width() + dim1.wid + 5;
			dim.asc = max(dim0.asc, dim1.asc);
			dim.des = max(dim0.des, dim1.des);
		} else {
			cell(2).metrics(mi, dim2);
			ShapeChanger dummy2(mi.base.font, UP_SHAPE);
			FracChanger dummy(mi.base);
			cell(0).metrics(mi, dim0);
			cell(1).metrics(mi, dim1);
			dim.wid = dim0.width() + dim1.wid + dim2.wid + 10;
			dim.asc = max(dim2.asc, dim0.height() + 5);
			dim.des = max(dim2.des, dim1.height() - 5);
		}
	} else {
		// general cell metrics used for \frac
		FracChanger dummy(mi.base);
		cell(0).metrics(mi, dim0);
		cell(1).metrics(mi, dim1);
		if (nargs() == 3)
			cell(2).metrics(mi, dim2);
		// metrics for special fraction types
		if (kind_ == NICEFRAC) {
			dim.wid = dim0.width() + dim1.wid + 5;
			dim.asc = dim0.height() + 5;
			dim.des = dim1.height() - 5;
		} else if (kind_ == UNITFRAC) {
			ShapeChanger dummy2(mi.base.font, UP_SHAPE);
			dim.wid = dim0.width() + dim1.wid + 5;
			dim.asc = dim0.height() + 5;
			dim.des = dim1.height() - 5;
		} else {
			if (kind_ == CFRAC || kind_ == CFRACLEFT
			|| kind_ == CFRACRIGHT || kind_ == DFRAC) {
				// \cfrac and \dfrac are always in display size
				StyleChanger dummy2(mi.base, LM_ST_DISPLAY);
				cell(0).metrics(mi, dim0);
				cell(1).metrics(mi, dim1);
			} else if (kind_ == TFRAC) {
				// tfrac is in always in text size
				StyleChanger dummy2(mi.base, LM_ST_SCRIPT);
				cell(0).metrics(mi, dim0);
				cell(1).metrics(mi, dim1);
			}
			dim.wid = max(dim0.wid, dim1.wid) + 2;
			dim.asc = dim0.height() + 2 + 5;
			dim.des = dim1.height() + 2 - 5;
		}
	}
	metricsMarkers(dim);
}
Esempio n. 3
0
	asm {
		mov ax, 5801h		/* Set Allocation Strategy */
		mov bx, 2			/* Last fit */
		int 21h
	}

	asm {
		mov bx, asmName(size, 4)
		mov ah, 48h
		int 21h
		jnc allocOK
		xor ax, ax
	asmLabel(allocOK)
	}
	segment = nargs();

	if(allocation != 2) {
		_AX = 0x5801;
		_BX = allocation;
		geninterrupt(0x21);
	}
	if(UMBLink == 0) {
		_AX = 0x5803;
		_BX = 0;
		geninterrupt(0x21);
	}

	return segment;
}
Esempio n. 4
0
 *      You should have received a copy of the GNU General Public License
 *      along with frosted.  If not, see <http://www.gnu.org/licenses/>.
 *
 *      Authors:
 *
 */
 
#include "frosted_binutils.h"

int main(int argc, char *args[])
    int argc = 0, i, c;
    extern int optind;
    char delim = '\n';
    char *head, *tail;
    char **flags;
    argc = nargs( args);

    setlocale (LC_ALL, "");

    if ( argc < 2 || args[1] == NULL){
        fprintf(stderr, "usage: dirname [OPTION] NAME...\n");
        exit(1);
    }

    while( (c=getopt(argc,(char**) args, "r") ) != -1 ){
        switch (c){
            case 'r':   /*use NUL char as delimiter instead of \n*/
                delim = (char) 0;
                break;
            default:
                fprintf( stderr, "dirname: invalid option -- '%c'\n", (char)c);
Esempio n. 5
0
static void configure(int handle, int argc, char **argv)
{
	int i;
	u8 arg1, arg2;

	for (i = 1; i < argc; ++i)
	{
		u8 perm = 0x80;
		char *cmd = argv[i];

		if (strneq(cmd, "temp-", 5))
			perm = 0, cmd += 5;

		if (streq(cmd, "free"))
		{
			mx_cmd(handle, perm + 1, 0, 0);
		}
		else if (streq(cmd, "click"))
		{
			mx_cmd(handle, perm + 2, 0, 0);
		}
		else if (strneq(cmd, "manual", 6))
		{
			twoargs(cmd + 6, &arg1, &arg2, 0, 0, 15);
			if (arg1 != arg2)
				mx_cmd(handle, perm + 7, arg1 * 16 + arg2, 0);
			else
				mx_cmd(handle, perm + 8, arg1, 0);
		}
		else if (strneq(cmd, "auto", 4))
		{
			twoargs(cmd + 4, &arg1, &arg2, 0, 0, 50);
			mx_cmd(handle, perm + 5, arg1, arg2);
		}
		else if (strneq(argv[i], "soft-free", 9))
		{
			twoargs(argv[i] + 9, &arg1, &arg2, 0, 0, 255);
			mx_cmd(handle, 3, arg1, arg2);
		}
		else if (strneq(argv[i], "soft-click", 10))
		{
			twoargs(argv[i] + 10, &arg1, &arg2, 0, 0, 255);
			mx_cmd(handle, 4, arg1, arg2);
		}
		else if (strneq(argv[i], "reconnect", 9))
		{
			static const u8 cmd[] = { 0xff, 0x80, 0xb2, 1, 0, 0 };

			twoargs(argv[i] + 9, &arg1, &arg2, 0, 0, 255);
			send_report(handle, 0x10, cmd, 6);
			printf("Reconnection initiated\n");
			printf(" - Turn off the mouse\n");
			printf(" - Press and hold the left mouse button\n");
			printf(" - Turn on the mouse\n");
			printf(" - Press the right button 5 times\n");
			printf(" - Release the left mouse button\n");
		}
		else if (strneq(argv[i], "mode", 4))
		{
			u8 buf[6];

			if (mx_query(handle, 0x08, buf))
			{
				if (buf[5] & 1)
					printf("click-by-click\n");
			else
				printf("free spinning\n");
			}
		}
		else if (strneq(argv[i], "battery", 7))
		{
			u8 buf[6];

			if (mx_query(handle, 0x0d, buf))
			{
				char str[32], *st;

				switch (buf[5])
				{
					case 0x30:	st = "running on battery";	break;
					case 0x50:	st = "charging";		break;
					case 0x90:	st = "fully charged";		break;
					default:	sprintf(st = str, "status %02x", buf[5]);
				}
				printf("battery level %d%%, %s\n", buf[3], st);
			}
		}

		/*** debug commands ***/
		else if (strneq(argv[i], "raw", 3))
		{
			u8 buf[256], n;

			n = nargs(argv[i] + 3, buf, 256, 0, 0, 255);
			send_report(handle, buf[0], buf+1, n-1);
		}
		else if (strneq(argv[i], "query", 5))
		{
			u8 buf[256], j;

			twoargs(argv[i] + 5, &arg1, &arg2, -1, 0, 255);
			if (arg1 == -1)
				arg1 = 0x10, arg2 = 6;
			query_report(handle, arg1, buf, arg2);

			printf("report %02x:", arg1);
			for (j = 0; j < arg2; ++j)
				printf(" %02x", buf[j]);
			printf("\n");
		}
		else if (strneq(argv[i], "sleep", 5))
		{
			twoargs(argv[i] + 5, &arg1, &arg2, 1, 0, 255);
			sleep(arg1);
		}
		else
			fatal("unknown option `%s'", argv[i]);
	}
}
Esempio n. 6
0
void SelectFunc::execute() {
    static int all_symid = symbol_add("all");
    ComValue all_flagv(stack_key(all_symid));
    boolean all_flag = all_flagv.is_true();
    static int clear_symid = symbol_add("clear");
    ComValue clear_flagv(stack_key(clear_symid));
    boolean clear_flag = clear_flagv.is_true();

    Selection* sel = _ed->GetViewer()->GetSelection();
    if (clear_flag) {
      sel->Clear();
      unidraw->Update();
      reset_stack();
      return;
    }
      
    OverlaySelection* newSel = ((OverlayEditor*)_ed)->overlay_kit()->MakeSelection();
    
    Viewer* viewer = _ed->GetViewer();
    AttributeValueList* avl = new AttributeValueList();
    if (all_flag) {

      GraphicView* gv = ((OverlayEditor*)_ed)->GetFrame();
      Iterator i;
      int count=0;
      for (gv->First(i); !gv->Done(i); gv->Next(i)) {
	GraphicView* subgv = gv->GetView(i);
	newSel->Append(subgv);
	OverlayComp* comp = (OverlayComp*)subgv->GetGraphicComp();
	ComValue* compval = new ComValue(new OverlayViewRef(comp), comp->classid());
	avl->Append(compval);
      }

    } else if (nargs()==0) {
      Iterator i;
      int count=0;
      for (sel->First(i); !sel->Done(i); sel->Next(i)) {
	GraphicView* grview = sel->GetView(i);
	OverlayComp* comp = grview ? (OverlayComp*)grview->GetSubject() : nil;
	ComValue* compval = comp ? new ComValue(new OverlayViewRef(comp), comp->classid()) : nil;

	if (compval) {
	  avl->Append(compval);
	}
	delete newSel;
        newSel = nil;
      }

    } else {

      for (int i=0; i<nargsfixed(); i++) {
        ComValue& obj = stack_arg(i);
	if (obj.object_compview()) {
	  ComponentView* comview = (ComponentView*)obj.obj_val();
	  OverlayComp* comp = (OverlayComp*)comview->GetSubject();
	  if (comp) {
	    GraphicView* view = comp->FindView(viewer);
	    if (view) {
	      newSel->Append(view);
	      ComValue* compval = new ComValue(new OverlayViewRef(comp), comp->classid());
	      avl->Append(compval);
	    }
	  }
	} else if (obj.is_array()) {
	  Iterator it;
	  AttributeValueList* al = obj.array_val();
	  al->First(it);
	  while (!al->Done(it)) {
	    if (al->GetAttrVal(it)->object_compview()) {
	      ComponentView* comview = (ComponentView*)al->GetAttrVal(it)->obj_val();
	      OverlayComp* comp = (OverlayComp*)comview->GetSubject();
	      if (comp) {
		GraphicView* view = comp->FindView(viewer);
		if (view) {
		  newSel->Append(view);
		  ComValue* compval = new ComValue(new OverlayViewRef(comp), comp->classid());
		  avl->Append(compval);
		}
	      }
	    }
	    al->Next(it);
	  }
	}
      }
    }

    if (newSel){
      sel->Clear();
      delete sel;
      _ed->SetSelection(newSel);
      newSel->Update(viewer);
      unidraw->Update();
    }
    reset_stack();
    ComValue retval(avl);
    push_stack(retval);
}