home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Editor / DVD!FX17.LHA / FrexxEd / fpl / ZMacs.FPL < prev   
Encoding:
Text File  |  1995-05-31  |  8.9 KB  |  288 lines

  1. // $VER: ZMacs.FPL 1.6 (30.05.95) © Jesper Skov
  2.  
  3.  
  4. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Ideas ««
  5. // M-y scroll through old yanks (kill ring).
  6. // M-t transpose words
  7.  
  8. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Support routines ««
  9. export int __yankID = GetBufferID("DefaultBlock");  // ID of the block buffer
  10.  
  11. int __killCounter; 
  12. void export emacsBsWord()
  13. {
  14.   int thisBuffer;
  15.   int end_line = ReadInfo("line");
  16.   int end_byte = ReadInfo("byte_position");
  17.   int tempBlock = BlockCreate("__bsTempBlock");
  18.  
  19.   if (ReadInfo("counter")!=(__killCounter+1)){
  20.     Clean("Clear(__yankID);");}
  21.   __killCounter = ReadInfo("counter");
  22.  
  23.   CursorLeftWord();
  24.   BlockCut(tempBlock, GetCursor(end_byte, end_line), end_line, GetCursor(end_byte=ReadInfo("byte_position")), end_line=ReadInfo("line"));
  25.  
  26.   thisBuffer = CurrentBuffer(__yankID);
  27.   GotoLine(1);
  28.   BlockPaste(tempBlock);
  29.   CurrentBuffer(thisBuffer);
  30.  
  31.   GotoLine(end_line, end_byte);
  32.  
  33.   Kill(tempBlock);
  34. }
  35.  
  36. void export emacsDelWord()
  37. {
  38.   int beg_line = ReadInfo("line");
  39.   int beg_byte = ReadInfo("byte_position");
  40.  
  41.   if (ReadInfo("counter")!=(__killCounter+1)){
  42.     Clean("Clear(__yankID);");}
  43.   __killCounter = ReadInfo("counter");
  44.  
  45.   CursorRightWord();
  46.   BlockCutAppend(__yankID, GetCursor(ReadInfo("byte_position")), ReadInfo("line"), GetCursor(beg_byte, beg_line), beg_line);
  47.  
  48.   GotoLine(beg_line, beg_byte);
  49. }   
  50.  
  51. /*
  52.  * Emacs kill-line embryo.
  53.  * Killed lines will get copied into the block buffer before deleted. Note that
  54.  * the first killed line will first clear the block buffer, and kills following
  55.  * that one will append them to the current one.
  56.  *
  57.  * Paste the buffer with BlockPaste() or BlockPasteRect() just as usual blocks.
  58.  *
  59.  * Coded by Daniel Stenberg
  60.  */
  61.  
  62. void export kill_line()
  63. {
  64.   int this_count = ReadInfo("counter");
  65.   if ((this_count != __killCounter)&&(this_count != __killCounter+1)) {
  66.     // We were not invoked this/last action, clear the buffer
  67.     Clean("Clear(__yankID);");                // Clear the block without any hooks
  68.   }
  69.   __killCounter = ReadInfo("counter");
  70.   if(Isnewline(GetChar())) {                // standing on a newline character
  71.     int oldID = GetEntryID();                // get current entry
  72.     Delete();                                // delete the newline character
  73.     CurrentBuffer(__yankID);                // switch to the block buffer
  74.     GotoLine(-1);                            // jump to the bottom
  75.     GotoLine(ReadInfo("line"),ReadInfo("line_length")); // jump to end of line
  76.     Output("\n");                            // add a newline to the buffer
  77.     CurrentBuffer(oldID);                    // switch back to previous buffer
  78.   } else {                                    // delete to end of line
  79.     int curr_col = ReadInfo("column");        // get current column
  80.     int end_col = GetCursor(ReadInfo("line_length")); // get column of the end of line
  81.     int curr_line = ReadInfo("line");        // get line number
  82.  
  83.     BlockCopyAppend(__yankID, end_col, curr_line, curr_col, curr_line);  // append the line to the block
  84.  
  85.     DeleteEol();                            // delete to the end of line
  86.   }
  87. }
  88.  
  89. int export __yankCounter; 
  90.  
  91. /*
  92. string __killRing[16];
  93.  
  94. int nextEntry=0;                            // Where to fill kill data next time
  95. int prevEntry;                                // Last exchanged at prev yankPop call
  96. int wrapped;
  97. int __yankPopCounter; 
  98. int __yankCounter; 
  99. void export yankPop()
  100. {
  101.   if (ReadInfo("counter")+1!=__yankCounter){
  102.     DisplayBeep();
  103.     ReturnStatus("Last command was not a yank!");
  104.   } else {
  105.     if (ReadInfo("counter")+1==__yankPopCounter){
  106.       if ((!wrapped && !prevEntry) || (wrapped && ((prevEntry-1) % 15)==firstEntry)){
  107.         DisplayBeep();
  108.         ReturnStatus("No more entries in kill ring!")
  109.         exit();
  110.       } else {
  111.         prevEntry--;
  112.  
  113.  
  114.       }
  115.     }
  116.   }
  117. }
  118. */
  119.  
  120. void export emacsOpenFile(int viewControl)
  121. {
  122.   int old_popup = ReadInfo("popup_view");
  123.   SetInfo(0,"popup_view",viewControl);
  124.   Open("");
  125.   SetInfo(0,"popup_view",old_popup);
  126. }
  127.  
  128.  
  129. void export emacsIncludeFile()
  130. {
  131.   int old_popup = ReadInfo("popup_view");
  132.   SetInfo(0,"popup_view",0);
  133.   InsertFile("");
  134.   SetInfo(0,"popup_view",old_popup);
  135. }
  136.  
  137.  
  138.  
  139. void export emacsGotoBuffer(int viewControl)
  140. {
  141.   int id=PromptBuffer("",1);
  142.   if (id){
  143.     Activate(id,viewControl);
  144.     CurrentBuffer(id);
  145.   }
  146. }
  147.  
  148.  
  149. void export emacsTranspose()
  150. {
  151.   int letter=GetChar();
  152.  
  153.   if (Isnewline(letter)){
  154.     CursorLeft();
  155.     letter=GetChar();
  156.     Delete();
  157.     CursorLeft();
  158.     Output(itoc(letter));
  159.     CursorRight();
  160.   } else {
  161.     Delete();
  162.     CursorLeft();
  163.     Output(itoc(letter));
  164.     if (Isnewline(GetChar())){                // Fix if moved to prev line
  165.       CursorRight();
  166.     }
  167.   }
  168. }
  169.  
  170. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Configuration ««
  171.  
  172. string metaKey = "amiga";                            // Default/0
  173.  
  174. ConstructInfo("emacs_meta","","","GCW(system)","Amiga|Escape|Alt",0,0);
  175.  
  176. if (ReadInfo("emacs_meta")==1){
  177.   metaKey = "'esc'";                                // 1=Esc
  178. } else if (ReadInfo("emacs_meta")==2){
  179.   metaKey = "alt";                                    // 2=alt
  180. }
  181.  
  182. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Cursor movement ««
  183. AssignKey("CursorLeft();",    "control b");
  184. AssignKey("CursorRight();",    "control f");
  185. AssignKey("CursorLeftWord();", joinstr(metaKey," b"));
  186. AssignKey("CursorRightWord();",    "'esc' f");
  187.  
  188. AssignKey("CursorDown();",    "control n");
  189. AssignKey("CursorUp();",    "control p");
  190.  
  191. AssignKey("PageUp();",        "control V");
  192. AssignKey("PageUp();",        joinstr(metaKey," v"));
  193. AssignKey("PageDown();",    "control v");
  194. AssignKey("GotoLine(ReadInfo(\"line\"));","control a");
  195. AssignKey("GotoLine(ReadInfo(\"line\"),ReadInfo(\"line_length\"));","control e");
  196. AssignKey("                                // Next view
  197. {
  198.   int id=PrevView();
  199.  
  200.   Activate(id, 0);CurrentBuffer(id);
  201. }",                            "control x o");
  202. AssignKey("                                // Previous view
  203. {
  204.   int id=NextView();
  205.  
  206.   Activate(id, 0);CurrentBuffer(id);
  207. }",                            "control x O");
  208. AssignKey("GotoLine();",    "control c g");
  209. AssignKey("GotoLine(1,0);",    joinstr(metaKey," <"));
  210. AssignKey("Bottom();End();",joinstr(metaKey," >"));
  211.  
  212. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Editing ««
  213. AssignKey("kill_line();",    "control k");
  214. AssignKey("DeleteEol();",    "shift 'Del'");
  215. AssignKey("Backspace(ReadInfo(\"byte_position\"));","shift 'backspace'");
  216. AssignKey("
  217. {
  218.   if (ReadInfo(\"line_length\")==1){
  219.     kill_line();                         // Don't overdo it if the line is
  220.   } else {                                 // is empty
  221.     GotoLine(ReadInfo(\"line\"));kill_line();kill_line();
  222.   }
  223. }",                            "control K");
  224.  
  225. AssignKey("Delete();",        "control d");
  226. AssignKey("emacsDelWord();",    joinstr(metaKey," d"));
  227. AssignKey("emacsBsWord();",joinstr(metaKey," 'backspace'"));
  228.  
  229. AssignKey("Undo();",        "control x u");
  230.  
  231. AssignKey("CenterLine(0);", joinstr(metaKey," s"), "!block_exist");
  232. AssignKey("CenterBlock();", joinstr(metaKey," s"), "block_exist");
  233.  
  234. AssignKey("emacsTranspose();","control t");
  235.  
  236. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Block control ««
  237. AssignKey("BlockMark();",    "control 'space'");
  238. AssignKey("BlockCopy();",    "control W");
  239. AssignKey("BlockCopy();",    joinstr(metaKey," w"));
  240. AssignKey("BlockCut();",    "control w");
  241. AssignKey("__yankCounter=ReadInfo(\"counter\");BlockPaste();",    "control y");
  242.  
  243. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Macro control ««
  244. AssignKey("if (!ReadInfo(\"macro_on\"))
  245.              {MacroRecord(1);};","control x (");
  246. AssignKey("if (ReadInfo(\"macro_on\")){MacroRecord(1,\"\",\"control x e\");};","control x )");
  247.  
  248.  
  249. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Buffer control ««
  250. AssignKey("SaveChanges();",    "control x control s");
  251. AssignKey("SaveAs();",        "control x control w");
  252. AssignKey("emacsOpenFile(0);","control x control f");
  253. AssignKey("emacsOpenFile(1);","control x 4 f");
  254. AssignKey("emacsIncludeFile();","control x i");
  255. AssignKey("Kill(GetBufferID());","control x k");
  256. AssignKey("QuitAll();",        "control x control c");
  257. AssignKey("emacsGotoBuffer(0);","control x b");
  258. AssignKey("emacsGotoBuffer(1);","control x 4 b");
  259.  
  260. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» View control ««
  261. AssignKey("MaximizeView();","control x 1");
  262. AssignKey("RemoveView();",    "control x 0");
  263. AssignKey("CurrentBuffer(Activate(DuplicateEntry(),1));","control x 2");
  264. AssignKey("CenterView();",    "control l");
  265.  
  266. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Folder control ««
  267. AssignKey("FoldShow();", "control c control s");     // SHOW
  268. AssignKey("FoldShow(0);", "control c control S e");  // (e)xclusive
  269. AssignKey("FoldShow(-1);", "control c control S a"); // (a)ll
  270. AssignKey("FoldDelete();", "control c control S d"); // (d)elete
  271. AssignKey("FoldHide();", "control c control h");     // HIDE
  272. AssignKey("FoldHide(0);", "control c control H e");  // (e)xclusive
  273. AssignKey("FoldHide(-1);", "control c control H a"); // (a)ll
  274. AssignKey("Fold();", "control c control H n");       // (n)ew
  275.  
  276. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Replace ««
  277. AssignKey("ReplaceSet();", joinstr(metaKey, " shift 5"));
  278.  
  279. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Miscellaneous ««
  280. AssignKey("SetInfo(-1,\"wall_right\",ReadInfo(\"column\"));","control x f");
  281.                                                 // Set wall_right
  282.  
  283. AssignKey("ISpell();", joinstr(metaKey, " shift 4")); // ISpell
  284.  
  285. AssignKey("Prompt();",        joinstr(metaKey," x"));
  286.  
  287. AssignKey("Iconify();",        "control z");
  288.