static gboolean
#if GTK_CHECK_VERSION (3, 0, 0)
on_draw (GtkWidget *widget, cairo_t *cr, WindowData *windata)
{
	paint_window (widget, cr, windata);

	return FALSE;
}
Beispiel #2
0
static gboolean
on_draw (GtkWidget  *widget,
	 cairo_t    *cr,
	 WindowData *windata)
{
	paint_window (widget, cr, windata);

	return FALSE;
}
on_expose_event (GtkWidget *widget, GdkEventExpose *event, WindowData *windata)
{
	cairo_t *cr = gdk_cairo_create (event->window);

	paint_window (widget, cr, windata);

	cairo_destroy (cr);

	return FALSE;
}
Beispiel #4
0
void paint_window( t_window* window, t_screen_point window_origin, t_screen_rect const& rect )
{
    if (rect.width() <= 0 || rect.height() <= 0)
        return;

    {
        int width = g_windowed_draw_buffer->get_width();
        int height = g_windowed_draw_buffer->get_height();

        t_paint_surface paint_surface( window_origin, t_screen_rect(0,0,width,height), g_windowed_draw_buffer, g_windowed_back_buffer );

        paint_window( window, paint_surface, rect );
    }
}
static gboolean on_window_expose(GtkWidget* widget, GdkEventExpose* event, WindowData* windata)
{
	paint_window(widget, windata);

	return FALSE;
}
Beispiel #6
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static int msgs[] = { BB_RECONFIGURE, BB_BROADCAST, 0};

    switch (message)
    {
        case WM_CREATE:
            /* Register to reveive these message */
            SendMessage(BBhwnd, BB_REGISTERMESSAGE, (WPARAM)hwnd, (LPARAM)msgs);
            /* Make the window appear on all workspaces */
            MakeSticky(hwnd);
            break;

        case WM_DESTROY:
            /* as above, in reverse */
            RemoveSticky(hwnd);
            SendMessage(BBhwnd, BB_UNREGISTERMESSAGE, (WPARAM)hwnd, (LPARAM)msgs);
            break;

        /* ---------------------------------------------------------- */
        /* Blackbox sends a "BB_RECONFIGURE" message on style changes etc. */

        case BB_RECONFIGURE:
            ReadRCSettings();
            GetStyleSettings();
            set_window_modes();
            break;

        /* ---------------------------------------------------------- */
        /* Painting directly on screen. Good enough for static plugins. */
#if 1
        case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc;
            RECT r;

            /* get screen DC */
            hdc = BeginPaint(hwnd, &ps);

            /* Setup the rectangle */
            r.left = r.top = 0;
            r.right = my.width;
            r.bottom =  my.height;

            /* and paint everything on it*/
            paint_window(hdc, &r);

            /* Done */
            EndPaint(hwnd, &ps);
            break;
        }

        /* ---------------------------------------------------------- */
        /* Painting with a cached double-buffer. If your plugin updates
           frequently, this avoids flicker */
#else
        case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc, hdc_buffer;
            HGDIOBJ otherbmp;
            RECT r;

            /* get screen DC */
            hdc = BeginPaint(hwnd, &ps);

            /* create a DC for the buffer */
            hdc_buffer = CreateCompatibleDC(hdc);

            if (NULL == my.bufbmp) /* No bitmap yet? */
            {
                /* Make a bitmap ... */
                my.bufbmp = CreateCompatibleBitmap(hdc, my.width, my.height);

                /* ... and select it into the DC, saving the previous default. */
                otherbmp = SelectObject(hdc_buffer, my.bufbmp);

                /* Setup the rectangle */
                r.left = r.top = 0;
                r.right = my.width;
                r.bottom =  my.height;

                /* and paint everything on it*/
                paint_window(hdc_buffer, &r);
            }
            else
            {
                /* Otherwise it has been painted already,
                   so just select it into the DC */
                otherbmp = SelectObject(hdc_buffer, my.bufbmp);
            }

            /* Copy the buffer on the screen, within the invalid rectangle: */
            BitBltRect(hdc, hdc_buffer, &ps.rcPaint);

            /* Put back the previous default bitmap */
            SelectObject(hdc_buffer, otherbmp);
            /* clean up */
            DeleteDC(hdc_buffer);

            /* Done. */
            EndPaint(hwnd, &ps);
            break;
        }
