home *** CD-ROM | disk | FTP | other *** search
- // $VER: ZMacs.FPL 1.6 (30.05.95) © Jesper Skov
-
-
- //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Ideas ««
- // M-y scroll through old yanks (kill ring).
- // M-t transpose words
-
- //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Support routines ««
- export int __yankID = GetBufferID("DefaultBlock"); // ID of the block buffer
-
- int __killCounter;
- void export emacsBsWord()
- {
- int thisBuffer;
- int end_line = ReadInfo("line");
- int end_byte = ReadInfo("byte_position");
- int tempBlock = BlockCreate("__bsTempBlock");
-
- if (ReadInfo("counter")!=(__killCounter+1)){
- Clean("Clear(__yankID);");}
- __killCounter = ReadInfo("counter");
-
- CursorLeftWord();
- BlockCut(tempBlock, GetCursor(end_byte, end_line), end_line, GetCursor(end_byte=ReadInfo("byte_position")), end_line=ReadInfo("line"));
-
- thisBuffer = CurrentBuffer(__yankID);
- GotoLine(1);
- BlockPaste(tempBlock);
- CurrentBuffer(thisBuffer);
-
- GotoLine(end_line, end_byte);
-
- Kill(tempBlock);
- }
-
- void export emacsDelWord()
- {
- int beg_line = ReadInfo("line");
- int beg_byte = ReadInfo("byte_position");
-
- if (ReadInfo("counter")!=(__killCounter+1)){
- Clean("Clear(__yankID);");}
- __killCounter = ReadInfo("counter");
-
- CursorRightWord();
- BlockCutAppend(__yankID, GetCursor(ReadInfo("byte_position")), ReadInfo("line"), GetCursor(beg_byte, beg_line), beg_line);
-
- GotoLine(beg_line, beg_byte);
- }
-
- /*
- * Emacs kill-line embryo.
- * Killed lines will get copied into the block buffer before deleted. Note that
- * the first killed line will first clear the block buffer, and kills following
- * that one will append them to the current one.
- *
- * Paste the buffer with BlockPaste() or BlockPasteRect() just as usual blocks.
- *
- * Coded by Daniel Stenberg
- */
-
- void export kill_line()
- {
- int this_count = ReadInfo("counter");
- if ((this_count != __killCounter)&&(this_count != __killCounter+1)) {
- // We were not invoked this/last action, clear the buffer
- Clean("Clear(__yankID);"); // Clear the block without any hooks
- }
- __killCounter = ReadInfo("counter");
- if(Isnewline(GetChar())) { // standing on a newline character
- int oldID = GetEntryID(); // get current entry
- Delete(); // delete the newline character
- CurrentBuffer(__yankID); // switch to the block buffer
- GotoLine(-1); // jump to the bottom
- GotoLine(ReadInfo("line"),ReadInfo("line_length")); // jump to end of line
- Output("\n"); // add a newline to the buffer
- CurrentBuffer(oldID); // switch back to previous buffer
- } else { // delete to end of line
- int curr_col = ReadInfo("column"); // get current column
- int end_col = GetCursor(ReadInfo("line_length")); // get column of the end of line
- int curr_line = ReadInfo("line"); // get line number
-
- BlockCopyAppend(__yankID, end_col, curr_line, curr_col, curr_line); // append the line to the block
-
- DeleteEol(); // delete to the end of line
- }
- }
-
- int export __yankCounter;
-
- /*
- string __killRing[16];
-
- int nextEntry=0; // Where to fill kill data next time
- int prevEntry; // Last exchanged at prev yankPop call
- int wrapped;
- int __yankPopCounter;
- int __yankCounter;
- void export yankPop()
- {
- if (ReadInfo("counter")+1!=__yankCounter){
- DisplayBeep();
- ReturnStatus("Last command was not a yank!");
- } else {
- if (ReadInfo("counter")+1==__yankPopCounter){
- if ((!wrapped && !prevEntry) || (wrapped && ((prevEntry-1) % 15)==firstEntry)){
- DisplayBeep();
- ReturnStatus("No more entries in kill ring!")
- exit();
- } else {
- prevEntry--;
-
-
- }
- }
- }
- }
- */
-
- void export emacsOpenFile(int viewControl)
- {
- int old_popup = ReadInfo("popup_view");
- SetInfo(0,"popup_view",viewControl);
- Open("");
- SetInfo(0,"popup_view",old_popup);
- }
-
-
- void export emacsIncludeFile()
- {
- int old_popup = ReadInfo("popup_view");
- SetInfo(0,"popup_view",0);
- InsertFile("");
- SetInfo(0,"popup_view",old_popup);
- }
-
-
-
- void export emacsGotoBuffer(int viewControl)
- {
- int id=PromptBuffer("",1);
- if (id){
- Activate(id,viewControl);
- CurrentBuffer(id);
- }
- }
-
-
- void export emacsTranspose()
- {
- int letter=GetChar();
-
- if (Isnewline(letter)){
- CursorLeft();
- letter=GetChar();
- Delete();
- CursorLeft();
- Output(itoc(letter));
- CursorRight();
- } else {
- Delete();
- CursorLeft();
- Output(itoc(letter));
- if (Isnewline(GetChar())){ // Fix if moved to prev line
- CursorRight();
- }
- }
- }
-
- //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Configuration ««
-
- string metaKey = "amiga"; // Default/0
-
- ConstructInfo("emacs_meta","","","GCW(system)","Amiga|Escape|Alt",0,0);
-
- if (ReadInfo("emacs_meta")==1){
- metaKey = "'esc'"; // 1=Esc
- } else if (ReadInfo("emacs_meta")==2){
- metaKey = "alt"; // 2=alt
- }
-
- //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Cursor movement ««
- AssignKey("CursorLeft();", "control b");
- AssignKey("CursorRight();", "control f");
- AssignKey("CursorLeftWord();", joinstr(metaKey," b"));
- AssignKey("CursorRightWord();", "'esc' f");
-
- AssignKey("CursorDown();", "control n");
- AssignKey("CursorUp();", "control p");
-
- AssignKey("PageUp();", "control V");
- AssignKey("PageUp();", joinstr(metaKey," v"));
- AssignKey("PageDown();", "control v");
- AssignKey("GotoLine(ReadInfo(\"line\"));","control a");
- AssignKey("GotoLine(ReadInfo(\"line\"),ReadInfo(\"line_length\"));","control e");
- AssignKey(" // Next view
- {
- int id=PrevView();
-
- Activate(id, 0);CurrentBuffer(id);
- }", "control x o");
- AssignKey(" // Previous view
- {
- int id=NextView();
-
- Activate(id, 0);CurrentBuffer(id);
- }", "control x O");
- AssignKey("GotoLine();", "control c g");
- AssignKey("GotoLine(1,0);", joinstr(metaKey," <"));
- AssignKey("Bottom();End();",joinstr(metaKey," >"));
-
- //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Editing ««
- AssignKey("kill_line();", "control k");
- AssignKey("DeleteEol();", "shift 'Del'");
- AssignKey("Backspace(ReadInfo(\"byte_position\"));","shift 'backspace'");
- AssignKey("
- {
- if (ReadInfo(\"line_length\")==1){
- kill_line(); // Don't overdo it if the line is
- } else { // is empty
- GotoLine(ReadInfo(\"line\"));kill_line();kill_line();
- }
- }", "control K");
-
- AssignKey("Delete();", "control d");
- AssignKey("emacsDelWord();", joinstr(metaKey," d"));
- AssignKey("emacsBsWord();",joinstr(metaKey," 'backspace'"));
-
- AssignKey("Undo();", "control x u");
-
- AssignKey("CenterLine(0);", joinstr(metaKey," s"), "!block_exist");
- AssignKey("CenterBlock();", joinstr(metaKey," s"), "block_exist");
-
- AssignKey("emacsTranspose();","control t");
-
- //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Block control ««
- AssignKey("BlockMark();", "control 'space'");
- AssignKey("BlockCopy();", "control W");
- AssignKey("BlockCopy();", joinstr(metaKey," w"));
- AssignKey("BlockCut();", "control w");
- AssignKey("__yankCounter=ReadInfo(\"counter\");BlockPaste();", "control y");
-
- //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Macro control ««
- AssignKey("if (!ReadInfo(\"macro_on\"))
- {MacroRecord(1);};","control x (");
- AssignKey("if (ReadInfo(\"macro_on\")){MacroRecord(1,\"\",\"control x e\");};","control x )");
-
-
- //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Buffer control ««
- AssignKey("SaveChanges();", "control x control s");
- AssignKey("SaveAs();", "control x control w");
- AssignKey("emacsOpenFile(0);","control x control f");
- AssignKey("emacsOpenFile(1);","control x 4 f");
- AssignKey("emacsIncludeFile();","control x i");
- AssignKey("Kill(GetBufferID());","control x k");
- AssignKey("QuitAll();", "control x control c");
- AssignKey("emacsGotoBuffer(0);","control x b");
- AssignKey("emacsGotoBuffer(1);","control x 4 b");
-
- //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» View control ««
- AssignKey("MaximizeView();","control x 1");
- AssignKey("RemoveView();", "control x 0");
- AssignKey("CurrentBuffer(Activate(DuplicateEntry(),1));","control x 2");
- AssignKey("CenterView();", "control l");
-
- //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Folder control ««
- AssignKey("FoldShow();", "control c control s"); // SHOW
- AssignKey("FoldShow(0);", "control c control S e"); // (e)xclusive
- AssignKey("FoldShow(-1);", "control c control S a"); // (a)ll
- AssignKey("FoldDelete();", "control c control S d"); // (d)elete
- AssignKey("FoldHide();", "control c control h"); // HIDE
- AssignKey("FoldHide(0);", "control c control H e"); // (e)xclusive
- AssignKey("FoldHide(-1);", "control c control H a"); // (a)ll
- AssignKey("Fold();", "control c control H n"); // (n)ew
-
- //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Replace ««
- AssignKey("ReplaceSet();", joinstr(metaKey, " shift 5"));
-
- //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Miscellaneous ««
- AssignKey("SetInfo(-1,\"wall_right\",ReadInfo(\"column\"));","control x f");
- // Set wall_right
-
- AssignKey("ISpell();", joinstr(metaKey, " shift 4")); // ISpell
-
- AssignKey("Prompt();", joinstr(metaKey," x"));
-
- AssignKey("Iconify();", "control z");
-