error.c

来自「CC386 is a general-purpose 32-bit C comp」· C语言 代码 · 共 479 行 · 第 1/2 页

C
479
字号
/* 
Copyright 2001-2003 Free Software Foundation, Inc.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.  

You may contact the author at:

mailto::camille@bluegrass.net

or by snail mail at:

David Lindauer
850 Washburn Ave Apt 99
Louisville, KY 40222
 **********************************************************************

ERROR.C holds the functionality for the several tabs on the ERROR window.
These tabs include the 'build' tab, the 'debug' tab, and two 'find in
files' tabs.  The functionality is primarily performed by superclassing
the rich edit control four times, once for each tab.  The window proc
provides an interface for automatically switching tabs, or clearing the
windows out.

 **********************************************************************
 */
#define STRICT 
#include <windows.h>
#include <commctrl.h>
#include <commdlg.h>
#include <richedit.h>
#include <stdio.h>
#include "header.h"

extern HWND hwndSourceTab;
extern HANDLE hInstance;
extern HWND hwndWatch, hwndClient, hwndFrame, hwndTab;

HWND hwndError;
static char szErrorClassName[] = "xccErrorClass";
static WNDPROC oldproc;
static HWND hwndCtrl, hwndTabCtrl;
static LOGFONT Boldfontdata = 
{
    14, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS,
        CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_MODERN | FF_DONTCARE, "Arial"
};
static LOGFONT Normalfontdata = 
{
    14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
        OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_MODERN |
        FF_DONTCARE, "Arial"
};
static char *nameTags[] = 
{
    "Build", "Debug", "Find in Files 1", "Find in Files 2"
};
static char *szErrorTitle = "Information Window";
int getfile(char *start, char *buffer, char end, DWINFO *info)
{
    char *t = buffer,  *q = t;
    int rv;
    rv = atoi(++buffer);
    while (*buffer && isdigit(*buffer))
        buffer++;
    if (*buffer == end)
    {
        while (q > start)
        {
            if (*(q - 1) == ' ')
                break;
            q--;
        }
        strncpy(info->dwName, q, t - q);
        info->dwName[t - q] = 0;
        q = strrchr(info->dwName, '\\');
        if (q)
            strcpy(info->dwTitle, q + 1);
        else
            strcpy(info->dwTitle, info->dwName);
        return rv;
    }
    return  - 1;
}

//-------------------------------------------------------------------------

void BumpToEditor(HWND hwnd)
{
    HWND wnd;
    DWINFO info;
    char name[256], title[256], buffer[256],  *t;
    int lineno;
    int start;
    SendMessage(hwnd, EM_GETSEL, (WPARAM) &start, 0);
    lineno = SendMessage(hwnd, EM_EXLINEFROMCHAR, 0, start);
    *(short*)buffer = 255;
    lineno = SendMessage(hwnd, EM_GETLINE, lineno, (LPARAM)buffer);
    buffer[lineno] = 0;
    lineno =  - 1;
    if ((t = strchr(buffer, '(')) && isdigit(*(t + 1)))
    {
        lineno = getfile(buffer, t, ')', &info);
    }
    else
    {
        t = buffer;
        while (1)
        {
            if (t = strchr(t + 1, ':'))
            {
                if (isdigit(*(t + 1)))
                {
                    lineno = getfile(buffer, t, ':', &info);
                    if (lineno !=  - 1)
                        break;
                }
            }
            else
                break;
        }
    }
    if (lineno !=  - 1)
    {
        info.dwLineNo = lineno;
        info.logMRU = FALSE;
        CreateDrawWindow(&info);
    }

}

//-------------------------------------------------------------------------

void ScanForTags(int tagid, HWND hwnd)
{
    int lines;
    int i, lineno;
    DWINFO info;
    char buffer[256],  *t;
    lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0);
    for (i = 0; i < lines; i++)
    {
        *(short*)buffer = 255;
        lineno = SendMessage(hwnd, EM_GETLINE, i, (LPARAM)buffer);
        buffer[lineno] = 0;
        lineno =  - 1;
        if ((t = strchr(buffer, '(')) && isdigit(*(t + 1)))
        {
            lineno = getfile(buffer, t, ')', &info);
        }
        else
        {
            t = buffer;
            while (1)
            {
                if (t = strchr(t + 1, ':'))
                {
                    if (isdigit(*(t + 1)))
                    {
                        lineno = getfile(buffer, t, ':', &info);
                        if (lineno !=  - 1)
                            break;
                    }
                }
                else
                    break;
            }
        }
        if (lineno !=  - 1)
        {
            Tag(tagid, info.dwName, lineno, 0, 0, 0, 0);
        }
    }
}

//-------------------------------------------------------------------------

LRESULT CALLBACK _export buildEditProc(HWND hwnd, UINT iMessage, WPARAM wParam,
    LPARAM lParam)

{
    char buffer[256];
    int pos, chars, line, i;
    LRESULT rv;
    POINTL point;
    HBRUSH bk;
    RECT r;
    charinfo s;
    switch (iMessage)
    {
        case WM_CREATE:
            rv = CallWindowProc(oldproc, hwnd, iMessage, wParam, lParam);
            //         SendMessage(hwnd,EM_NOCOLORIZE,0,0) ;
            return rv;
        case WM_LBUTTONDOWN:
            *(short*)buffer = 256;
            point.x = LOWORD(lParam);
            point.y = HIWORD(lParam);
            pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point);
            line = SendMessage(hwnd, EM_EXLINEFROMCHAR, 0, pos);
            i = SendMessage(hwnd, EM_GETLINE, line, (LPARAM) &buffer);
            chars = 0; // richedit 1.0 was tacking things on the end...
            while (i-- && buffer[chars] > 31)
                chars++;
            pos = SendMessage(hwnd, EM_LINEINDEX, line, 0);
            s.min = pos;
            s.max = pos + chars;
            SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM) &s);

            BumpToEditor(hwnd);
            return 0;
        case WM_RBUTTONDOWN:
            {
                HMENU menu = LoadMenu(hInstance, "BUILDMENU");
                HMENU popup = GetSubMenu(menu, 0);
                POINT pos;
                GetCursorPos(&pos);
                TrackPopupMenuEx(popup, TPM_BOTTOMALIGN | TPM_LEFTBUTTON, pos.x,
                    pos.y, hwndFrame, NULL);
                DestroyMenu(menu);
            }
            return 0;
        case WM_LBUTTONDBLCLK:
        case WM_LBUTTONUP:
        case WM_RBUTTONUP:
        case WM_RBUTTONDBLCLK:
            return 0;
    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?