home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Editor / FREDV19A.LHA / FrexxEd / fpl / AsmMode.FPL < prev    next >
Encoding:
Text File  |  1995-07-27  |  4.8 KB  |  167 lines

  1. // $Id: AsmMode.FPL 1.6 1995/07/27 17:16:39 jskov Exp $
  2. // $VER: AsmMode.FPL 1.0 (15.06.95) © Jesper Skov
  3.  
  4. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» AsmModePrefs() ««
  5. void export AsmModePrefs()
  6. {
  7.   PromptInfo(-1,"AsmMode preferences",-1,-1,
  8.    "Asm_comment_start_skip",
  9.    "Asm_comment_start",
  10.    "Asm_comment_end",
  11.    "Asm_line_comment_start",
  12.    "Asm_line_comment_body",
  13.    "Asm_line_comment_end",
  14.    "Asm_tab_size",
  15.    "Asm_comment_column",
  16.    "Asm_auto_indent"
  17.    );
  18. }
  19.  
  20. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» FindMatch() ««
  21. // This function is used when searching for registers.
  22. //»»»»»»»»»»»»»»»»»»»»»»»»»»
  23. /*
  24. string FindMatch(string src)
  25. {
  26.   if (0==Search(src, "=flbw+")){            // Use search until b+ in ReplaceMatch()
  27.     if ((ReadInfo("line")>=ReadInfo("block_end_y"))&&(ReadInfo("column")>=ReadInfo("block_end_x"))) return ""; // BUG FIXER
  28.  
  29.     string result="";                        // gets fixed!
  30.     CursorLeft();
  31.     result=ReplaceMatch(src, "\\&", -1, "=flw+");
  32.     CursorRight(strlen(result));
  33.     return result
  34.   } else return "";
  35.  
  36. }
  37. */
  38.  
  39. string FindMatch2(string src)                // Use BUG to gain speed!
  40. {
  41.   string result=ReplaceMatch(src, "\\&", -1, "=flw+");
  42.   if ((ReadInfo("line")>=ReadInfo("block_end_y"))&&(ReadInfo("column")>=ReadInfo("block_end_x"))) return "";
  43.   CursorRight(strlen(result));
  44.   return result
  45. }
  46.  
  47. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» UsedRegisters() ««
  48. export void UsedRegisters()
  49.  
  50. {
  51.   if (!ReadInfo("block_exist")){            // Make sure that a block is marked
  52.     ReturnStatus("No block marked!");
  53.   } else {
  54.     int registers[16];
  55.     int beg,end, i, used;
  56.     string match;
  57.     string output="Used registers:";
  58.     int x=ReadInfo("byte_position");
  59.     int y=ReadInfo("line");
  60.     int oldVis=Visible(0);
  61.  
  62.     if (ReadInfo("block_exist")==1) BlockMark(2); // Release block if needed
  63.  
  64.     GotoLine(ReadInfo("block_begin_y"),ReadInfo("block_begin_x")); // start of block
  65.  
  66.     // Search for "Rx" or "Rx-Ry"
  67.     while (strlen(match=FindMatch2("(\\<[da][01234567]-[da][01234567]\\>)|(\\<[da][01234567]\\>)"))){
  68.       beg=match[1]-'0'+8*(match[0]=='a'||match[0]=='A');
  69.       if (strlen(match)==2){
  70.         // A single register
  71.         registers[beg]=1;
  72.       } else {
  73.         end=match[4]-'0'+8*(match[3]=='a'||match[3]=='A');
  74.         while (beg<=end) registers[beg++]=1;
  75.       }
  76.     }
  77.  
  78.     for (i=0;i<8;i++)
  79.     if (registers[i]){
  80.       output+=" D"+itoc(0x30+i);
  81.       used++;
  82.     }
  83.  
  84.     for (i=8;i<16;i++)
  85.     if (registers[i]){
  86.       output+=" A"+itoc(0x28+i);
  87.       used++;
  88.     }
  89.  
  90.     if (!used) output+=" NONE";
  91.  
  92.     GotoLine(y,x);
  93.  
  94.     Visible(oldVis);
  95.  
  96.     ReturnStatus(output);
  97.   }
  98. }
  99.  
  100. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» autoIndent() ««
  101. void export autoIndent()
  102. {
  103.   if (ReadInfo("byte_position")){
  104.     string s = GetLine();
  105.     int i;
  106.  
  107.     for(i=0;(!Isnewline(s[i])&&(Isspace(s[i])));i++);
  108.  
  109.     if (Isnewline(s[i])){                        // Empty line?
  110.       // Empty line
  111.       GotoLine(ReadInfo("line"));
  112.       DeleteEol();
  113.       Output("\n");
  114.     } else
  115.       // non-empty line
  116.       Output("\n"+substr(s,0,i));
  117.   } else
  118.     Output("\n");
  119. }
  120.  
  121. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» AssemblerModeInit() ««
  122. export void AsmModeInit()
  123. {
  124.   // Set comment strings for assembler mode
  125.   SetInfo(-1,"comment_start_skip",ReadInfo("Asm_comment_start_skip"));
  126.   SetInfo(-1,"comment_start",ReadInfo("Asm_comment_start"));
  127.   SetInfo(-1,"comment_end",ReadInfo("Asm_comment_end"));
  128.   SetInfo(-1,"line_comment_start",ReadInfo("Asm_line_comment_start"));
  129.   SetInfo(-1,"line_comment_body",ReadInfo("Asm_line_comment_body"));
  130.   SetInfo(-1,"line_comment_end",ReadInfo("Asm_line_comment_end"));
  131.   SetInfo(-1,"comment_column",ReadInfo("Asm_comment_column")); // set comment col
  132.   SetInfo(-1,"comment_mode",1);                // enable comment mode
  133.  
  134.   SetInfo(-1,"comment_begin",";");            // Set fold comment
  135.  
  136.   SetInfo(-1,"tab_size",ReadInfo("Asm_tab_size")); // Set tabulator size
  137.  
  138.   SetInfo(-1,"asm_mode",1);                    // enable self
  139. }
  140.  
  141. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Key bindings ««
  142. AssignKey("UsedRegisters();","control c r", "asm_mode");
  143. AssignKey("autoIndent();","'enter'","asm_mode&Asm_auto_indent");
  144.  
  145. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» AsmMode preferences ««
  146. ConstructInfo("Asm_comment_start_skip","","","WHGS","",0,0,"; *");
  147. ConstructInfo("Asm_comment_start","","","WHGS","",0,0,"; ");
  148. ConstructInfo("Asm_comment_end","","","WHGS","",0,0,"");
  149. ConstructInfo("Asm_line_comment_body","","","WHGS","",0,0,"»");
  150. ConstructInfo("Asm_line_comment_end","","","WHGS","",0,0,"««");
  151. ConstructInfo("Asm_line_comment_start","","","WHGS","",0,0,"*");
  152.  
  153. ConstructInfo("Asm_comment_column","","","WHGI","",0,9999,49);
  154.  
  155. ConstructInfo("Asm_tab_size","","","WHGI","",0,9999,8);
  156.  
  157. ConstructInfo("Asm_auto_indent","","","WBGH","",0,1,1);
  158.  
  159. ConstructInfo("asm_mode","","","LBH","",0,1,0);
  160.  
  161. AddMode(0,"asm_mode", "", "");                // Add as minor mode
  162.  
  163. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» AsmMode menu ««
  164. MenuAdd("s", "AsmMode...", "AsmModePrefs();", "", 6,6,-1); // Add to PackageSettings
  165. MenuBuild();
  166.  
  167.