Example #1
0
void Preprocessor::applyHelpFile()
{
    std::string help_file = file_directory(file_name) + file_extension(file_name) + ".help";
    std::ifstream hfs(help_file);
    if(!hfs.is_open())
        return;
    hfs.close();
    std::cout << "Using HELP file: " << help_file << '.' << std::endl;
    readFile(help_file);
    analyseSource();
    lines.clear();
    source.clear();
}
Example #2
0
// recursive parsing of menu file
static Menu* ParseMenu(struct menu_src *src, const char *title, const char *IDString)
{
    char line[4000];
    char data[4000];
    char buffer[4000];
    char command[40];
    char label[MAX_PATH];

    Menu *pMenu, *pSub;
    MenuItem *pItem;
    int f, e_cmd;
    const char *p_label, *p_data, *cp, *p_cmd;

    pMenu = NULL;
    for(;;)
    {
        p_label = NULL;
        p_data = data;

        if (0 == src->level) {
            // read default menu from string
            NextToken(line, &src->default_menu, "\n");
        } else {
            f = ReadNextCommand(src->fp[src->level-1], line, sizeof(line));
            if (!f) {
                if (src->level > 1) {
                    dec_inc_level(src);
                    continue; // continue from included file
                }
                e_cmd = e_no_end;
                goto skip;
            }
        }

        cp = replace_environment_strings(line, sizeof line);

        //dbg_printf("Menu %08x line:%s", pMenu, line);

        // get the command
        if (false == get_string_within(command, sizeof command, &cp, "[]"))
            continue;
        // search the command
        e_cmd = get_string_index(command, menu_cmds);

        if (get_string_within(label, sizeof label, &cp, "()"))
            p_label = label;

        if (false == get_string_within(data, sizeof data, &cp, "{}"))
            p_data = label;

skip:
        if (NULL == pMenu)
        {
            if (e_begin == e_cmd) {
                // If the line contains [begin] we create the menu
                // If no menu title has been defined, display Blackbox version...
#ifdef BBXMENU
                if (src->default_menu)
                    strcpy(label, "bbXMenu");
                else
#endif
                if (0 == label[0] && src->default_menu)
                    p_label = GetBBVersion();
                pMenu = MakeNamedMenu(p_label, IDString, src->popup);
                continue;
            }

            if (NULL == title)
                title = NLS0("missing [begin]");

            pMenu = MakeNamedMenu(title, IDString, src->popup);
        }

        pItem = NULL;

        switch (e_cmd) {

        //====================
        // [begin] is like [submenu] when within the menu
        case e_begin:
        case e_submenu:
            sprintf(buffer, "%s_%s", IDString, label);
            strlwr(buffer + strlen(IDString));
            pSub = ParseMenu(src, p_data, buffer);
            if (pSub)
                pItem = MakeSubmenu(pMenu, pSub, label);
            else
                pItem = MakeMenuNOP(pMenu, label);
            break;

        //====================
        case e_no_end:
            MakeMenuNOP(pMenu, NLS0("missing [end]"));
        case e_end:
            MenuOption(pMenu, BBMENU_ISDROPTARGET);
            return pMenu;

        //====================
        case e_include:
        {
            char dir[MAX_PATH];
            file_directory(dir, src->path[src->level-1]);
            replace_shellfolders_from_base(buffer, p_data, false, dir);
            if (false == add_inc_level(src, buffer)) {
                replace_shellfolders(buffer, p_data, false);
                if (false == add_inc_level(src, buffer))
                    MakeMenuNOP(pMenu, NLS0("[include] failed"));
            }
            continue;
        }

        //====================
        // a [nop] item will insert an inactive item with optional text
        case e_nop:
            pItem = MakeMenuNOP(pMenu, label);
            break;

        // a insert separator, we treat [sep] like [nop] with no label
        case e_sep1:
        case e_sep2:
            pItem = MakeMenuNOP(pMenu, NULL);
            break;

        //====================
        // a [path] item is pointing to a dynamic folder...
        case e_path:
            p_cmd = get_special_command(&p_data, buffer, sizeof buffer);
            pItem = MakeMenuItemPath(pMenu, label, p_data, p_cmd);
            break;

        // a [insertpath] item will insert items from a folder...
        case e_insertpath:
            p_cmd = get_special_command(&p_data, buffer, sizeof buffer);
            pItem = MakeMenuItemPath(pMenu, NULL, p_data, p_cmd);
            break;

        // a [stylemenu] item is pointing to a dynamic style folder...
        case e_stylesmenu:
            pItem = MakeMenuItemPath(pMenu, label, p_data, MM_STYLE_BROAM);
            break;

        // a [styledir] item will insert styles from a folder...
        case e_stylesdir:
            pItem = MakeMenuItemPath(pMenu, NULL, p_data, MM_STYLE_BROAM);
            break;

        // a [rcmenu] item is pointing to a dynamic rc files folder...
        case e_rcmenu:
            pItem = MakeMenuItemPath(pMenu, label, p_data, MM_EDIT_BROAM);
            break;

        case e_themesmenu:
            pItem = MakeMenuItemPath(pMenu, label, p_data, MM_THEME_BROAM);
            break;

        //====================
        // special items...
        case e_workspaces:
            pItem = MakeSubmenu(pMenu, MakeDesktopMenu(0, src->popup), p_label);
            break;
        case e_icons:
            pItem = MakeSubmenu(pMenu, MakeDesktopMenu(1, src->popup), p_label);
            break;
        case e_tasks:
            pItem = MakeSubmenu(pMenu, MakeDesktopMenu(2, src->popup), p_label);
            break;
        case e_config:
            pItem = MakeSubmenu(pMenu, MakeConfigMenu(src->popup), p_label);
            break;

        //====================
        case e_exec:
            if ('@' == data[0]) {
                pItem = MakeMenuItem(pMenu, label, data, false);
                MenuItemOption(pItem, BBMENUITEM_UPDCHECK);
            } else {
                goto core_broam;
            }
            break;

        //====================
        case e_other:
            f = get_workspace_number(command); // check for 'workspace1..'
            if (-1 != f) {
                pItem = MakeSubmenu(pMenu, MakeTaskFolder(f, src->popup), p_label);
            } else {
                p_data = data;
                goto core_broam;
            }
            break;

        //====================
        // everything else is converted to a '@BBCore.xxx' broam
        core_broam:
            f = sprintf(buffer, "@bbCore.%s", command);
            strlwr(buffer+8);
            if (p_data[0])
                sprintf(buffer + f, " %s", p_data);
            pItem = MakeMenuItem(pMenu, label[0]?label:command, buffer, false);
            break;
        }

//#ifdef BBOPT_MENUICONS
		if ( Settings_menu.iconSize ) {
			if (pItem && get_string_within(label,  sizeof label, &cp, "<>"))
				MenuItemOption(pItem, BBMENUITEM_SETICON, label);
		}
//#endif
    }
}
Example #3
0
HBITMAP load_desk_bitmap(const char* command, bool makebmp)
{
    char exe_path[MAX_PATH];
    char bmp_path[MAX_PATH];
    char buffer[4*MAX_PATH];
    int x, r;

    const char *cptr;
    unsigned long bsrt_vernum;

    cptr = command;
    if (false == is_bsetroot_command(&cptr)) {
bbexec:
        if (command[0])
            BBExecute_string(command, RUN_NOERRORS);
        return NULL;
    }

#ifndef BBTINY
    if (makebmp) {
        HBITMAP bmp = make_root_bmp(cptr);
        if (bmp)
            return bmp;
    }
#endif

    set_my_path(NULL, exe_path, "bsetroot.exe");
    bsrt_vernum = getfileversion(exe_path);
    //dbg_printf("bsrt_vernum %08x", bsrt_vernum);
    if (bsrt_vernum < 0x02000000)
        goto bbexec;

    x = sprintf(buffer, "\"%s\" %s", exe_path, cptr);

#ifndef BBTINY
    if (makebmp) {
        set_my_path(NULL, bmp_path, "$bsroot$.bmp");
        x += sprintf(buffer + x, " -save \"%s\"", bmp_path);
    }
#endif

#if 0
    if (bsrt_vernum >= 0x02010000) {
        char base_path[MAX_PATH];
        file_directory(base_path, bbrcPath(NULL));
        x += sprintf(buffer + x, " -prefix \"%s\"", base_path);
    }
#endif

    r = BBExecute_string(buffer, RUN_NOSUBST|RUN_WAIT|RUN_NOERRORS);
    //dbg_printf("command <%s>", buffer);
    if (0 == r)
        return NULL;

#ifndef BBTINY
    if (makebmp)
        return read_bitmap(bmp_path, true);
#endif

    return NULL;
}
Example #4
0
bool GraphVizPreview::saveAs()
{
    OPENFILENAME ofn = { 0 };

    ofn.lStructSize = sizeof(OPENFILENAME);
    ofn.hwndOwner = m_hDlg;
    ofn.lpstrFilter =
        TEXT("BMP (Windows Bitmap Format) (*.bmp)\0*.bmp\0")
        TEXT("DOT (*.canon)\0*.canon\0")
        TEXT("DOT (*.dot)\0*.dot\0")
        TEXT("DOT (*.gv)\0*.gv\0")
        TEXT("DOT (*.xdot)\0*.xdot\0")
        TEXT("DOT (*.xdot1.2)\0*.xdot1.2\0")
        TEXT("DOT (*.xdot1.4)\0*.xdot1.4\0")
        TEXT("CGImage bitmap format (*.cgimage)\0*.cgimage\0")
        TEXT("CMAP (Client-side imagemap) (deprecated) (*.cmap)\0*.cmap\0")
        TEXT("EPS (Encapsulated PostScript) (*.eps)\0*.eps\0")
        TEXT("EXR (OpenEXR) (*.exr)\0*.exr\0")
        TEXT("FIG (*.fig)\0*.fig\0")
        TEXT("GD (*.gd)\0*.gd\0")
        TEXT("GD2 (*.gd2)\0*.gd2\0")
        TEXT("GIF (*.gif)\0*.gif\0")
        TEXT("GTK canvas (*.gtk)\0*.gtk\0")
        TEXT("ICO (Icon Image File Format) (*.ico)\0*.ico\0")
        TEXT("IMAP (Server-side imagemap) (*.imap)\0*.imap\0")
        TEXT("CMAPX (Client-side imagemap) (*.cmapx)\0*.cmapx\0")
        TEXT("IMAP_NP (Server-side imagemap) (*.imap_np)\0*.imap_np\0")
        TEXT("CMAPX_NP (Client-side imagemap) (*.cmapx_np)\0*.cmapx_np\0")
        TEXT("ISMAP (Server-side imagemap (deprecated)) (*.ismap)\0*.ismap\0")
        TEXT("JPEG 2000 (*.jp2)\0*.jp2\0")
        TEXT("JPEG (*.jpg)\0*.jpg\0")
        TEXT("JPEG (*.jpeg)\0*.jpeg\0")
        TEXT("JPEG (*.jpe)\0*.jpe\0")
        TEXT("PICT (*.pict)\0*.pict\0")
        TEXT("PDF (Portable Document Format) (PDF) (*.pdf)\0*.pdf\0")
        TEXT("PIC (Kernighan's PIC graphics language) (*.pic)\0*.pic\0")
        TEXT("PLAIN (Simple text format) (*.plain)\0*.plain\0")
        TEXT("PLAIN-EXT (Simple text format) (*.plain-ext)\0*.plain-ext\0")
        TEXT("PNG (Portable Network Graphics format) (*.png)\0*.png\0")
        TEXT("POV-Ray markup language (prototype) (*.pov)\0*.pov\0")
        TEXT("PS (PostScript) (*.ps)\0*.ps\0")
        TEXT("PS2 (PostScript) for PDF (*.ps2)\0*.ps2\0")
        TEXT("PSD (*.psd)\0*.psd\0")
        TEXT("SGI (*.sgi)\0*.sgi\0")
        TEXT("SVG (Scalable Vector Graphics) (*.svg)\0*.svg\0")
        TEXT("SVGZ (Scalable Vector Graphics) (*.svgz)\0*.svgz\0")
        TEXT("TGA (Truevision TGA) (*.tga)\0*.tga\0")
        TEXT("TIFF (Tag Image File Format) (*.tif)\0*.tif\0")
        TEXT("TIFF (Tag Image File Format) (*.tiff)\0*.tiff\0")
        TEXT("TK graphics (*.tk)\0*.tk\0")
        TEXT("VML (Vector Markup Language) (*.vml)\0*.vml\0")
        TEXT("VML (Vector Markup Language) (*.vmlz)\0*.vmlz\0")
        TEXT("VRML (*.vrml)\0*.vrml\0")
        TEXT("WBMP (Wireless BitMap format) (*.wbmp)\0*.wbmp\0")
        TEXT("WEBP (Image format for the Web) (*.webp)\0*.webp\0")
        TEXT("Xlib canvas (*.xlib)\0*.xlib\0")
        TEXT("Xlib canvas (*.x11)\0*.x11\0")
        TEXT("\0\0");// ends the pairs
        
    ConfigSettings &settings = cfg.load();

    static TCHAR initial_directory[MAX_PATH];
    lstrcpynW(initial_directory, settings.save_as_path.c_str(), MAX_PATH);

    TCHAR szFile[MAX_PATH] = { 0 };
    TCHAR szFileTitle[MAX_PATH] = { 0 };

    ofn.lpstrFile = szFile;
    ofn.nMaxFile = sizeof(szFile) / sizeof(*szFile);
    ofn.lpstrFileTitle = szFileTitle;
    ofn.nMaxFileTitle = sizeof(szFileTitle);
    ofn.lpstrInitialDir = initial_directory;
    ofn.Flags = OFN_SHOWHELP | OFN_OVERWRITEPROMPT;
    ofn.lpstrTitle = TEXT("Save As");
    ofn.nFilterIndex = settings.save_as_filter_index;
    
    ofn.Flags |= OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_ENABLESIZING;

    //ofn.Flags |= OFN_ENABLEHOOK;
    //ofn.lpfnHook = OFNHookProc;

    try {
        if (::GetSaveFileName((OPENFILENAME*)&ofn) == false)
            return false;

        // Main things to do next:
        // 1. Save filter index and directory for next Save As.
        // 2. Adjust the file name:
        //      * if no extension, use the filter extension.
        //      * if the file_name contains an extension that differs
        //          from the filter extension, change the filter extension.
        // 3. Store the save as path and extension for Graphviz.
        
        // 1.  Save filter index and directory for next Save As.
        settings.save_as_filter_index = ofn.nFilterIndex; // to save for next Save As.

        // Use the filter index to find the filter string.
        int file_type_inx = 0;
        for (DWORD i = 1; i < ofn.nFilterIndex * 2; ++i)
        {
            if (ofn.lpstrFilter[file_type_inx] == '\0')
                return false;
            while (ofn.lpstrFilter[file_type_inx++] != '\0'){}
        }

        std::wstring file_directory(ofn.lpstrFile);
        std::wstring file_type(&ofn.lpstrFilter[file_type_inx]);
        file_type = file_type.substr(2); // remove the "*.", first two characters.
        
        // Store the initial directory for next Save As.
        std::wstring::size_type dir_slash = file_directory.rfind(TEXT("\\"));
        std::wstring file_name = file_directory.substr(dir_slash);
        file_directory = file_directory.substr(0, dir_slash);
        settings.save_as_path = file_directory;

        // 2. Adjust the file name:
        
        //If the file_name doesn't contain an extension, append the extension we know.
        if (file_name.find(TEXT(".")) == std::wstring::npos)
        {
            file_name.append(TEXT("."));
            file_name.append(file_type);
        }
        else
        {
            // Is the extension different from our filter?
            if (file_name.rfind(file_type) == std::wstring::npos || !(file_name.rfind(file_type) == file_name.size() - file_type.size()))
            {
                std::wstring::size_type pos = file_name.rfind(TEXT("."));
                if (pos != std::wstring::npos)
                {
                    file_type = file_name.substr(pos + 1);
                }
            }
        }

        // 3. Store the "save as" path and extension for Graphviz.
        m_save_as_path = file_directory + file_name;
        m_save_as_ext = file_type;

        return true;
    }
    catch (std::exception e) {
        ::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
    }
    catch (...) {
        ::MessageBox(NULL, TEXT("GetSaveFileName crashes!!!"), TEXT(""), MB_OK);
    }

    return false;
}