#endif
        /* ---------------------------------------------------------- */
        /* Manually moving/sizing has been started */

        case WM_ENTERSIZEMOVE:
            my.is_moving = true;
            break;

        case WM_EXITSIZEMOVE:
            if (my.is_moving)
            {
                if (my.is_inslit)
                {
                    /* moving in the slit is not really supported but who
                       knows ... */
                    SendMessage(g_hSlit, SLIT_UPDATE, 0, (LPARAM)hwnd);
                }
                else
                {
                    /* if not in slit, record new position */
                    WriteInt(rcpath, RC_KEY("xpos"), my.xpos);
                    WriteInt(rcpath, RC_KEY("ypos"), my.ypos);
                }

                if (my.is_sizing)
                {
                    /* record new size */
                    WriteInt(rcpath, RC_KEY("width"), my.width);
                    WriteInt(rcpath, RC_KEY("height"), my.height);
                }
            }
            my.is_moving = my.is_sizing = false;
            set_window_modes();
            break;

        /* --------------------------------------------------- */
        /* snap to edges on moving */

        case WM_WINDOWPOSCHANGING:
            if (my.is_moving)
            {
                WINDOWPOS* wp = (WINDOWPOS*)lParam;
                if (my.snapWindow && false == my.is_sizing)
                    SnapWindowToEdge(wp, 10, SNAP_FULLSCREEN);

                /* set a minimum size */
                if (wp->cx < 40)
                    wp->cx = 40;

                if (wp->cy < 20)
                    wp->cy = 20;
            }
            break;

        /* --------------------------------------------------- */
        /* record new position or size */

        case WM_WINDOWPOSCHANGED:
            if (my.is_moving)
            {
                WINDOWPOS* wp = (WINDOWPOS*)lParam;
                if (my.is_sizing)
                {
                    /* record sizes */
                    my.width = wp->cx;
                    my.height = wp->cy;

                    /* redraw window */
                    invalidate_window();
                }

                if (false == my.is_inslit)
                {
                    /* record position, if not in slit */
                    my.xpos = wp->x;
                    my.ypos = wp->y;
                }
            }
            break;

        /* ---------------------------------------------------------- */
        /* start moving or sizing accordingly to keys held down */

        case WM_LBUTTONDOWN:
            UpdateWindow(hwnd);
            if (GetAsyncKeyState(VK_MENU) & 0x8000)
            {
                /* start sizing, when alt-key is held down */
                PostMessage(hwnd, WM_SYSCOMMAND, 0xf008, 0);
                my.is_sizing = true;
            }
            else
            if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
            {
                /* start moving, when control-key is held down */
                PostMessage(hwnd, WM_SYSCOMMAND, 0xf012, 0);
            }
            break;

        /* ---------------------------------------------------------- */
        /* normal mouse clicks */

        case WM_LBUTTONUP:
            /* code goes here ... */
            break;

        case WM_RBUTTONUP:
            /* Show the user menu on right-click (might test for control-key
               held down if wanted */
            /* if (wParam & MK_CONTROL) */
            ShowMyMenu(true);
            break;

        case WM_LBUTTONDBLCLK:
            /* Do something here ... */
            about_box();
            break;

        /* ---------------------------------------------------------- */
        /* Blackbox sends Broams to all windows... */

        case BB_BROADCAST:
        {
            const char *msg = (LPCSTR)lParam;
            struct msg_test msg_test;

            /* check general broams */
            if (!stricmp(msg, "@BBShowPlugins"))
            {
                if (my.is_hidden)
                {
                    my.is_hidden = false;
                    ShowWindow(hwnd, SW_SHOWNA);
                }
                break;
            }

            if (!stricmp(msg, "@BBHidePlugins"))
            {
                if (my.pluginToggle && false == my.is_inslit)
                {
                    my.is_hidden = true;
                    ShowWindow(hwnd, SW_HIDE);
                }
                break;
            }

            /* if the broam is not for us, return now */
            if (0 != memicmp(msg, BROAM_PREFIX, sizeof BROAM_PREFIX - 1))
                break;

            msg_test.msg = msg + sizeof BROAM_PREFIX - 1;

            if (scan_broam(&msg_test, "useSlit"))
            {
                eval_broam(&msg_test, M_BOL, &my.useSlit);
                break;
            }

            if (scan_broam(&msg_test, "alwaysOnTop"))
            {
                eval_broam(&msg_test, M_BOL, &my.alwaysOnTop);
                break;
            }

            if (scan_broam(&msg_test, "drawBorder"))
            {
                eval_broam(&msg_test, M_BOL, &my.drawBorder);
                break;
            }

            if (scan_broam(&msg_test, "snapWindow"))
            {
                eval_broam(&msg_test, M_BOL, &my.snapWindow);
                break;
            }

            if (scan_broam(&msg_test, "pluginToggle"))
            {
                eval_broam(&msg_test, M_BOL, &my.pluginToggle);
                break;
            }

            if (scan_broam(&msg_test, "alphaEnabled"))
            {
                eval_broam(&msg_test, M_BOL, &my.alphaEnabled);
                break;
            }

            if (scan_broam(&msg_test, "alphaValue"))
            {
                eval_broam(&msg_test, M_INT, &my.alphaValue);
                break;
            }

            if (scan_broam(&msg_test, "windowText"))
            {
                eval_broam(&msg_test, M_STR, &my.windowText);
                break;
            }

            if (scan_broam(&msg_test, "editRC"))
            {
                edit_rc(rcpath);
                break;
            }

            if (scan_broam(&msg_test, "About"))
            {
                about_box();
                break;
            }

            break;
        }

        /* ---------------------------------------------------------- */
        /* prevent the user from closing the plugin with alt-F4 */

        case WM_CLOSE:
            break;

        /* ---------------------------------------------------------- */
        /* let windows handle any other message */
        default:
            return DefWindowProc(hwnd,message,wParam,lParam);
    }
    return 0;
}
Beispiel #7
0
LRESULT CALLBACK EditProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){

    char bstr[MAX_PATH];
    char *p,c;
    int i,k,n,o,r,f;
    POINT pt;
    struct edvars *ev;

    r = 0;

    //if (domove(GetParent(hwnd),message,wParam,lParam)) return 0;

    switch (message) {
    case WM_COPYDATA:
        if (0x4F4E4242 == ((PCOPYDATASTRUCT)lParam)->dwData)
        {
            char buff[MAX_PATH];
            int line_nr;
            const char *file = (const char*)((PCOPYDATASTRUCT)lParam)->lpData;
            getfile(buff, file, &line_nr);
            set_currentdir(buff);
            LoadFile(buff);
            if (line_nr) {
                ed_cmd(EK_GOTOLINE,line_nr-1);
                //ed_cmd(EK_MARK,lpos,imin(lpos+1,nextline(lpos,1)));
            }

            r = TRUE;
            goto p0r;
        }

        return bbn_receive_data(hwnd, lParam);

    default:
        if (bb_broadcast_msg == message && message)
        {
            if (bb_register(hwnd) && bb_getstyle(hwnd))
               goto reconfig1;
            return 0;
        }
        break;

    case BB_RECONFIGURE:
        if (bb_getstyle(hwnd))
            goto reconfig1;
        return 0;


    reconfig1:
        bb_close_dlg();
        makedlgfont();

    reconfig:
        zy0 = title_h + FRM-1;
        setsize(hwnd);
        new_back();
        InvalidateRect(hwnd, NULL, FALSE);
        return 0;

    case BB_SETSTYLESTRUCT:
    {
        StyleStruct *d = (StyleStruct *)wParam;
        StyleStruct *s = (StyleStruct *)lParam;
        memset(d, 0, sizeof *d);
        memcpy(d, s, sizeof *d);
        break;
    }

    case BB_SETSTYLE:
    {
        char *d = (char *)wParam;
        char *s = (char *)lParam;
        strcpy(d, s);
        break;
    }

    case WM_CREATE:
        zy0 = title_h + FRM-1;
        setsize(ewnd=hwnd);
        dragC  = LoadCursor(hInst,MAKEINTRESOURCE(101));
        dragCp = LoadCursor(hInst,MAKEINTRESOURCE(102));
        pointC = hCurs = LoadCursor(NULL,IDC_ARROW);
        init_edit(hwnd);
        DragAcceptFiles(hwnd,TRUE);
        if (false == bb_register(hwnd) || false == bb_getstyle(hwnd))
            readstyle(defstyle);
        goto reconfig1;


    case WM_DROPFILES: {
        POINT pt;
        HDROP hDrop = (HDROP)wParam; int n,f;
        ev=edp;
        f=0;

        GetCursorPos(&pt);
        if (GetAsyncKeyState(VK_CONTROL)<0) f=1;
        if (GetAsyncKeyState(VK_SHIFT)<0)   f=2;
        if (f) ScreenToClient(hwnd,&pt);

        for (i=-1, k=0; i<k; i++)
        {
            n=DragQueryFile (hDrop, i, p=bstr, 255);
            if (i<0)
            {
                k=n;
            }
            else
            if (f==0)
            {
                LoadFile(p);
            }
            else
            if (f==2)
            {
                if (readstyle(p))
                {
                    CopyFile(p, defstyle, FALSE);
                }
                break;
            }
            else
            {
                if (i == 0 && -1 == getmoupos(pt.x ,pt.y))
                    break;

                ed_cmd(EK_SETVAR);
                ed_cmd(EK_INSERT, p);
                ed_cmd(KEY_RET);
            }
        }
        DragFinish(hDrop);
        SetForegroundWindow(hwnd);
        if (f==0) goto showf;
        if (f==2) goto reconfig1;
        goto p0;
        }

    case WM_QUERYENDSESSION:
        return (1 == QueryDiscard(hwnd,1));

    case WM_ENDSESSION:
    {
        //void savecfg(void); savecfg();
        return 0;
    }

    case WM_DESTROY:
        exit_edit();
        DragAcceptFiles(hwnd,FALSE);
        bb_unregister(hwnd);
        PostQuitMessage(0);
        return 0 ;


    case WM_ACTIVATE:
        i=LOWORD(wParam);
        if (i==WA_ACTIVE)
            clickflag=0;

        return 0;

    case WM_ACTIVATEAPP:
        if (wParam) {
            clickflag=2;
        }
        return 0;

    case WM_LBUTTONDOWN:
    case WM_RBUTTONDOWN:
        if (alt_f) alt_f=2;

    case WM_MOUSEMOVE:
#if 0
    {
        static int wm;
        i = (short)HIWORD(lParam)/2;
        n = wm;
        wm = i;
        wParam = MAKELPARAM(0,(n-i)*30);
        goto mwhl;

    }
#endif
    case WM_LBUTTONDBLCLK:
    case WM_LBUTTONUP:
    case WM_RBUTTONUP:
    case WM_MBUTTONUP:
    case WM_MBUTTONDOWN:

        if (drag==0 && domove (hwnd, message, wParam, lParam))
            return 0;

        do_mouse(hwnd, wParam, lParam, message);

        if (message==WM_MOUSEMOVE && 0==(wParam & (MK_LBUTTON | MK_RBUTTON)))
            return 0;

        goto p0;

    case WM_TIMER:

        if (wParam==2) {
            resetmsg(hwnd);
            goto p0;
        }

        if (wParam==4) {
            mousewheelaccu=0;
        t0:
            KillTimer(hwnd, wParam);
            return 0;
        }

        GetCursorPos(&pt);
        ScreenToClient(hwnd,&pt);
        o=getmoupos(pt.x ,pt.y);
        if (o!=tcmd) {
            settimer(hwnd, o, SCROLL_INTERVAL);
            return 0;
        }

        if (tcmd==0) goto t0;
        c=ltup; ltup=0;
        ed_cmd(tcmd);
        ed_cmd(tcmd);
        upd=1;
        ltup=c;
        k=GetAsyncKeyState(VK_SHIFT)&0x8000;
        domarking(k!=0 || (0==moumrk && 0==drag));
        goto p0;


    case WM_SIZE:
        if (SIZE_MINIMIZED == wParam)
            return 0;

        if (edp) upd=1;
        ed_cmd(EK_SIZE);
        new_back();

    case WM_MOVE:
        setsize(hwnd);
        goto p0;

/*
   case WM_WINDOWPOSCHANGED:
        ewx0 = ((LPWINDOWPOS) lParam)->x;
        ewy0 = ((LPWINDOWPOS) lParam)->y;
        ewxl = ((LPWINDOWPOS) lParam)->cx;
        ewyl = ((LPWINDOWPOS) lParam)->cy;
        cfg_f |= 1;
        break; //process wm_move/wm_size

    case WM_WINDOWPOSCHANGING:
        SnapWindowToEdge((WINDOWPOS*)lParam, 10, 0);
        setsize(hwnd);
        return 0;
*/

    case WM_VSCROLL:
        vscroll(wParam);
        goto p0;

    case WM_HSCROLL:
        hscroll(wParam);
        goto p0;

    case WM_SETFOCUS:
        k_alt = 0>GetAsyncKeyState(VK_MENU);
        k_shft= 0>GetAsyncKeyState(VK_SHIFT);
        k_ctrl= 0>GetAsyncKeyState(VK_CONTROL);
        CreateCaret(hwnd,NULL,My_CaretSize,zy);
        caret=1;
        checkftime(hwnd);
        goto f1;

    case WM_KILLFOCUS:
        DestroyCaret();
        caret=0;
    f1:
        if (edp) upd=1;
        goto p0;

p0:
        r=0;
p0r:
        set_update(hwnd);
        return r;


    case WM_ERASEBKGND:
        return 1;

    case WM_PAINT:
        paint_window (hwnd);
        return 0;


    case WM_COMMAND:
        switch (LOWORD(wParam)) {

        case CMD_HELP:
#if 0
            bbnote_help();
            return 0;
#else
            if (fileexist(set_my_path(bstr, "bbnote.txt")))
                LoadFile(bstr);
            else if (fileexist(set_my_path(bstr, "docs/bbnote.txt")))
                LoadFile(bstr);
            goto p0;
#endif


        case CMD_EXIT:
            goto quit;

        case CMD_MENU_2:
        filemenu:
            if (ed0)
            {
                struct edvars *e = ed0;
                struct strl   *s = NULL;
                while (e)
                {
                    char temp[MAX_PATH];
                    sprintf(temp, "&%s", fname(e->sfilename));
                    appendstr(&s, temp);
                    e = e->next;
                }
                bb_file_menu (hwnd, lParam, s);
            }
            return 0;

        case CMD_MENU_1:
            bb_menu(hwnd, lParam);
            return 0;

        case CMD_COLOR:
            goto reconfig;

        case CMD_UPD:
            settitle();
            if (edp) upd=1;
            goto p0;


        case CMD_ZOOM:
    zoom:
            ShowWindow(hwnd, IsZoomed(hwnd) ? SW_SHOWNORMAL : SW_MAXIMIZE);
            return 0;

        case CMD_SEARCH:
        search:
            if (edp) bb_search_dialog(hwnd);
            return 0;

        case CMD_CLOSE:
        closefile:
            if (edp)
            {
                if (1 != QueryDiscard_1(hwnd, 1)) goto p0;
                if (ed0->next==NULL)
                {
                    extern HWND mwnd;
                    SendMessage(mwnd, WM_KEYDOWN, VK_ESCAPE, 0);
                    //DestroyWindow(mwnd);
                }
                CloseFile();
            }
            goto p0;

        case CMD_OPEN:
        openfile:
            ev=edp;
            DoFileOpenSave(hwnd, 0);
showf:
            if (ev==NULL || ev->next)
            {
                edp = ev ? ev->next : ed0;
                settitle();
            }
            goto p0;

        case CMD_RELOAD:
        reload:
            if (edp) f_reload(1);
            goto p0;


        case CMD_LIST:
            lParam = 2;
            goto filemenu;

        case CMD_NEW:
        newfile:
            NewFile();
            goto p0;

        case CMD_SAVE:
        savefile:
            if (edp) DoFileOpenSave(hwnd, 2);
            goto p0;

        case CMD_SAVEAS:
            if (edp!=NULL) DoFileOpenSave(hwnd, 1);
            break;

        case CMD_SAVEALL:
        //saveall:
            return QueryDiscard(hwnd, 0);

        case CMD_UNDO:
            ed_cmd(KEY_C_Z);
            goto p0;

        case CMD_REDO:
            ed_cmd(KEY_CS_Z);
            goto p0;

        case CMD_ABOUT:
            oyncan_msgbox(
              VERSION_STRING
              "\n"
              "\nediting with style"
              "\n04/2003 by grischka"
              "\n"
              "\[email protected]"
              , NULL, 1);
              return 0;


        case CMD_OPTIONS:
            goto config;

        case CMD_INFO:
            resetmsg(hwnd);
            p=(char*)lParam;
            if (p[0]==1) p++;
            else infoflg=1,infotimer=SetTimer(hwnd,2,666,NULL);
            strcpy(infomsg,p);
            if (edp) upd=1;
            goto p0;


        case CMD_FILECHG:
        {
            struct edvars *p=edp;
            edp=(struct edvars*)lParam;
            settitle();
            set_update(hwnd);
            f_reload(0);
            edp=p;
            settitle();
            goto p0;
        }

        default:
            i = LOWORD(wParam);
            if (i>=CMD_FILE && i< CMD_FILE_M)
            {
                struct edvars *p=ed0;
                i-=CMD_FILE;
                for (;i && p!=NULL; p=p->next,i--);
                if (p) {
                    //edp = p; settitle();
                    insfile(p);
                    goto p0;
                }
                return 0;
            }
            break;

        }
        break;

quit:
    if (1 == QueryDiscard(hwnd, 1))
        DestroyWindow(hwnd);
    return 0;

    case WM_SYSKEYDOWN:
        f=3; goto k1;

    case WM_SYSKEYUP:
        f=2; goto k1;

    case WM_KEYUP:
        if (wParam==VK_CONTROL && drag==3)  setdragc(2);
        f=0; goto k1;

    case WM_KEYDOWN:
        if (wParam==VK_CONTROL && drag==2)  setdragc(3);
        if (wParam==VK_SCROLL) { scroll_lock^=1; goto p0; }

        f=1; k1:

        n=LOWORD(wParam);

#if 0
        sprintf(bstr,"key %d  stat %d",n,f);
        if (n!=VK_MENU) MessageBox(NULL, bstr, "", MB_OK|MB_TOPMOST|MB_SETFOREGROUND);
#endif
        n=trans_keys(n, f);
        //if (0==n) goto p0;
        if (0==n) return 0;

        if (n>=2110 && n<=2117) {
        vmark=k_alt!=0;
        domarking(1);
        ed_cmd(n-100);
        domarking(1);
        goto p0;
        }

        switch (n) {

        case KEY_F8: return 0;
        case KEY_A_RIGHT:
        case KEY_F6:   nextfile(); goto p0;
        case KEY_A_LEFT:
        case KEY_C_F6: prevfile(); goto p0;

        case KEY_F10:  goto zoom;
        case KEY_F3:
        case KEY_C_F:  goto search;
        case KEY_C_F4: goto closefile;
        case KEY_C_O:  goto openfile;
        //case KEY_A_F3: goto reload;
        case KEY_C_N:  goto newfile;
        case KEY_C_L:  lParam = 0; goto filemenu;

        case KEY_F4:
            QueryDiscard(hwnd, 0);
            bb_reconfig();
            return 0;

        case KEY_S_F4:
            if (IDOK == oyncan_msgbox("Do you want to write all files?", "", 1+8))
                QueryDiscard(hwnd, 4);
            return 0;


        case KEY_C_S:  goto savefile;
        case KEY_A_F4: goto quit;

        case KEY_A_F2:
config:
            n = tabs;
            bb_config_dialog(hwnd);
            if (n!=tabs) goto reload;
            return 0;

        case KEY_ESC:
            if (drag==0) goto quit;
            dragmove=0;
            do_mouse(hwnd, 0,0,WM_LBUTTONUP);
            goto p0;

        case KEY_UP:
        case KEY_DOWN:
            if (scroll_lock) n+=200;
            goto defkey;

        case KEY_LEFT:
        case KEY_RIGHT:
            if (scroll_lock) n=(n^1)+204;
            goto defkey;
        }

    defkey:
        domarking(0);
        ed_cmd(n);
        i=n;
        if (i!=KEY_C_A
         && i!=KEY_C_U
         && i!=KEY_C_7
         && i!=KEY_C_8
         && i!=KEY_C_9
         && i!=KEY_C_0
         && i!=KEY_TAB
         && i!=KEY_S_TAB
         )
            unmark();
        goto p0;


    case WM_MOUSEWHEEL:
        i = mousewheelaccu + mousewheelfac * (short)HIWORD(wParam);
        while (i < -300)
            ed_cmd(KEY_C_DOWN), i+=600;
        while (i >  300)
            ed_cmd(KEY_C_UP),   i-=600;

        mousewheelaccu=i;
        unmark();
        SetTimer(hwnd, 4, 200, NULL);
        goto p0;


    case WM_NCPAINT:
        return 0;


    case WM_CHAR:
        n = LOWORD(wParam);
        if (n<32||n==127) return 0;

        resetmsg(hwnd);
        ed_cmd(EK_CHAR, n);
        goto p0;



    case CMD_GOTOLINE:
        ed_cmd(EK_GOTOLINE,wParam-1);
        ed_cmd(EK_MARK,lpos,imin(lpos+1,nextline(lpos,1)));
        lmf=2;
        goto p0;

    case CMD_LOADFILE:
        r=LoadFile((char*)wParam);
        goto p0r;

    case CMD_NSEARCH:
        resetmsg(hwnd);
        if (wParam&8) {
            ed_cmd(EK_REPLACE,(char *)lParam);
            if (wParam&1)
               ed_cmd(EK_GOTO,fpos+strlen((char*)lParam));
            goto p0;
        }
        unmark();
        if (wParam!=0) {
            struct sea *s=(struct sea *)lParam;
            struct edvars *ev0;

            for (ev0=edp;;) {
                r=ed_search(s);
                if (r || 0==(s->sf&128)) break;
                s->sf &= ~4;
                if (s->sf & 1) {
                    if (edp->next==NULL) break;
                    nextfile();
                    s->from=0;
                    continue;
                }
                if (s->sf & 2) {
                    if (edp==ed0) break;
                    prevfile();
                    s->from=flen;
                    continue;
                }}
            if (r<=0) {
                edp=ev0;
                settitle();
            } else {
               ed_cmd(KEY_HOME);
               ed_cmd(EK_MARK,s->a,s->e);
               ed_cmd(EK_GOTO,s->a);
            }
        }
        goto p0r;

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