📄 bfunc.java
字号:
{
/* (cell-create i:short j:short formula:string format:short ) -> cell */
Cell cell = (Cell)Cell.fromList( sexp );
try {
cell.formula = Operator.OPERATOR.parseFormula( sexp.getString3() ); // formula
}
catch( FormulaParseException ee ) {
// will import even not parsed formulas
// throw new EvaluateException( ee.getMessage(), sexp );
}
return cell;
}
case NAME_REF:
/* (ref i1 j1 i2 j2 absflags) -> reference */
return fromList( sexp );
case NAME_CURSOR_MOVE:
/* (cursor-move axis:short offset:short) -> nil*/
//#ifndef NOGUI
case NAME_CURSOR_SET:
/* (cursor-set axis:short index:short) -> nil*/
{
int oldcursor[] = { canvasHandler.cursorx, canvasHandler.cursory };
int axis = sexp.getShort1();
int pos = sexp.getShort2();
if( optype == NAME_CURSOR_MOVE )
pos += oldcursor[axis];
int paint;
if( axis == 0 )
paint = canvasHandler.setCursorX( pos );
else
paint = canvasHandler.setCursorY( pos );
if( paint == 2 )
canvasHandler.canvas.repaint();
else if( paint == 1 ) {
canvasHandler.repaintCell( oldcursor[1], oldcursor[0] );
canvasHandler.repaintCell( canvasHandler.cursory, canvasHandler.cursorx );
}
break;
}
case NAME_CURSOR_GET:
{
/* (cursor-get axis:short) -> index:short*/
int axis = sexp.getShort1();
return new ShortAtom( axis == 0 ? canvasHandler.cursorx : canvasHandler.cursory );
}
//#endif
//#ifndef MINIMAL_SET
case NAME_SHEET_ADDCELL:
{
/* (sheet-addcell cell) -> cell */
Cell cl = sexp.getCell1();
sheet.putCell( cl );
return cl;
}
case NAME_CELL_GETFORMULA:
{
/* (cell-getformula cell) -> string */
Cell cl = sexp.getCell1();
return new StringAtom( cl.formula.toString() );
}
//#endif
case NAME_CELL_GETWSFORMULA:
{
/* (cell-getwsformula cell) -> string */
Cell cl = sexp.getCell1();
return new StringAtom( cl.getFormula() );
}
case NAME_CELL_ADDRESS:
{
/* (cell-address cell) -> string */
Cell cl = sexp.getCell1();
return new StringAtom( Reference.cellAddress(cl.i,cl.j,0) );
}
//#ifndef NOGUI
case NAME_SHEET_GETCELL:
{
/* (sheet-getcell row:short col:short) -> cell */
int i = sexp.getShort1();
int j = sexp.getShort2();
return canvasHandler.getCell( i, j );
}
//#endif
//#ifndef MINIMAL_SET
case NAME_SEXP_PARSE:
{
/* (parse-sexp lisp:string) -> lispobject */
try {
return LispObject.parseSExp( sexp.getString1() );
}
catch( ParseException ee ) {
throw new EvaluateException( ee.getMessage(), sexp );
}
}
//#endif
//#ifndef NOGUI
case NAME_CELL_ACTIVE:
{
/* (cell-active) -> cell gets current selected cell */
return canvasHandler.getCell( canvasHandler.cursory, canvasHandler.cursorx );
}
//#endif
case NAME_CELL_SETFORMULA:
{
/* (cell-setformula cell formula:string) -> nil */
Cell cl = sexp.getCell1();
try {
sheet.setFormula( cl.i, cl.j, sexp.getString2() );
}
catch( ParseException ee ) {
throw new EvaluateException( ee.getMessage(), sexp );
}
break;
}
case NAME_CELL_SETWSFORMULA:
{
/* (cell-setwsformula cell formula:string) -> nil */
Cell cl = sexp.getCell1();
String formula = sexp.getString2();
try {
sheet.setWSFormula( cl.i, cl.j, formula );
}
catch( FormulaParseException ee ) {
throw new EvaluateException( ee.getMessage() );
}
break;
}
//#ifndef NOGUI
case NAME_SHEET_RECALCULATE:
{
/* (sheet-recalculate [repaintflag:ShortAtom]) -> nil */
int paint = 0;
if( size > 1 )
paint = sexp.getShort1();
try {
sheet.recalculateChangedCells( paint==1 ? canvasHandler : null );
}
catch( CircularReferenceException ee ) {
throw new EvaluateException(ee.getMessage(), sexp);
}
if( paint == 2 )
canvasHandler.repaint();
break;
}
//#endif
//#ifndef MINIMAL_SET
case NAME_SEXP_EVALUATE:
/* (sexp-evaluate) -> obj*/
return sexp.evaluateArg1().interpret();
case NAME_SEXP_GETTYPE:
/* (sexp-gettype sexp) -> short */
return new ShortAtom( sexp.evaluateArg1().typeNumber() );
case NAME_SEXP_PREPROCESS:
{
/* (sexp-preprocess sexp functor1 ...) -> sexp */
LispObject rez = sexp.getArgument1();
for( int i=2; i<size; i++ ) {
NameObjectBase functor = (NameObjectBase)sexp.getArgumentN(i);
rez = rez.preprocess(functor);
}
return rez;
}
case NAME_GOLD_SET:
/* (gold-set short) -> nil */
//#ifndef NOGUI
canvasHandler.goldkey = sexp.getShort1();
//#endif
return NIL;
case NAME_THROW_ERROR:
{
/* (throw-error error) -> exception! */
FormulaError err = (FormulaError) sexp.evaluateArg1();
throw new EvaluateException(err.message);
}
case NAME_QLIST_TO_SHEET:
{
/* (qlist-to-sheet qlist:quotedlist sheet:sheet i:short j:short asis:short ) -> nil*/
QuotedList ql = sexp.getQuotedList(1);
Sheet sh = sexp.getSheet(2);
int ii = sexp.getShort3();
int jj = sexp.getShort(4);
int axis = sexp.getShort(5);
for( int i=0; i<ql.value.length; i++) {
int iii = ii;
int jjj = jj;
if(axis == 0)
iii+=i;
else
jjj+=i;
Cell cell = new Cell(iii,jjj,ql.value[i],0);
sh.putCell(cell);
}
break;
}
//#endif
//#ifdef JAVA_COMPILER
case NAME__IF:
if ( ((BooleanAtom)sexp.evaluateArg1()).value )
return sexp.getArgument2();
else if( size == 4 )
return sexp.getArgument3();
return NIL;
case NAME__INCLUDE:
/* not implemented because requires file system API, so should be done in separate module */
break;
//#endif
//#ifndef NOGUI
case NAME_CELL_REPAINT:
/* (cell-repaint I J) -> nil */
/* (cell-repaint cell) -> nil */
if( size == 2 ) {
Cell cell = sexp.getCell1();
canvasHandler.repaintCell( cell.i, cell.j );
}
else
canvasHandler.repaintCell( sexp.getShort1(), sexp.getShort2() );
break;
//#endif
case NAME_DATE:
/* (date milisec:long) -> date */
return fromList( sexp );
case NAME_ROWCOLUMN:
/* (rowcolumn index width) -> rowcolumn */
return fromList( sexp );
//#ifndef NOGUI
case NAME_SHEET_SAVE:
/* (sheet-save sheet recordstorename:string) -> nil */
try {
Sheet sh = sexp.getSheet1();
sh.saveToRecordStore( sexp.getString2() );
}
catch( RecordStoreException ee ) {
throw new EvaluateException("Error saving sheet: " + ee.getMessage(), sexp);
}
break;
case NAME_SHEET_LOAD:
/* (sheet-load recordstorename:string) -> sheet */
try {
Sheet sh = Sheet.readFromRecordStore( sexp.getString1() );
canvasHandler.sheetInitialize();
return sh;
}
catch( RecordStoreException ee ) {
throw new EvaluateException("Error loading sheet: " + ee.getMessage(), sexp);
}
catch( ParseException ee ) {
throw new EvaluateException("Error parsing sheet: " + ee.getMessage(), sexp);
}
//#endif
case NAME_SHEET_GETNAME:
/* (sheet-getname sheet) -> string */
return new StringAtom( sexp.getSheet1().name );
case NAME_SHEET_SETNAME:
/* (sheet-setname sheet name:string) -> nil */
sexp.getSheet1().name = sexp.getString2();
break;
case NAME_SHEET_ISCHANGED:
{
/* (sheet-ischanged sheet ) -> boolean */
Sheet sh = sexp.getSheet1();
return sh.isChanged ? BooleanAtom.TRUE : BooleanAtom.FALSE;
}
case NAME_SHEET_SETCHANGED:
/* (sheet-setchanged sheet changed:boolean) -> nil */
sexp.getSheet1().isChanged = sexp.getBoolean(2);
break;
//#ifndef NOGUI
case NAME_SHEET_LIST:
/* (sheet-list) -> '("file1" "file2") */
return Sheet.listSheets();
//#endif
case NAME_CELL_SETFORMAT:
{
/* (cell-setformat cell) -> nil */
Cell cl = sexp.getCell1();
short format = sexp.getShort2();
cl.format = format;
break;
}
case NAME_CELL_GETFORMAT:
{
/* (cell-getformat cell) -> short */
Cell cl = sexp.getCell1();
return new ShortAtom( cl.format );
}
//#ifndef NOGUI
case NAME_SHEET_DELETE:
{
/* (sheet-delete string) -> nil */
String sheetname = sexp.getString1();
try {
Sheet.deleteFromRecordStore( sheetname );
}
catch( RecordStoreException ee ) {
throw new EvaluateException( "cannot delete sheet", sexp );
}
break;
}
case NAME_MESSAGE:
{
/* (message title:string body:string) -> nil */
Alert a1 = new Alert(
sexp.getString1(),
sexp.getString2(),
null,
AlertType.INFO );
a1.setTimeout( Alert.FOREVER );
LispTask.LispMachine.popMessage = a1;
break;
}
//#endif
case NAME_SHEET_GETWIDTHHEIGHT:
{
/* (sheet-getwidthheight sheet axis:ShortAtom index:ShortAtom) -> ShortAtom */
Sheet sheet1 = sexp.getSheet1();
return new ShortAtom( sheet1.getRowColumn( sexp.getShort2(), sexp.getShort3() ).width_height );
}
case NAME_SHEET_SETWIDTHHEIGHT:
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -