std::shared_ptr<Object> LispReader::read(std::istream &in, bool eof_is_error, std::shared_ptr<Object> eof_value, bool is_recursive) { //return read(in, eof_is_error, eof_value, is_recursive); for (; ;) { int c; while (iswhitespace(c = in.get())) {} if (in.eof()) { return eof_value; } else { if (c == '+' || c == '-') { int c2 = in.peek(); if (std::isdigit(c2)) { in.unget(); return read_number(in); } } if (std::isdigit(c)) { in.unget(); return read_number(in); } macro_fn fn = getmacro(c); if (fn != 0) { return fn(in); } in.unget(); return read_token(in); throw "not yet supported"; } } return eof_value; }
std::list<std::shared_ptr<Object>> read_delimited_list(int delim, std::istream &in) { std::list<std::shared_ptr<Object> > list; for (; ;) { int c; while (iswhitespace(c = in.get())) {} if (in.eof()) { throw "EOF while reading"; } if (c == delim) { break; } macro_fn fn = getmacro(c); if (fn != 0) { auto m = fn(in); if (m != NOOP) { list.push_back(m); } } else { in.unget(); auto o = read(in, true, Object::nil, true); if (o != NOOP) { list.push_back(o); } } } return list; }
short ModalMacros(NewMacroInfo *macrost) { DialogPtr dtemp; short dItem; short i; Rect dBox; Str255 temp; Handle MacString[10], rubbish; SetUpMovableModalMenus(); dtemp=GetNewMyDialog( MacroDLOG + 2, NULL, kInFront, (void *)ThirdCenterDialog); SetDialogDefaultItem(dtemp, 1); SetDialogCancelItem(dtemp, 2); SetDialogTracksCursor(dtemp, 1); HideDialogItem(dtemp, 25); // no save default in session macros dialog dialogPane = 0; // start with Command-[0-9] // RAB BetterTelnet 2.0b5 - fix cancel button so it works again oldMacros = macrost->handle; HandToHand(&oldMacros); oldMacroIndexes = *macrost; // now fix the strings for (i=0; i<10; i++) { GetIndString(temp, 7100, i + (10 * dialogPane) + 1); GetDialogItem(dtemp, i+3, &dItem, &rubbish, &dBox); if (!temp[0]) { HideDialogItem(dtemp, i+13); HideDialogItem(dtemp, i+3); } else { ShowDialogItem(dtemp, i+13); ShowDialogItem(dtemp, i+3); } SetDialogItemText(rubbish, temp); } for (i=0; i<10; i++) { getmacro(macrost, i, (char *) &temp, 256); /* BYU LSC */ c2pstr((char *)temp); /* BYU LSC */ GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox); SetDialogItemText( MacString[i], temp ); } TelInfo->macrosModeless = dtemp; dItem = 0; while ((dItem != 1) && (dItem != 2)) { movableModalDialog(0, &dItem); MacroDialog(macrost, dtemp, 0, dItem); } if (dItem == 2) CancelMacros(macrost, dtemp); else CloseMacros(macrost, dtemp); ResetMenus(); return dItem; }
void Macros( void) { DialogPtr dtemp; short dItem; short i; Rect dBox; Str255 temp; Handle MacString[10], rubbish; setLastCursor(theCursors[normcurs]); if (TelInfo->macrosModeless) { SelectWindow(TelInfo->macrosModeless); return; } dtemp=GetNewMyDialog( MacroDLOG, NULL, kInFront, (void *)ThirdCenterDialog); SetDialogDefaultItem(dtemp, 1); SetDialogCancelItem(dtemp, 2); SetDialogTracksCursor(dtemp, 1); dialogPane = 0; // start with Command-[0-9] // RAB BetterTelnet 2.0b5 - fix cancel button so it works again oldMacros = TelInfo->newMacros.handle; HandToHand(&oldMacros); oldMacroIndexes = TelInfo->newMacros; // now fix the strings for (i=0; i<10; i++) { GetIndString(temp, 7100, i + (10 * dialogPane) + 1); GetDialogItem(dtemp, i+3, &dItem, &rubbish, &dBox); if (!temp[0]) { HideDialogItem(dtemp, i+13); HideDialogItem(dtemp, i+3); } else { ShowDialogItem(dtemp, i+13); ShowDialogItem(dtemp, i+3); } SetDialogItemText(rubbish, temp); } for (i=0; i<10; i++) { getmacro(&TelInfo->newMacros, i, (char *) &temp, 256); /* BYU LSC */ c2pstr((char *)temp); /* BYU LSC */ GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox); SetDialogItemText( MacString[i], temp ); } TelInfo->macrosModeless = dtemp; }
// NB: As of 2.0fc1, theEvent can be NULL! It isn't used anywhere, so don't _let_ it be // used anywhere! void MacroDialog(NewMacroInfo *macrost, DialogPtr dtemp, EventRecord *theEvent, short dItem) { short i; Rect dBox; Str255 temp; Handle MacString[10], rubbish; switch (dItem) { case 27: // switch keyset (pane) - RAB BetterTelnet 2.0b5 for (i=0; i<10; i++) { GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox); GetDialogItemText( MacString[i], temp); p2cstr(temp); setmacro(macrost, i + (10 * dialogPane), (char *) &temp); } dialogPane = GetCntlVal(dtemp, 27) - 1; // now fix the strings for (i=0; i<10; i++) { GetIndString(temp, 7100, i + (10 * dialogPane) + 1); GetDialogItem(dtemp, i+3, &dItem, &rubbish, &dBox); if (!temp[0]) { HideDialogItem(dtemp, i+13); HideDialogItem(dtemp, i+3); } else { ShowDialogItem(dtemp, i+13); ShowDialogItem(dtemp, i+3); } SetDialogItemText(rubbish, temp); } for (i=0; i<10; i++) { getmacro(macrost, i + (10 * dialogPane), (char *) &temp, 256); c2pstr((char *)temp); GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox); SetDialogItemText( MacString[i], temp ); } break; case (MacroExport): // we _used_ to get all the macros out, but now only the current set of 10 for (i=0; i<10; i++) { GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox); GetDialogItemText( MacString[i], temp); p2cstr(temp); setmacro(macrost, i + (10 * dialogPane), (char *) &temp); // RAB BetterTelnet 2.0b5 (revised) } saveMacros(macrost, (FSSpec *) NULL); break; case 25: for (i=0; i<10; i++) { GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox); GetDialogItemText( MacString[i], temp); p2cstr(temp); setmacro(macrost, i + (10 * dialogPane), (char *) &temp); } SaveGlobalMacros(macrost); break; case (MacroImport): loadMacros(macrost, (FSSpec *) NULL); for (i=0; i<10; i++) { getmacro(macrost, i + (10 * dialogPane), (char *) &temp, 256); c2pstr((char *)temp); GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox); SetDialogItemText( MacString[i], temp ); } break; case 1: case 2: break; default: if (dItem >2 && dItem <13) { i=dItem-3; getmacro(macrost, i + (dialogPane * 10), (char *) &temp, 256); /* BYU LSC */ c2pstr((char *)temp); GetDialogItem( dtemp, i+13, &dItem, &MacString[i], &dBox); SetDialogItemText( MacString[i], temp ); /* BYU LSC - Revert the mother */ SelectDialogItemText( dtemp, i+13, 0, 32767); /* And select it... */ } break; } }
inline bool isterminator(int c) { return c != '#' && getmacro(c) != 0; }