Team Ai
Datasetpublic

hschumann2/TempleOS-Source-Code

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes847downloads
DocWidgetWiz.txt1165 linesDownload Raw Back to DolDoc
1 2#help_index "DolDoc/Misc"3 4U8 *ctrl_L_footer=5        "\n$MU-X+Q,\"Abort\",LE=DOCM_CANCEL$\n"6        "\n\n$LK+PU,\"Click for Help\",A=\"FI:::/Doc/Widget.DD\"$\n";7 8I64 PopUpLinkType(Bool include_anchor)9{10  I64 i;11  CDoc *doc=DocNew;12  DocPrint(doc,"$PURPLE$$TX+CX,\"Link Type Menu\"$\n"13        "\n$LTBLUE$$MU,\"To file\",LE=LK_FILE$\n"14        "$MU,\"To anchor in file\",LE=LK_FILE_ANCHOR$\n"15        "$MU,\"To str in file\",LE=LK_FILE_FIND$\n"16        "$MU,\"To line in file\",LE=LK_FILE_LINE$\n"17        "$MU,\"To man page\",LE=LK_MAN_PAGE$\n"18        "$MU,\"To plain-text file\",LE=LK_PLAIN$\n"19        "$MU,\"To str in plain-text file\",LE=LK_PLAIN_FIND$\n"20        "$MU,\"To line in plain-text file\",LE=LK_PLAIN_LINE$\n"21        "$MU,\"To Bible chapter line and verse\",LE=LK_BIBLE_FIND$\n"22        "$MU,\"To Dictionary Definition\",LE=LK_DEF$\n"23        "$MU,\"To Help Index\",LE=LK_HELP_INDEX$\n"24        "$MU,\"To Addr\",LE=LK_ADDR$\n");25  if (include_anchor)26    DocPrint(doc,"$MU,\"Place Anchor\",LE=LK_PLACE_ANCHOR$\n");27  DocPrint(doc,"%s",ctrl_L_footer);28  i=PopUpMenu(doc);29  DocDel(doc);30  return i;31}32 33class CEdFileLink34{35  U8    tag[512]        format "$DA-P,A=\"Tag Text      :%s\"$\n",36        file[512]       format "$DA-P,A=\"File          :%s\"$\n";37  I64   book;38  U8    aux[512];39  I64   num;40  U8    html_link[512]  format "$DA-P,A=\"Html Link     :%s\"$\n";41  Bool  pop_up          format "$CB,\"PopUp\"$\n",42        quote           format "$CB,\"Quote\"$\n",43        hide;44};45 46class CEdFileAnchorLink47{48  U8    tag[512]        format "$DA-P,A=\"Tag Text      :%s\"$\n",49        file[512]       format "$DA-P,A=\"File          :%s\"$\n";50  I64   book;51  U8    aux[512]        format "$DA-P,A=\"Anchor Label  :%s\"$\n";52  I64   num;53  U8    html_link[512]  format "$DA-P,A=\"Html Link     :%s\"$\n";54  Bool  pop_up          format "$CB,\"PopUp\"$\n",55        quote           format "$CB,\"Quote\"$\n",56        hide;57};58 59class CEdFileFindLink60{61  U8    tag[512]        format "$DA-P,A=\"Tag Text      :%s\"$\n",62        file[512]       format "$DA-P,A=\"File          :%s\"$\n";63  I64   book;64  U8    aux[512]        format "$DA-P,A=\"Str        :%s\"$\n";65  I64   num             format "$DA-TRM,A=\"Occurrence Num:%04d\"$\n";66  U8    html_link[512]  format "$DA-P,A=\"Html Link     :%s\"$\n";67  Bool  pop_up          format "$CB,\"PopUp\"$\n",68        quote           format "$CB,\"Quote\"$\n",69        hide;70};71 72class CEdFileLineLink73{74  U8    tag[512]        format "$DA-P,A=\"Tag Text      :%s\"$\n",75        file[512]       format "$DA-P,A=\"File          :%s\"$\n";76  I64   book;77  U8    aux[512];78  I64   num             format "$DA-TRM,A=\"Line Num      :%04d\"$\n";79  U8    html_link[512]  format "$DA-P,A=\"Html Link     :%s\"$\n";80  Bool  pop_up          format "$CB,\"PopUp\"$\n",81        quote           format "$CB,\"Quote\"$\n",82        hide;83};84 85class CEdManPageLink86{87  U8    tag[512]        format "$DA-P,A=\"Tag Text      :%s\"$\n",88        file[512];89  I64   book;90  U8    aux[512]        format "$DA-P,A=\"Label         :%s\"$\n";91  I64   num;92  U8    html_link[512]  format "$DA-P,A=\"Html Link     :%s\"$\n";93  Bool  pop_up          format "$CB,\"PopUp\"$\n",94        quote           format "$CB,\"Quote\"$\n",95        hide;96};97 98class CEdAddrLink99{100  U8    tag[512]        format "$DA-P,A=\"Tag Text      :%s\"$\n",101        file[512];102  I64   book;103  U8    aux[512]        format "$DA-P,A=\"Addr Exp   :%s\"$\n";104  I64   num             format "$DA-TRM,A=\"Bin Size      :%04d\"$\n";105  U8    html_link[512]  format "$DA-P,A=\"Html Link     :%s\"$\n";106  Bool  pop_up          format "$CB,\"PopUp\"$\n",107        quote           format "$CB,\"Quote\"$\n",108        hide;109};110 111class CEdPlaceAnchor112{113  U8    tag[512]        format "$DA-P,A=\"Tag Text      :%s\"$\n",114        file[512];115  I64   book;116  U8    aux[512]        format "$DA-P,A=\"Anchor Label  :%s\"$\n";117  I64   num;118  U8    html_link[512]  format "$DA-P,A=\"Html Link     :%s\"$\n";119  Bool  pop_up,120        quote           format "$CB,\"Quote\"$\n",121        hide            format "$CB,\"Hide\"$\n";122};123 124class CEdBibleLink125{126  U8    tag[512]        format "$DA-P,A=\"Tag Text      :%s\"$\n",127        file[512];128  I64   book            format "$LS,D=\"ST_BIBLE_BOOKS\"$\n";129  U8    aux[512]        format "$DA-P,A=\"Chapter Verse :%s\"$\n";130  I64   num;131 132  U8    html_link[512]  format "$DA-P,A=\"Html Link     :%s\"$\n";133  Bool  pop_up          format "$CB,\"PopUp\"$\n",134        quote           format "$CB,\"Quote\"$\n",135        hide;136};137 138class CEdDefLink139{140  U8    tag[512]        format "$DA-P,A=\"Tag Text      :%s\"$\n",141        file[512];142  I64   book;143  U8    aux[512]        format "$DA-P,A=\"Word          :%s\"$\n";144  I64   num             format "$DA-TRM,A=\"Def Num       :%4d\"$\n";145  U8    html_link[512]  format "$DA-P,A=\"Html Link     :%s\"$\n";146  Bool  pop_up          format "$CB,\"PopUp\"$\n",147        quote           format "$CB,\"Quote\"$\n",148        hide;149};150 151class CEdProject152{153  U8    tag[512]        format "$DA-P,A=\"Tag Text      :%s\"$\n",154        file[512]       format "$DA-P,A=\"File          :%s\"$\n";155  I64   book;156  U8    aux[512];157  I64   num;158  U8    html_link[512]  format "$DA-P,A=\"Html Link     :%s\"$\n";159  Bool  pop_up          format "$CB,\"PopUp\"$\n",160        quote           format "$CB,\"Quote\"$\n",161        hide;162};163 164Bool GetLink(I64 type,U8 **_tag,U8 **_link,Bool *_pop_up,165        Bool *_quote,U8 **_html_link)166{167  CEdFileLink *e=CAlloc(sizeof(CEdFileLink));168  Bool res=FALSE;169  if (type>=0) {170    e->num=1;171    switch (type) {172      case LK_FILE:173        if (DocForm(e,,,,ctrl_L_footer)) {174          res=TRUE;175          if (!*e->tag)176            *_tag=StrNew(e->file);177          else178            *_tag=StrNew(e->tag);179          *_link=MStrPrint("FI:%s",e->file);180        }181        break;182      case LK_PLAIN:183        if (DocForm(e,,,,ctrl_L_footer)) {184          res=TRUE;185          if (!*e->tag)186            *_tag=StrNew(e->file);187          else188            *_tag=StrNew(e->tag);189          *_link=MStrPrint("PI:%s",e->file);190        }191        break;192      case LK_FILE_ANCHOR:193        if (DocForm(e,"CEdFileAnchorLink",,,ctrl_L_footer)) {194          res=TRUE;195          if (!*e->tag)196            *_tag=StrNew(e->aux);197          else198            *_tag=StrNew(e->tag);199          *_link=MStrPrint("FA:%s,%s",e->file,e->aux);200        }201        break;202      case LK_FILE_FIND:203        if (DocForm(e,"CEdFileFindLink",,,ctrl_L_footer)) {204          res=TRUE;205          if (e->num==1) {206            if (!*e->tag)207              *_tag=StrNew(e->aux);208            else209              *_tag=StrNew(e->tag);210            *_link=MStrPrint("FF:%s,%s",e->file,e->aux);211          } else {212            if (!*e->tag)213              *_tag=StrNew(e->aux);214            else215              *_tag=StrNew(e->tag);216            *_link=MStrPrint("FF:%s,%s:%d",e->file,e->aux,e->num);217          }218        }219        break;220      case LK_PLAIN_FIND:221        if (DocForm(e,"CEdFileFindLink",,,ctrl_L_footer)) {222          res=TRUE;223          if (e->num==1) {224            if (!*e->tag)225              *_tag=StrNew(e->aux);226            else227              *_tag=StrNew(e->tag);228            *_link=MStrPrint("PF:%s,%s",e->file,e->aux);229          } else {230            if (!*e->tag)231              *_tag=StrNew(e->aux);232            else233              *_tag=StrNew(e->tag);234            *_link=MStrPrint("PF:%s,%s:%d",e->file,e->aux,e->num);235          }236        }237        break;238      case LK_FILE_LINE:239        if (DocForm(e,"CEdFileLineLink",,,ctrl_L_footer)) {240          res=TRUE;241          if (!*e->tag)242            *_tag=StrNew(e->file);243          else244            *_tag=StrNew(e->tag);245          *_link=MStrPrint("FL:%s,%d",e->file,e->num);246        }247        break;248      case LK_PLAIN_LINE:249        if (DocForm(e,"CEdFileLineLink",,,ctrl_L_footer)) {250          res=TRUE;251          if (!*e->tag)252            *_tag=StrNew(e->file);253          else254            *_tag=StrNew(e->tag);255          *_link=MStrPrint("PL:%s,%d",e->file,e->num);256        }257        break;258      case LK_MAN_PAGE:259        if (DocForm(e,"CEdManPageLink",,,ctrl_L_footer)) {260          res=TRUE;261          if (!*e->tag)262            *_tag=StrNew(e->aux);263          else264            *_tag=StrNew(e->tag);265          *_link=MStrPrint("MN:%s",e->aux);266        }267        break;268      case LK_PLACE_ANCHOR:269        if (DocForm(e,"CEdPlaceAnchor",,,ctrl_L_footer)) {270          res=TRUE;271          if (!*e->tag) {272            if (e->hide)273              *_tag=StrNew("");274            else275              *_tag=StrNew(e->aux);276          } else277            *_tag=StrNew(e->tag);278          *_link=StrNew(e->aux);279        }280        break;281      case LK_BIBLE_FIND:282        if (DocForm(e,"CEdBibleLink",,,ctrl_L_footer)) {283          res=TRUE;284          if (!*e->tag)285            *_tag=MStrPrint("%Z,%s",e->book,"ST_BIBLE_BOOKS",e->aux);286          else287            *_tag=StrNew(e->tag);288          *_link=MStrPrint("BF:%Z,%s",e->book,"ST_BIBLE_BOOKS",e->aux);289        }290        break;291      case LK_DEF:292        e->num=-1;293        if (DocForm(e,"CEdDefLink",,,ctrl_L_footer)) {294          res=TRUE;295          if (!*e->tag)296            *_tag=StrNew(e->aux);297          else298            *_tag=StrNew(e->tag);299          if (e->num<0)300            *_link=MStrPrint("DN:%s",e->aux);301          else302            *_link=MStrPrint("DN:%s,%d",e->aux,e->num);303 304        }305        break;306      case LK_HELP_INDEX:307        if (DocForm(e,"CEdManPageLink",,,ctrl_L_footer)) {308          res=TRUE;309          if (!*e->tag)310            *_tag=StrNew(e->aux);311          else312            *_tag=StrNew(e->tag);313          *_link=MStrPrint("HI:%s",e->aux);314        }315        break;316      case LK_ADDR:317        e->num=DFT_ADDR_LINK_BIN_SIZE;318        if (DocForm(e,"CEdAddrLink",,,ctrl_L_footer)) {319          res=TRUE;320          if (e->num==DFT_ADDR_LINK_BIN_SIZE) {321            if (!*e->tag)322              *_tag=StrNew(e->aux);323            else324              *_tag=StrNew(e->tag);325            *_link=MStrPrint("AD:%s",e->aux);326          } else {327            if (!*e->tag)328              *_tag=MStrPrint("%s,%d",e->aux,e->num);329            else330              *_tag=StrNew(e->tag);331            *_link=MStrPrint("AD:%s,%d",e->aux,e->num);332          }333        }334        break;335    }336  }337  if (*e->html_link)338    *_html_link=StrNew(e->html_link);339  else340    *_html_link=NULL;341  if (e->pop_up)342    *_pop_up=TRUE;343  else344    *_pop_up=FALSE;345  if (e->quote)346    *_quote=TRUE;347  else348    *_quote=FALSE;349  Free(e);350  return res;351}352 353U0 EdInsLink()354{355  U8 *tag=NULL,*link=NULL,*st=NULL,*html_link=NULL,*pop_up_st;356  Bool pop_up=FALSE,quote=FALSE;357  I64 type=PopUpLinkType(TRUE);358  if (type>=0) {359    if (GetLink(type,&tag,&link,&pop_up,"e,&html_link)) {360      if (pop_up)361        pop_up_st="+PU";362      else363        pop_up_st="";364      switch (type) {365        case LK_PLACE_ANCHOR:366          if (html_link)367            st=MStrPrint("$AN,\"%$Q\",A=\"%$Q\",HTML=\"%$Q\"$",368                  tag,link,html_link);369          else370            st=MStrPrint("$AN,\"%$Q\",A=\"%$Q\"$",tag,link);371          break;372        default:373          if (html_link)374            st=MStrPrint("$LK%s,\"%$Q\",A=\"%$Q\",HTML=\"%$Q\"$",375                  pop_up_st,tag,link,html_link);376          else377            st=MStrPrint("$LK%s,\"%$Q\",A=\"%$Q\"$",pop_up_st,tag,link);378      }379    }380  }381  if (st) {382    if (quote)383      "%$Q",st;384    else385      "%s",st;386  }387  Free(tag);388  Free(link);389  Free(html_link);390  Free(st);391}392 393I64 PopUpColorType()394{395  I64 i;396  CDoc *doc=DocNew;397  DocPrint(doc,"$PURPLE$$TX+CX,\"Color Type Menu\"$\n"398        "\n$LTBLUE$$MU,\"Foreground\",LE=DOCT_FOREGROUND$\n"399        "$MU,\"Background\",LE=DOCT_BACKGROUND$\n"400        "$MU,\"Default Foreground\",LE=DOCT_DFT_FOREGROUND$\n"401        "$MU,\"Default Background\",LE=DOCT_DFT_BACKGROUND$\n"402        "%s",ctrl_L_footer);403  i=PopUpMenu(doc);404  DocDel(doc);405  return i;406}407 408I64 PopUpPageSettingType()409{410  I64 i;411  CDoc *doc=DocNew;412  DocPrint(doc,"$PURPLE$$TX+CX,\"Page Setting Menu\"$\n"413        "\n$LTBLUE$$MU,\"Page Length\",LE=DOCT_PAGE_LEN$\n"414        "$MU,\"Page Header\",LE=DOCT_HEADER$\n"415        "$MU,\"Page Footer\",LE=DOCT_FOOTER$\n"416        "$MU,\"Left Margin\",LE=DOCT_LEFT_MARGIN$\n"417        "$MU,\"Right Margin\",LE=DOCT_RIGHT_MARGIN$\n"418        "%s",ctrl_L_footer);419  i=PopUpMenu(doc);420  DocDel(doc);421  return i;422}423 424U0 EdInsColor()425{426  I64 type=PopUpColorType,col=DOC_DFT;427  if (type>=0) {428    col=PopUpColor(,FALSE);429    if (col==DOC_DFT)430      "$%Z$",type,"ST_DOC_CMDS";431    else if (col>=0)432      "$%Z,%d$",type,"ST_DOC_CMDS",col;433  }434}435 436class CEdPageSetting1437{438  U8    val[512]        format "$DA-P,A=\"Setting Val:%s\"$\n";439  Bool  winrel;440};441 442class CEdPageSetting2443{444  U8    val[512]        format "$DA-P,A=\"Setting Val:%s\"$\n";445  Bool  winrel          format "$CB,\"Win Relative\"$\n";446};447 448U0 EdInsPageSetting()449{450  I64 type=PopUpPageSettingType;451  CEdPageSetting1 *e=CAlloc(sizeof(CEdPageSetting1));452  if (type>=0) {453    if (type==DOCT_RIGHT_MARGIN||type==DOCT_PAGE_LEN) {454      if (DocForm(e(CEdPageSetting2 *))) {455        if (e->winrel) {456          if (*e->val)457            "$%Z+WR,%s$",type,"ST_DOC_CMDS",e->val;458          else459            "$%Z+WR,0$",type,"ST_DOC_CMDS";460        } else {461          if (*e->val)462            "$%Z,%s$",type,"ST_DOC_CMDS",e->val;463          else464            "$%Z$",type,"ST_DOC_CMDS";465        }466      }467    } else {468      if (DocForm(e)) {469        if (*e->val)470          "$%Z,%s$",type,"ST_DOC_CMDS",e->val;471        else472          "$%Z$",type,"ST_DOC_CMDS";473      }474    }475  }476  Free(e);477}478 479#define WIZ_HIGHLIGHT_ON        (DOCT_ERROR+1)480#define WIZ_HIGHLIGHT_OFF       (DOCT_ERROR+2)481 482I64 PopUpWidgetType()483{484  I64 i;485  CDoc *doc=DocNew;486  DocPrint(doc,"$PURPLE$$TX+CX,\"Text Widgets Menu\"$\n"487        "\n$LTBLUE$$MU,\"Link\",LE=DOCT_LINK$\n"488        "$MU,\"Text\",LE=DOCT_TEXT$\n"489        "$MU,\"Tree Branch\",LE=DOCT_TREE$\n"490        "$MU,\"Color\",LE=DOCT_FOREGROUND$\n"491        "$MU,\"Page Settings\",LE=DOCT_PAGE_LEN$\n"492        "$MU,\"Cursor Movement\",LE=DOCT_CURSOR_MOVEMENT$\n"493        "$MU,\"Macro\",LE=DOCT_MACRO$\n"494        "$MU,\"Bttn\",LE=DOCT_BTTN$\n"495        "$MU,\"Check Box\",LE=DOCT_CHECK_BOX$\n"496        "$MU,\"List\",LE=DOCT_LST$\n"497        "$MU,\"Menu Val\",LE=DOCT_MENU_VAL$\n"498        "$MU,\"Data\",LE=DOCT_DATA$\n"499        "$MU,\"Hex Edit\",LE=DOCT_HEX_ED$\n"500        "$MU,\"Syntax Highlight ON\",LE=WIZ_HIGHLIGHT_ON$\n"501        "$MU,\"Syntax Highlight OFF\",LE=WIZ_HIGHLIGHT_OFF$\n"502        "$MU,\"HTML\",LE=DOCT_HTML_CODE$\n"503        "$MU,\"Song\",LE=DOCT_SONG$\n"504        "%s",ctrl_L_footer);505  i=PopUpMenu(doc);506  DocDel(doc);507  return i;508}509 510class CEdText511{512  U8    tag[512]  format "$DA-P,A=\"Tag Text      :%s\"$\n";513  Bool  left_x    format "$CB,\"Left X\"$\n",514        center_x  format "$CB,\"Center X\"$\n",515        right_x   format "$CB,\"Right X\"$\n",516        margin_rel format "$CB,\"Margin Rel X\"$\n",517        blink     format "$CB,\"Blink\"$\n",518        invert    format "$CB,\"Invert\"$\n",519        underline format "$CB,\"Underline\"$\n",520        tree      format "$CB,\"Tree\"$\n",521        collapsed format "$CB,\"Collapsed\"$\n";522  U8    scroll_x [512]  format "$DA-P,A=\"Scroll X Length Expression:%s\"$\n",523        shift_x  [512]  format "$DA-P,A=\"X Offset Expression       :%s\"$\n",524        shift_y  [512]  format "$DA-P,A=\"Y Offset Expression       :%s\"$\n",525        define_str[512] format "$DA-P,A=\"Define Str                :%s\"$\n",526        html_link[512]  format "$DA-P,A=\"Html Link                 :%s\"$\n";527};528 529U0 EdInsText()530{531  U8 *st,buf[512];532  CEdText *e=CAlloc(sizeof(CEdText));533  if (DocForm(e,,,,ctrl_L_footer)) {534    *buf=0;535    if (e->left_x  )  CatPrint(buf,"+LX");536    if (e->center_x)  CatPrint(buf,"+CX");537    if (e->right_x )  CatPrint(buf,"+RX");538    if (e->margin_rel) CatPrint(buf,"+MRX");539    if (e->blink)     CatPrint(buf,"+BK");540    if (e->invert)    CatPrint(buf,"+IV");541    if (e->underline) CatPrint(buf,"+UL");542    if (e->tree)      CatPrint(buf,"+TR");543    if (e->collapsed) CatPrint(buf,"+C");544    st=MStrPrint("%q",e->tag);545    "$TX%s,\"%$Q\"",buf,st;546    Free(st);547    if (*e->shift_x)548      ",SX=%s",e->shift_x;549    if (*e->shift_y)550      ",SY=%s",e->shift_y;551    if (*e->scroll_x)552      ",SCX=%s",e->scroll_x;553    if (*e->define_str) {554      st=MStrPrint("%q",e->define_str);555      ",D=\"%$Q\"",st;556      Free(st);557    }558    if (*e->html_link) {559      st=MStrPrint("%q",e->html_link);560      ",HTML=\"%$Q\"",st;561      Free(st);562    }563    "$";564  }565  Free(e);566}567 568class CEdSong569{570  U8    tag[512]        format "$DA-P,A=\"Tag Text      :%s\"$\n",571        song[512]       format "$DA-P,A=\"Song          :%s\"$\n";572};573 574U0 EdInsSong()575{576  CEdSong *e=CAlloc(sizeof(CEdSong));577  if (DocForm(e,,,,ctrl_L_footer))578    "$SO,\"%$Q\",A=\"%s\"$",e->tag,e->song;579  Free(e);580}581 582class CEdHtmlCode583{584  U8    tag[512]        format "$DA-P,A=\"Html Code:%s\"$\n";585};586 587U0 EdInsHtml()588{589  CEdHtmlCode *e=CAlloc(sizeof(CEdHtmlCode));590  if (DocForm(e,,,,ctrl_L_footer))591    "$HC,\"%$Q\"$",e->tag;592  Free(e);593}594 595class CEdMacroMenu596{597  U8    tag[512]        format "$DA-P,A=\"Tag Text                  :%s\"$\n",598        left_macro[512] format "$DA-P,A=\"Left Click Macro          :%s\"$\n",599        left_exp[512]   format "$DA-P,A=\"Left Click Expression     :%s\"$\n";600  Bool  popup           format "$CB,\"PopUp\"$\n",601        left_is_in_str  format "$CB,\"Left is InStr\"$\n",602        left_x          format "$CB,\"Left X \"$\n",603        center_x        format "$CB,\"Center X \"$\n",604        right_x         format "$CB,\"Right X \"$\n",605        margin_rel      format "$CB,\"Margin Rel X\"$\n",606        blink           format "$CB,\"Blink\"$\n",607        invert          format "$CB,\"Invert\"$\n",608        underline       format "$CB,\"Underline\"$\n",609        escape          format "$CB,\"Escape\"$\n";610  U8    scroll_x[512]   format "$DA-P,A=\"Scroll X Length Expression:%s\"$\n",611        shift_x[512]    format "$DA-P,A=\"X Offset Expression       :%s\"$\n",612        shift_y[512]    format "$DA-P,A=\"Y Offset Expression       :%s\"$\n";613};614 615U0 EdInsMacroMenu(Bool is_macro)616{617  U8 *st,buf[512];618  CEdMacroMenu *e=CAlloc(sizeof(CEdMacroMenu));619  e->underline=TRUE;620  e->escape=TRUE;621  if (DocForm(e,,,,ctrl_L_footer)) {622    *buf=0;623    if (e->popup)       CatPrint(buf,"+PU-X");624    if (e->left_x  )    CatPrint(buf,"+LX");625    if (e->center_x)    CatPrint(buf,"+CX");626    if (e->right_x )    CatPrint(buf,"+RX");627    if (e->margin_rel)  CatPrint(buf,"+MRX");628    if (e->blink)       CatPrint(buf,"+BK");629    if (e->invert)      CatPrint(buf,"+IV");630    if (!e->underline)  CatPrint(buf,"-UL");631    if (!e->escape)     CatPrint(buf,"-X");632    if (e->left_is_in_str) CatPrint(buf,"+LIS");633    if (*e->tag || is_macro) {634      if (is_macro) {635        if (*e->tag) {636          st=MStrPrint("%q",e->tag);637          "$MA%s,\"%$Q\"",buf,st;638          Free(st);639        } else640          "$MA%s",buf;641      } else {642        st=MStrPrint("%q",e->tag);643        "$MU%s,\"%$Q\"",buf,st;644        Free(st);645      }646      if (*e->left_exp)647        ",LE=%s",e->left_exp;648      if (*e->left_macro) {649        st=MStrPrint("%q",e->left_macro);650        ",LM=\"%$Q\"",st;651        Free(st);652      }653      if (*e->shift_x)654        ",SX=%s",e->shift_x;655      if (*e->shift_y)656        ",SY=%s",e->shift_y;657      if (*e->scroll_x)658        ",SCX=%s",e->scroll_x;659      "$";660    }661  }662  Free(e);663}664 665class CEdBttn666{667  U8    tag[512]   format "$DA-P,A=\"Tag Text      :%s\"$\n";668  Bool  popup      format "$CB,\"PopUp\"$\n",669        left_x     format "$CB,\"Left X \"$\n",670        center_x   format "$CB,\"Center X \"$\n",671        right_x    format "$CB,\"Right X \"$\n",672        margin_rel format "$CB,\"Margin Rel X\"$\n",673        escape     format "$CB,\"Escape\"$\n";674  U8    left_macro[512] format "$DA-P,A=\"Left Click Macro:%s\"$\n";675  Bool  left_is_in_str  format "$CB,\"Left is InStr\"$\n";676  U8    left_exp[512]   format "$DA-P,A=\"Left Click Expression:%s\"$\n";677  Bool  quote           format "$CB,\"Quote\"$\n";678};679 680U0 EdInsBttn()681{682  U8 *st,buf[512];683  CEdBttn *e=CAlloc(sizeof(CEdBttn));684  e->escape=TRUE;685  if (DocForm(e,,,,ctrl_L_footer)) {686    *buf=0;687    if (e->popup)    CatPrint(buf,"+PU-X");688    if (e->left_x  ) CatPrint(buf,"+LX");689    if (e->center_x) CatPrint(buf,"+CX");690    if (e->right_x ) CatPrint(buf,"+RX");691    if (e->margin_rel) CatPrint(buf,"+MRX");692    if (!e->escape)     CatPrint(buf,"-X");693    if (e->left_is_in_str) CatPrint(buf,"+LIS");694    if (*e->tag) {695      if (e->quote) {696        st=MStrPrint("%q",e->tag);697        "$$BT%s,\\\"%$Q\\\"",buf,st;698        Free(st);699        if (*e->left_exp)700          ",LE=%s",e->left_exp;701        if (*e->left_macro) {702          st=MStrPrint("%q",e->left_macro);703          ",LM=\\\"%$Q\\\"",st;704          Free(st);705        }706        "$$";707      } else {708        st=MStrPrint("%q",e->tag);709        "$BT%s,\"%$Q\"",buf,st;710        Free(st);711        if (*e->left_exp)712          ",LE=%s",e->left_exp;713        if (*e->left_macro) {714          st=MStrPrint("%q",e->left_macro);715          ",LM=\"%$Q\"",st;716          Free(st);717        }718        "$";719      }720    }721  }722  Free(e);723}724 725class CEdCursorMovement726{727  U8    left_exp[512]    format "$DA-P,A=\"X Expression (LE):%s\"$\n",728        right_exp[512]   format "$DA-P,A=\"Y Expression (RE):%s\"$\n";729  Bool  left_x   format "$CB,\"Left   X \"$\n",730        center_x format "$CB,\"Center X \"$\n",731        right_x  format "$CB,\"Right  X \"$\n",732        margin_rel format "$CB,\"Margin Rel X\"$\n",733        top_y    format "$CB,\"Top    Y \"$\n",734        center_y format "$CB,\"Center Y \"$\n",735        bottom_y format "$CB,\"Bottom Y \"$\n",736        page_rel format "$CB,\"Page Rel Y\"$\n",737        quote    format "$CB,\"Quote\"$\n";738};739 740U0 EdInsCursorMovement()741{742  U8 buf[512];743  CEdCursorMovement *e=CAlloc(sizeof(CEdCursorMovement));744  if (DocForm(e,,,,ctrl_L_footer)) {745    *buf=0;746    if (e->left_x  )    CatPrint(buf,"+LX");747    if (e->center_x)    CatPrint(buf,"+CX");748    if (e->right_x )    CatPrint(buf,"+RX");749    if (e->margin_rel)  CatPrint(buf,"+MRX");750    if (e->top_y   )    CatPrint(buf,"+TY");751    if (e->center_y)    CatPrint(buf,"+CY");752    if (e->bottom_y)    CatPrint(buf,"+BY");753    if (e->page_rel)    CatPrint(buf,"+PRY");754    if (!*e->left_exp)  CatPrint(buf,"-LE");755    if (!*e->right_exp) CatPrint(buf,"-RE");756    if (e->quote)757      "$";758    "$CM%s",buf;759    if (*e->left_exp)760      ",LE=%s",e->left_exp;761    if (*e->right_exp)762      ",RE=%s",e->right_exp;763    "$";764    if (e->quote)765      "$";766  }767  Free(e);768}769 770class CEdDataNum771{772  U8    fmt_str[512]    format "$DA-P,A=\"Format Str:%s\"$\n";773  I64   len;774  Bool  term            format "$CB,\"Form Field Terminator\"$\n",775        remalloc,776        refresh         format "$CB,\"Refresh Data\"$\n",777        update          format "$CB,\"Update Data\"$\n";778};779 780class CEdDataStr781{782  U8    fmt_str[512]    format "$DA-P,A=\"Format Str:%s\"$\n";783  I64   len             format "$DA,A=\"Length:%d\"$\n";784  Bool  term            format "$CB,\"Zero Terminator\"$\n",785        remalloc        format "$CB,\"Remalloc for Unlimited Length\"$\n",786        refresh         format "$CB,\"Refresh Data\"$\n",787        update          format "$CB,\"Update Data\"$\n";788};789 790U0 EdInsData()791{792  I64 i,type=RT_I64;793  U8 *st,buf[512],raw_type[16];794  CEdDataNum *e=CAlloc(sizeof(CEdDataNum));795  e->term=TRUE;796  e->len=DOCE_LEN_DFT;797  if ((i=PopUpPickDefineSub("ST_NATURAL_TYPES"))>=0) {798    *buf=0;799    i+=RT_I8;800    if (i==RT_F32)801      i=RT_F64;802    if (i==RT_UF32) {//U8 *803      i=DocForm(e(CEdDataStr *),,,,ctrl_L_footer);804      if (e->remalloc) {805        CatPrint(buf,"+M");806        e->term=TRUE;807      } else808        CatPrint(buf,"-P");809    } else {810      type=i;811      i=DocForm(e,,,,ctrl_L_footer);812    }813    if (i) {814      if (type==RT_I64)815        *raw_type=0;816      else817        StrPrint(raw_type,",RT=%Z",type,"ST_RAW_TYPES");818 819      if (!e->term)     CatPrint(buf,"-TRM");820      if (e->refresh)   CatPrint(buf,"+RD");821      if (e->update)    CatPrint(buf,"+UD");822 823      st=MStrPrint("%q",e->fmt_str);824      if (e->remalloc)825        "$$DA%s,A=\\\"%$Q\\\"$$",buf,st;826      else if (e->len==DOCE_LEN_DFT)827        "$$DA%s%s,A=\\\"%$Q\\\"$$",buf,raw_type,st;828      else829        "$$DA%s,LEN=%d%s,A=\\\"%$Q\\\"$$",buf,e->len,raw_type,st;830      Free(st);831    }832  }833  Free(e);834}835 836class CEdCheckBox837{838  U8    tag[512]        format "$DA-P,A=\"Tag Text      :%s\"$\n";839  Bool  refresh         format "$CB,\"Refresh Data\"$\n";840  I64   type            format "$LS,D=\"ST_INT_SIZE_TYPES\"$\n";841};842 843U0 EdInsCheckBox()844{845  U8 *st,buf[512],raw_type[16];846  CEdCheckBox *e=CAlloc(sizeof(CEdCheckBox));847  e->type=RT_I8-RT_I8;848  if (DocForm(e,,,,ctrl_L_footer)) {849    *buf=0;850    e->type+=RT_I8;851    if (e->type==RT_I8)852      *raw_type=0;853    else854      StrPrint(raw_type,",RT=%Z",e->type,"ST_RAW_TYPES");855    if (e->refresh)  CatPrint(buf,"+RD");856    st=MStrPrint("%q",e->tag);857    "$$CB%s%s,\\\"%$Q\\\"$$",buf,raw_type,st;858    Free(st);859  }860  Free(e);861}862 863class CEdLst864{865  U8    tag[512]        format "$DA-P,A=\"Dft Sel    :%s\"$\n",866        define_str[512] format "$DA-P,A=\"Define Str    :%s\"$\n";867  Bool  refresh         format "$CB,\"Refresh Data\"$\n";868  I64   type            format "$LS,D=\"ST_INT_SIZE_TYPES\"$\n";869};870 871U0 EdInsLst()872{873  U8 *st1,*st2,buf[512],raw_type[16];874  CEdLst *e=CAlloc(sizeof(CEdLst));875  e->type=RT_I64-RT_I8;876  if (DocForm(e,,,,ctrl_L_footer)) {877    *buf=0;878    e->type+=RT_I8;879    if (e->type==RT_I64)880      *raw_type=0;881    else882      StrPrint(raw_type,",RT=%Z",e->type,"ST_RAW_TYPES");883    if (e->refresh)  CatPrint(buf,"+RD");884    if (!*e->tag)885      st1=NULL;886    else887      st1=MStrPrint("%q",e->tag);888    st2=MStrPrint("%q",e->define_str);889    if (st1)890      "$$LS%s%s,\\\"%$Q\\\",D=\\\"%$Q\\\"$$",buf,raw_type,st1,st2;891    else892      "$$LS%s%s,D=\\\"%$Q\\\"$$",buf,raw_type,st2;893    Free(st1);894    Free(st2);895  }896  Free(e);897}898 899class CEdHexEd900{901  I64   cnt     format "$DA,A=\"Count:%d\"$\n",902        cols    format "$DA,A=\"Columns:%d\"$\n";903  Bool  zero    format "$CB,\"Zero Based\"$\n",904        refresh format "$CB,\"Refresh Data\"$\n";905};906 907U0 EdInsHexEd()908{909  U8 buf[512];910  CEdHexEd *e=CAlloc(sizeof(CEdHexEd));911  e->cnt=128;912  e->cols=4;913  e->zero=TRUE;914  if (DocForm(e,,,,ctrl_L_footer)) {915    *buf=0;916    if (!e->zero)  CatPrint(buf,"-Z");917    if (e->refresh)  CatPrint(buf,"+RD");918    "$$HX%s,%d,%d$$",buf,e->cnt,e->cols;919  }920  Free(e);921}922 923class CEdBin924{925  U8    tag[512]                format "$DA-P,A=\"Tag Text      :%s\"$\n";926  I64   bin_num                 format "$DA,A=\"Bin Num:%d\"$\n";927  U8    bin_ptr_link_file[512]  format "$DA-P,A=\"File:%s\"$\n";928  I64   bin_ptr_link_bin_num    format "$DA,A=\"File Bin Num:%d\"$\n";929  U8    bin_ptr_link_tag[512]   format "$DA-P,A=\"File Bin Tag:%s\"$\n";930};931 932U0 EdInsBin(I64 bin_num,I64 type)933{934  CEdBin *e=CAlloc(sizeof(CEdBin));935  StrPrint(e->tag,"<%d>",bin_num);936  e->bin_num=bin_num;937  e->bin_ptr_link_bin_num=1;938  if (DocForm(e,,,939        "Note: Normally, you enter no file,\n"940        "just a bin num.  If You enter a\n"941        "file, enter a file bin num or a file\n"942        "bin tag.\n\n",ctrl_L_footer)) {943    if (*e->bin_ptr_link_file) {944      if (*e->bin_ptr_link_tag)945        "$%Z,\"%$Q\",BI=%d,BP=\"%s,%s\"$",type,"ST_DOC_CMDS",e->tag,e->bin_num,946              e->bin_ptr_link_file,e->bin_ptr_link_tag;947      else948        "$%Z,\"%$Q\",BI=%d,BP=\"%s,%d\"$",type,"ST_DOC_CMDS",e->tag,e->bin_num,949              e->bin_ptr_link_file,e->bin_ptr_link_bin_num;950    } else {951      if (DocBinFindNum(DocPut,e->bin_num))952        "$%Z,\"%$Q\",BI=%d$",type,"ST_DOC_CMDS",e->tag,e->bin_num;953      else954        PopUpOk("Invalid Binary Num");955    }956  }957  Free(e);958}959 960class CEdTree961{962  U8    tag[512]        format "$DA-P,A=\"Tag Text      :%s\"$\n";963  I64   indent          format "$DA,A=\"Indention:%d\"$\n";964  Bool  collapsed       format "$CB,\"Collapsed\"$\n";965};966 967U0 EdInsTree()968{969  U8 *st1,*st2,buf[512];970  CEdTree *e=CAlloc(sizeof(CEdTree));971  e->collapsed=TRUE;972  e->indent=2;973  if (DocForm(e,,,,ctrl_L_footer)) {974    *buf=0;975    if (!e->collapsed)  CatPrint(buf,"-C");976    st1=MStrPrint("%q",e->tag);977    st2=MStrPrint("$TR%s,\"%$Q\"$\n$ID,%d$*\n$ID,%d$",978          buf,st1,e->indent,-e->indent);979    DocPrintAtomic(DocPut,"%s",st2);980    Free(st1);981    Free(st2);982  }983  Free(e);984}985 986U0 EdInsWidgetWiz()987{988  I64 type=PopUpWidgetType;989  switch (type) {990    case DOCT_FOREGROUND:991      EdInsColor;992      break;993    case DOCT_PAGE_LEN:994      EdInsPageSetting;995      break;996    case DOCT_LINK:997      EdInsLink;998      break;999    case DOCT_TEXT:1000      EdInsText;1001      break;1002    case DOCT_TREE:1003      EdInsTree;1004      break;1005    case DOCT_MACRO:1006      EdInsMacroMenu(TRUE);1007      break;1008    case DOCT_MENU_VAL:1009      EdInsMacroMenu(FALSE);1010      break;1011    case DOCT_CURSOR_MOVEMENT:1012      EdInsCursorMovement;1013      break;1014    case DOCT_BTTN:1015      EdInsBttn;1016      break;1017    case DOCT_DATA:1018      EdInsData;1019      break;1020    case DOCT_CHECK_BOX:1021      EdInsCheckBox;1022      break;1023    case DOCT_LST:1024      EdInsLst;1025      break;1026    case DOCT_HEX_ED:1027      EdInsHexEd;1028      break;1029    case DOCT_SONG:1030      EdInsSong;1031      break;1032    case WIZ_HIGHLIGHT_ON:1033      "$HL,1$";1034      break;1035    case WIZ_HIGHLIGHT_OFF:1036      "$HL,0$";1037      break;1038    case DOCT_HTML_CODE:1039      EdInsHtml;1040  }1041}1042 1043#define EST_SPRITE              01044#define EST_SPRITE_PTR          11045#define EST_DUP_SPRITE          21046#define EST_SPRITE_SIZE         31047#define EST_SPRITE_MACRO        41048#define EST_SPRITE_MENU         51049#define EST_SPRITE_LINK         61050 1051I64 PopUpSpriteType()1052{1053  I64 i;1054  CDoc *doc=DocNew;1055  DocPrint(doc,"$PURPLE$$TX+CX,\"Graphic Sprite Resource Menu\"$\n"1056        "$LK+PU+CX,\"Click for Help\",A=\"FI:::/Doc/Resource.DD.Z\"$\n\n"1057        "$LTBLUE$$MU,\"Make Sprite\",LE=EST_SPRITE$$FG$\t "1058        "Start by making a sprite.\n"1059        "$LTBLUE$$MU,\"Ptr to Sprite\",LE=EST_SPRITE_PTR$$FG$\t "1060        "Insert pointer into src code.\n"1061        "$LTBLUE$$MU,\"Duplicate Sprite\",LE=EST_DUP_SPRITE$$FG$ "1062        "Make dup image for in a doc.\n"1063        "$LTBLUE$$MU,\"Sprite Size\",LE=EST_SPRITE_SIZE$$FG$\t "1064        "Insert size of a sprite into src code.\n"1065        "$LTBLUE$$MU,\"Sprite Macro\",LE=EST_SPRITE_MACRO$$FG$\t "1066        "Create icon with auto-text payload.\n"1067        "$LTBLUE$$MU,\"Sprite Menu Item\",LE=EST_SPRITE_MENU$$FG$ "1068        "Create icon with numeric payload.\n"1069        "$LTBLUE$$MU,\"Sprite Link\",LE=EST_SPRITE_LINK$$FG$\t "1070        "Create icon with link payload.\n\n"1071        "$LTBLUE$$MU,\"Abort\",LE=DOCM_CANCEL$\n\n");1072  i=PopUpMenu(doc);1073  DocDel(doc);1074  return i;1075}1076 1077class CEdMacroSprite1078{1079  U8    tag[512]        format "$DA-P,A=\"Tag Text       :%s\"$\n",1080        exp[512]        format "$DA-P,A=\"Macro          :%s\"$\n";1081  Bool  escape          format "$CB,\"Escape\"$\n",1082        popup           format "$CB,\"PopUp\"$\n",1083        is_in_str               format "$CB,\"InStr\"$\n";1084};1085 1086class CEdMenuSprite1087{1088  U8    tag[512]        format "$DA-P,A=\"Tag Text       :%s\"$\n",1089        exp[512]        format "$DA-P,A=\"Expression     :%s\"$\n";1090  Bool  escape          format "$CB,\"Escape\"$\n",1091        popup,1092        is_in_str;1093};1094 1095U8 *EdSpriteLink(Bool *_pop_up,U8 **_html_link)1096{1097  U8 *res=NULL,*tag=NULL,*link=NULL;1098  Bool quote=FALSE;1099  I64 type=PopUpLinkType(FALSE);1100  *_html_link=NULL;1101  if (type>=0 && GetLink(type,&tag,&link,_pop_up,"e,_html_link))1102    res=MStrPrint("\"%$Q\",A=\"%$Q\"",tag,link);1103  Free(tag);1104  Free(link);1105  return res;1106}1107 1108U8 *EdSprite(I64 bin_num)1109{1110  I64 type=PopUpSpriteType;1111  Bool pop_up;1112  U8 *st,*st1=NULL,*st2=NULL,buf[1024],*html_link=NULL;1113  CEdMacroSprite *e=CAlloc(sizeof(CEdMacroSprite));1114  *buf=0;1115  switch (type) {1116    case EST_SPRITE:1117      st1=MStrPrint("\"<%d>\"",bin_num);1118      break;1119    case EST_SPRITE_MACRO:1120      e->escape=TRUE;1121      if (DocForm(e,,,,ctrl_L_footer)) {1122        CatPrint(buf,"+UL");1123        if (e->is_in_str) CatPrint(buf,"+LIS");1124        if (e->popup)   CatPrint(buf,"+PU");1125        if (e->escape)  CatPrint(buf,"+X");1126        st=MStrPrint("%q",e->exp);1127        st1=MStrPrint("\"%$Q\",LM=\"%$Q\"",e->tag,st);1128        Free(st);1129      }1130      break;1131    case EST_SPRITE_MENU:1132      e->escape=TRUE;1133      if (DocForm(e,"CEdMenuSprite",,,ctrl_L_footer)) {1134        if (e->escape)  CatPrint(buf,"+X");1135        st1=MStrPrint("\"%$Q\",LE=%s",e->tag,e->exp);1136      }1137      break;1138    case EST_SPRITE_LINK:1139      CatPrint(buf,"+L");1140      st1=EdSpriteLink(&pop_up,&html_link);1141      if (pop_up)1142        CatPrint(buf,"+PU");1143      break;1144    case EST_SPRITE_PTR:1145      EdInsBin(--bin_num,DOCT_INS_BIN);1146      break;1147    case EST_SPRITE_SIZE:1148      EdInsBin(--bin_num,DOCT_INS_BIN_SIZE);1149      break;1150    case EST_DUP_SPRITE:1151      EdInsBin(--bin_num,DOCT_SPRITE);1152      break;1153  }1154  if (st1) {1155    if (html_link)1156      st2=MStrPrint("$SP%s,%s,HTML=\"%$Q\",BI=%d$",buf,st1,html_link,bin_num);1157    else1158      st2=MStrPrint("$SP%s,%s,BI=%d$",buf,st1,bin_num);1159    Free(st1);1160  }1161  Free(e);1162  Free(html_link);1163  return st2;1164}1165