Example #1
0
void if_highlight_sviewer(enum tokenizer_language_support l)
{
    /* src_viewer->cur is NULL when reading cgdbrc */
    if (src_viewer && src_viewer->cur) {
        if ( l == TOKENIZER_LANGUAGE_UNKNOWN )
            l = tokenizer_get_default_file_type(strrchr(src_viewer->cur->path, '.'));

        src_viewer->cur->language = l;
        source_highlight(src_viewer->cur);
        if_draw();
    }
}
Example #2
0
/* load_file:  Loads the file in the list_node into its memory buffer.
 * ----------
 *
 *   node:  The list node to work on
 *
 * Return Value:  Zero on success, non-zero on error.
 */
static int load_file(struct list_node *node)
{
    /* No node pointer? */
    if (!node)
        return -1;

    /* File already loaded - success! */
    if (node->file_buf.lines)
        return 0;

    /* Stat the file to get the timestamp */
    if (get_timestamp(node->path, &(node->last_modification)) == -1)
        return -1;

    node->language = tokenizer_get_default_file_type(strrchr(node->path, '.'));

    /* Add the highlighted lines */
    return source_highlight(node);
}
Example #3
0
void if_display_help(void)
{
    char cgdb_help_file[FSUTIL_PATH_MAX];
    int ret_val = 0;

    fs_util_get_path(PKGDATADIR, "cgdb.txt", cgdb_help_file);

    /* File doesn't exist. Try to find cgdb.txt in the build dir in case
     * the user is running a built cgdb binary directly. */
    if (!fs_verify_file_exists(cgdb_help_file))
        fs_util_get_path(TOPBUILDDIR, "doc/cgdb.txt", cgdb_help_file);

    ret_val = source_set_exec_line(src_viewer, cgdb_help_file, 1, 0);

    if (ret_val == 0)
    {
        src_viewer->cur->language = TOKENIZER_LANGUAGE_CGDBHELP;
        source_highlight(src_viewer->cur);
        if_draw();
    }
    else if (ret_val == 5)      /* File does not exist */
        if_display_message("No such file: ", WIN_REFRESH, 0, "%s", cgdb_help_file);
}