Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
de_win.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define OTHER_FLAG   0x100
#define EDIT_CMD_FLAG   0x200
#define REPEAT_FLAG   0x400
#define CHAR_CMD(i)   ((i) & 0xff)
#define IDM_FILESAVE   (EDIT_CMD_FLAG + WRITE)
#define IDM_FILEEXIT   (OTHER_FLAG + 1)
#define IDM_HELPABOUT   (OTHER_FLAG + 2)
#define IDM_HELPCONTENTS   (OTHER_FLAG + 3)
#define IDM_EDITPDOWN   (REPEAT_FLAG + EDIT_CMD_FLAG + DOWN)
#define IDM_EDITPUP   (REPEAT_FLAG + EDIT_CMD_FLAG + UP)
#define IDM_EDITUNDO   (EDIT_CMD_FLAG + UNDO)
#define IDM_EDITLOCATE   (EDIT_CMD_FLAG + LOCATE)
#define IDM_EDITDOWN   (EDIT_CMD_FLAG + DOWN)
#define IDM_EDITUP   (EDIT_CMD_FLAG + UP)
#define IDM_EDITLEFT   (EDIT_CMD_FLAG + LEFT)
#define IDM_EDITRIGHT   (EDIT_CMD_FLAG + RIGHT)
#define IDM_EDITBS   (EDIT_CMD_FLAG + BS)
#define IDM_EDITDEL   (EDIT_CMD_FLAG + DEL)
#define IDM_EDITREPEAT   (EDIT_CMD_FLAG + REPEAT)
#define IDM_EDITTOP   (EDIT_CMD_FLAG + TOP)

Functions

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, UINT wParam, LONG lParam)
LRESULT CALLBACK AboutBox (HWND hDlg, UINT message, UINT wParam, LONG lParam)
CORD retrieve_screen_line (int i)
void set_position (int x, int y)
void do_command (int)
void generic_init (void)
void move_cursor (int column, int line)
void invalidate_line (int line)
void de_error (char *s)

Variables

int LINES
int COLS
char * arg_file_name
int dis_line
int dis_col
int line
int col

Define Documentation

#define CHAR_CMD (   i)    ((i) & 0xff)

Definition at line 22 of file de_win.h.

#define EDIT_CMD_FLAG   0x200

Definition at line 19 of file de_win.h.

Definition at line 38 of file de_win.h.

Definition at line 39 of file de_win.h.

Definition at line 34 of file de_win.h.

Definition at line 36 of file de_win.h.

Definition at line 33 of file de_win.h.

Definition at line 30 of file de_win.h.

Definition at line 31 of file de_win.h.

Definition at line 40 of file de_win.h.

Definition at line 37 of file de_win.h.

Definition at line 41 of file de_win.h.

Definition at line 32 of file de_win.h.

Definition at line 35 of file de_win.h.

Definition at line 26 of file de_win.h.

Definition at line 25 of file de_win.h.

Definition at line 27 of file de_win.h.

Definition at line 28 of file de_win.h.

#define OTHER_FLAG   0x100

Definition at line 18 of file de_win.h.

#define REPEAT_FLAG   0x400

Definition at line 20 of file de_win.h.


Function Documentation

LRESULT CALLBACK AboutBox ( HWND  hDlg,
UINT  message,
UINT  wParam,
LONG  lParam 
)
void de_error ( char *  s)

Definition at line 39 of file de_win.c.

{
    MessageBox( hwnd, (LPSTR) s,
                (LPSTR) FullAppName,
                MB_ICONINFORMATION | MB_OK );
    InvalidateRect(hwnd, NULL, TRUE);
}

Definition at line 397 of file de.c.

