home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / wp / ew12b.zip / FILES1.ZIP / BACKTAB.C < prev    next >
C/C++ Source or Header  |  1993-07-03  |  2KB  |  61 lines

  1. /*------------------------------------------------
  2.    BACKTAB.C -- Extension DLL for E! - version 1.0
  3.  
  4.    To compile: nmake backtab.mak
  5.  
  6.    Once compiled, copy BACKTAB.EWD to your USER directory.
  7.  
  8.    To use this DLL simply load it from the user menu or add its name to the
  9.    list of autoloaded Extension DLLs by using the Autoload dialog box from
  10.    the User Menu of EW. That's all.
  11.  
  12.    This extension DLL adds a new function to E!. It erases all text between
  13.    the current cursor position and the previous tab position, shifting all
  14.    the text after the cursor to the left.
  15.  
  16.    You can assign this extension to a keystroke (Ctrl Bsp would be nice).
  17.    See the documentation for a description of how to assign DLL execution
  18.    to a keystroke. Once assigned to a keystroke, an extension DLL needs not
  19.    be explicitly loaded. EW takes care of this for you.
  20.   ------------------------------------------------*/
  21.  
  22. #include <windows.h>
  23. #include <string.h>
  24. #include "ewapi.h"
  25.  
  26. int FAR PASCAL LibMain (HANDLE hInstance, WORD wDataSeg, WORD wHeapSize,
  27.             LPSTR lpszCmdLine)
  28. {
  29.   if (wHeapSize > 0)
  30.     UnlockData (0) ;
  31.   return 1 ;
  32. }
  33.  
  34. int FAR PASCAL EWExecute(unsigned int RoutineId)
  35. {
  36.   WORD    xPos1, xPos2, yPos;
  37.   long    CaretPos1, CaretPos2;
  38.   char    LineBuffer[256];
  39.   HWND    H;
  40.  
  41.   CaretPos1 = EWGetCaretPos();             // Get current caret position
  42.   xPos1 = LOWORD(CaretPos1);
  43.   yPos = HIWORD(CaretPos1);
  44.   if ((xPos1 != 0) && (!EWGotoPrevTab())) {  // Go to previous Tab position
  45.     CaretPos2 = EWGetCaretPos();
  46.     xPos2 = LOWORD(CaretPos2);
  47.     _fstrcpy(LineBuffer, EWGetLineAt(yPos)); // Get current line
  48.     _fmemmove(LineBuffer + xPos2,         // Erase unwanted characters
  49.           LineBuffer + xPos1,
  50.           _fstrlen(LineBuffer + xPos1) + 1);
  51.     EWSetLineAt(LineBuffer, yPos);         // Move new line to actual text
  52.     H = EWGetTextWindowHandle();
  53.     InvalidateRect(H, NULL, FALSE);         // Repaint window
  54.     UpdateWindow(H);
  55.     EWSetModified();                 // Tell E! that the text has been modified
  56.     return(0);
  57.   }
  58.   else
  59.     return(ewerr_EXTFAILED);
  60. }
  61.