{
    int i;
    int need_fix_pos;
    FILE * out;
    
    if ( c == '\r') c = '\n';
    if (locate_mode) {
        size_t new_pos;
          
        if (c == LOCATE) {
              locate_mode = 0;
              locate_string = CORD_EMPTY;
              return;
        }
        locate_string = CORD_cat_char(locate_string, (char)c);
        new_pos = CORD_str(current, file_pos - CORD_len(locate_string) + 1,
                        locate_string);
        if (new_pos != CORD_NOT_FOUND) {
            need_redisplay = ALL;
            new_pos += CORD_len(locate_string);
            for (;;) {
                     file_pos = line_pos(line + 1, 0);
                     if (file_pos > new_pos) break;
                     line++;
            }
            col = new_pos - line_pos(line, 0);
            file_pos = new_pos;
            fix_cursor();
        } else {
            locate_string = CORD_substr(locate_string, 0,
                                          CORD_len(locate_string) - 1);
            beep();
        }
        return;
    }
    if (c == REPEAT) {
       repeat_count = BARE_PREFIX; return;
    } else if (c < 0x100 && isdigit(c)){
        if (repeat_count == BARE_PREFIX) {
          repeat_count = c - '0'; return;
        } else if (repeat_count != NO_PREFIX) {
          repeat_count = 10 * repeat_count + c - '0'; return;
        }
    }
    if (repeat_count == NO_PREFIX) repeat_count = 1;
    if (repeat_count == BARE_PREFIX && (c == UP || c == DOWN)) {
       repeat_count = LINES - dis_granularity;
    }
    if (repeat_count == BARE_PREFIX) repeat_count = 8;
    need_fix_pos = 0;
    for (i = 0; i < repeat_count; i++) {
        switch(c) {
          case LOCATE:
            locate_mode = 1;
            break;
          case TOP:
            line = col = file_pos = 0;
            break;
         case UP:
           if (line != 0) {
               line--;
               need_fix_pos = 1;
           }
           break;
         case DOWN:
           line++;
           need_fix_pos = 1;
           break;
         case LEFT:
           if (col != 0) {
               col--; file_pos--;
           }
           break;
         case RIGHT:
           if (CORD_fetch(current, file_pos) == '\n') break;
           col++; file_pos++;
           break;
         case UNDO:
           del_hist();
           need_redisplay = ALL; need_fix_pos = 1;
           break;
         case BS:
           if (col == 0) {
               beep();
               break;
           }
           col--; file_pos--;
           /* fall through: */
         case DEL:
           if (file_pos == current_len-1) break;
              /* Can't delete trailing newline */
           if (CORD_fetch(current, file_pos) == '\n') {
               need_redisplay = ALL; need_fix_pos = 1;
           } else {
               need_redisplay = line - dis_line;
           }
           add_hist(CORD_cat(
                     CORD_substr(current, 0, file_pos),
                     CORD_substr(current, file_pos+1, current_len)));
           invalidate_map(line);
           break;
         case WRITE:
           {
              CORD name = CORD_cat(CORD_from_char_star(arg_file_name),
                                 ".new");

               if ((out = fopen(CORD_to_const_char_star(name), "wb")) == NULL
                   || CORD_put(current, out) == EOF) {
                  de_error("Write failed\n");
                  need_redisplay = ALL;
                } else {
                    fclose(out);
                }
           }
            break;
         default:
           {
               CORD left_part = CORD_substr(current, 0, file_pos);
               CORD right_part = CORD_substr(current, file_pos, current_len);
               
               add_hist(CORD_cat(CORD_cat_char(left_part, (char)c),
                              right_part));
               invalidate_map(line);
               if (c == '\n') {
                   col = 0; line++; file_pos++;
                   need_redisplay = ALL;
               } else {
                   col++; file_pos++;
                   need_redisplay = line - dis_line;
              }
               break;
           }
        }
    }
    if (need_fix_pos) fix_pos();
    fix_cursor();
    repeat_count = NO_PREFIX;
}

Here is the call graph for this function:

Definition at line 539 of file de.c.

{
    FILE * f;
    CORD initial;
    
    if ((f = fopen(arg_file_name, "rb")) == NULL) {
       initial = "\n";
    } else {
        initial = CORD_from_file(f);
        if (initial == CORD_EMPTY
            || CORD_fetch(initial, CORD_len(initial)-1) != '\n') {
            initial = CORD_cat(initial, "\n");
        }
    }
    add_map(0,0);
    add_hist(initial);
    now -> map = current_map;
    now -> previous = now;  /* Can't back up further: beginning of the world */
    need_redisplay = ALL;
    fix_cursor();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 330 of file de_win.c.

{
    RECT line;
    
    if (!screen_was_painted) return;
       /* Invalidating a rectangle before painting seems result in a  */
       /* major performance problem.                                  */
    get_line_rect(i, COLS*char_width, &line);
    InvalidateRect(hwnd, &line, FALSE);
}

Here is the call graph for this function:

void move_cursor ( int  column,
int  line 
)

Definition at line 316 of file de_win.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void set_position ( int  x,
int  y 
)

Here is the caller graph for this function:

long FAR PASCAL _export WndProc ( HWND  hwnd,
UINT  message,
UINT  wParam,
LONG  lParam 
)

Definition at line 224 of file poppad.c.

     {
     static BOOL    bNeedSave = FALSE ;
     static char    szFileName  [_MAX_PATH] ;
     static char    szTitleName [_MAX_FNAME + _MAX_EXT] ;
     static FARPROC lpfnAboutDlgProc ;
     static HANDLE  hInst ;
     static int     iOffset ;
     static UINT    messageFindReplace ;
     LONG           lSelect ;
     LPFINDREPLACE  lpfr ;
     WORD           wEnable ;

     switch (message)
          {
          case WM_CREATE:
                         // Get About dialog instance address

               hInst = ((LPCREATESTRUCT) lParam)->hInstance ;
               lpfnAboutDlgProc = MakeProcInstance ((FARPROC) AboutDlgProc,
                                                    hInst) ;

                         // Create the edit control child window

               hwndEdit = CreateWindow ("edit", NULL,
                         WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |
                              WS_BORDER | ES_LEFT | ES_MULTILINE |
                              ES_NOHIDESEL | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
                         0, 0, 0, 0,
                         hwnd, EDITID, hInst, NULL) ;

               SendMessage (hwndEdit, EM_LIMITTEXT, 32000, 0L) ;

                         // Initialize common dialog box stuff

               PopFileInitialize (hwnd) ;
               PopFontInitialize (hwndEdit) ;

               messageFindReplace = RegisterWindowMessage (FINDMSGSTRING) ;

                         // Process command line

               lstrcpy (szFileName, (LPSTR)
                        (((LPCREATESTRUCT) lParam)->lpCreateParams)) ;

               if (lstrlen (szFileName) > 0)
                    {
                    GetFileTitle (szFileName, szTitleName,
                                  sizeof (szTitleName)) ;

                    if (!PopFileRead (hwndEdit, szFileName))
                         OkMessage (hwnd, "File %s cannot be read!",
                                          szTitleName) ;
                    }

               DoCaption (hwnd, szTitleName) ;

               /* Initialize Event Processing for NSPR
               ** Retrieve the event queue just created
               ** Create the TimerThread
               */               
               PL_InitializeEventsLib("someName");
               padQueue = PL_GetMainEventQueue();
               tThread = PR_CreateThread(PR_USER_THREAD,
                        TimerThread,
                        NULL,
                        PR_PRIORITY_NORMAL,
                        PR_LOCAL_THREAD,
                        PR_JOINABLE_THREAD,
                        0 );
               return 0 ;

          case WM_SETFOCUS:
               SetFocus (hwndEdit) ;
               return 0 ;

          case WM_SIZE: 
               MoveWindow (hwndEdit, 0, 0, LOWORD (lParam),
                                           HIWORD (lParam), TRUE) ;
               return 0 ;

          case WM_INITMENUPOPUP:
               switch (lParam)
                    {
                    case 1:        // Edit menu

                              // Enable Undo if edit control can do it

                         EnableMenuItem (wParam, IDM_UNDO,
                              SendMessage (hwndEdit, EM_CANUNDO, 0, 0L) ?
                                   MF_ENABLED : MF_GRAYED) ;

                              // Enable Paste if text is in the clipboard

                         EnableMenuItem (wParam, IDM_PASTE,
                              IsClipboardFormatAvailable (CF_TEXT) ?
                                   MF_ENABLED : MF_GRAYED) ;

                              // Enable Cut, Copy, and Del if text is selected

                         lSelect = SendMessage (hwndEdit, EM_GETSEL, 0, 0L) ;
                         wEnable = HIWORD (lSelect) != LOWORD (lSelect) ?
                                        MF_ENABLED : MF_GRAYED ;

                         EnableMenuItem (wParam, IDM_CUT,  wEnable) ;
                         EnableMenuItem (wParam, IDM_COPY, wEnable) ;
                         EnableMenuItem (wParam, IDM_DEL,  wEnable) ;
                         break ;

                    case 2:        // Search menu

                              // Enable Find, Next, and Replace if modeless
                              //   dialogs are not already active

                         wEnable = hDlgModeless == NULL ?
                                        MF_ENABLED : MF_GRAYED ;

                         EnableMenuItem (wParam, IDM_FIND,    wEnable) ;
                         EnableMenuItem (wParam, IDM_NEXT,    wEnable) ;
                         EnableMenuItem (wParam, IDM_REPLACE, wEnable) ;
                         break ;
                    }
               return 0 ;

          case WM_COMMAND :
                              // Messages from edit control

               if (LOWORD (lParam) && wParam == EDITID)
                    {
                    switch (HIWORD (lParam))
                         {
                         case EN_UPDATE:
                              bNeedSave = TRUE ;
                              return 0 ;

                         case EN_ERRSPACE:
                         case EN_MAXTEXT:
                              MessageBox (hwnd, "Edit control out of space.",
                                        szAppName, MB_OK | MB_ICONSTOP) ;
                              return 0 ;
                         }
                    break ;
                    }

               switch (wParam)
                    {
                              // Messages from File menu

                    case IDM_NEW:
                         if (bNeedSave && IDCANCEL ==
                                   AskAboutSave (hwnd, szTitleName))
                              return 0 ;

                         SetWindowText (hwndEdit, "\0") ;
                         szFileName [0]  = '\0' ;
                         szTitleName [0] = '\0' ;
                         DoCaption (hwnd, szTitleName) ;
                         bNeedSave = FALSE ;
                         return 0 ;

                    case IDM_OPEN:
                         if (bNeedSave && IDCANCEL ==
                                   AskAboutSave (hwnd, szTitleName))
                              return 0 ;

                         if (PopFileOpenDlg (hwnd, szFileName, szTitleName))
                              {
                              if (!PopFileRead (hwndEdit, szFileName))
                                   {
                                   OkMessage (hwnd, "Could not read file %s!",
                                                    szTitleName) ;
                                   szFileName  [0] = '\0' ;
                                   szTitleName [0] = '\0' ;
                                   }
                              }

                         DoCaption (hwnd, szTitleName) ;
                         bNeedSave = FALSE ;
                         return 0 ;

                    case IDM_SAVE:
                         if (szFileName [0])
                              {
                              if (PopFileWrite (hwndEdit, szFileName))
                                   {
                                   bNeedSave = FALSE ;
                                   return 1 ;
                                   }
                              else
                                   OkMessage (hwnd, "Could not write file %s",
                                                    szTitleName) ;
                              return 0 ;
                              }
                                                  // fall through
                    case IDM_SAVEAS:
                         if (PopFileSaveDlg (hwnd, szFileName, szTitleName))
                              {
                              DoCaption (hwnd, szTitleName) ;

                              if (PopFileWrite (hwndEdit, szFileName))
                                   {
                                   bNeedSave = FALSE ;
                                   return 1 ;
                                   }
                              else
                                   OkMessage (hwnd, "Could not write file %s",
                                                    szTitleName) ;
                              }
                         return 0 ;

                    case IDM_PRINT:
                         if (!PopPrntPrintFile (hInst, hwnd, hwndEdit,
                                                szTitleName))
                              OkMessage (hwnd, "Could not print file %s",
                                         szTitleName) ;
                         return 0 ;

                    case IDM_EXIT:
                         SendMessage (hwnd, WM_CLOSE, 0, 0L) ;
                         return 0 ;

                              // Messages from Edit menu

                    case IDM_UNDO:
                         SendMessage (hwndEdit, WM_UNDO, 0, 0L) ;
                         return 0 ;

                    case IDM_CUT:
                         SendMessage (hwndEdit, WM_CUT, 0, 0L) ;
                         return 0 ;

                    case IDM_COPY:
                         SendMessage (hwndEdit, WM_COPY, 0, 0L) ;
                         return 0 ;

                    case IDM_PASTE:
                         SendMessage (hwndEdit, WM_PASTE, 0, 0L) ;
                         return 0 ;

                    case IDM_DEL:
                         SendMessage (hwndEdit, WM_CLEAR, 0, 0L) ;
                         return 0 ;

                    case IDM_SELALL:
                         SendMessage (hwndEdit, EM_SETSEL, 0,
                                        MAKELONG (0, 32767)) ;
                         return 0 ;

                              // Messages from Search menu

                    case IDM_FIND:
                         iOffset = HIWORD (
                              SendMessage (hwndEdit, EM_GETSEL, 0, 0L)) ;
                         hDlgModeless = PopFindFindDlg (hwnd) ;
                         return 0 ;

                    case IDM_NEXT:
                         iOffset = HIWORD (
                              SendMessage (hwndEdit, EM_GETSEL, 0, 0L)) ;

                         if (PopFindValidFind ())
                              PopFindNextText (hwndEdit, &iOffset) ;
                         else
                              hDlgModeless = PopFindFindDlg (hwnd) ;

                         return 0 ;

                    case IDM_REPLACE:
                         iOffset = HIWORD (
                              SendMessage (hwndEdit, EM_GETSEL, 0, 0L)) ;

                         hDlgModeless = PopFindReplaceDlg (hwnd) ;
                         return 0 ;

                    case IDM_FONT:
                         if (PopFontChooseFont (hwnd))
                              PopFontSetFont (hwndEdit) ;

                         return 0 ;

                              // Messages from Help menu

                    case IDM_HELP:
                         OkMessage (hwnd, "Help not yet implemented!", NULL) ;
                         return 0 ;

                    case IDM_ABOUT:
                         DialogBox (hInst, "AboutBox", hwnd, lpfnAboutDlgProc);
                         return 0 ;
                    }
               break ;

          case WM_CLOSE:
               if (!bNeedSave || IDCANCEL != AskAboutSave (hwnd, szTitleName))
                    DestroyWindow (hwnd) ;

               return 0 ;

          case WM_QUERYENDSESSION:
               if (!bNeedSave || IDCANCEL != AskAboutSave (hwnd, szTitleName))
                    return 1L ;

               return 0 ;

          case WM_DESTROY:
               PopFontDeinitialize () ;
               PostQuitMessage (0) ;
               quitSwitch = 1;
               return 0 ;

          default:
                         // Process "Find-Replace" messages

               if (message == messageFindReplace)
                    {
                    lpfr = (LPFINDREPLACE) lParam ;

                    if (lpfr->Flags & FR_DIALOGTERM)
                         hDlgModeless = NULL ;

                    if (lpfr->Flags & FR_FINDNEXT)
                         if (!PopFindFindText (hwndEdit, &iOffset, lpfr))
                              OkMessage (hwnd, "Text not found!", NULL) ;

                    if (lpfr->Flags & FR_REPLACE ||
                        lpfr->Flags & FR_REPLACEALL)
                         if (!PopFindReplaceText (hwndEdit, &iOffset, lpfr))
                              OkMessage (hwnd, "Text not found!", NULL) ;

                    if (lpfr->Flags & FR_REPLACEALL)
                         while (PopFindReplaceText (hwndEdit, &iOffset, lpfr));

                    return 0 ;
                    }
               break ;
          }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
     }

Here is the call graph for this function:


Variable Documentation

Definition at line 378 of file de.c.

Definition at line 108 of file de.c.

Definition at line 32 of file de_win.c.

Definition at line 99 of file de.c.

Definition at line 98 of file de.c.

Definition at line 107 of file de.c.

Definition at line 31 of file de_win.c.