~ubuntu-branches/debian/stretch/vifm/stretch

« back to all changes in this revision

Viewing changes to src/menus.c

  • Committer: Bazaar Package Importer
  • Author(s): Edelhard Becker
  • Date: 2005-08-09 15:15:09 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050809151509-0csu5v00b8gfvypy
Tags: 0.3-2
ACK NMU, thanks Blars (Closes: #320118)

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include "fileops.h"
35
35
#include "filetype.h"
36
36
#include "keys.h"
 
37
#include "registers.h"
37
38
#include "status.h"
38
39
#include "ui.h"
39
40
#include "utils.h"
65
66
        HISTORY,
66
67
        JOBS,
67
68
        LOCATE,
 
69
        REGISTER,
68
70
        USER,
69
71
        VIFM
70
72
};
551
553
        char *dir = NULL;
552
554
        char *file = NULL;
553
555
        char *free_this = NULL;
554
 
        int isdir = 0;
 
556
        //int isdir = 0;
555
557
 
556
558
        free_this = file = dir = strdup(m->data[m->pos]);
557
559
        chomp(file);
559
561
        if (m->action_program == NULL)
560
562
        {
561
563
                /* check if it really is a file */
 
564
                /*
562
565
                if (!access(file, R_OK))
563
566
                {
564
567
                        if (is_dir(file))
594
597
                        else
595
598
                                moveto_list_pos(view, find_file_pos_in_list(view, file));
596
599
                }
 
600
                */
597
601
        }
598
602
        else if (m->action_program != NULL)
599
603
        {
668
672
        {
669
673
                if(strchr(prog_str, '%'))
670
674
                {
671
 
                        char *expanded_command = expand_macros(view, prog_str, NULL);
 
675
                        int m = 0;
 
676
                        char *expanded_command = expand_macros(view, prog_str, NULL, &m, 0);
672
677
                        shellout(expanded_command, 0);
673
678
                        my_free(expanded_command);
674
679
                        return;
696
701
                        {
697
702
                                if(strchr(prog_str, '%'))
698
703
                                {
699
 
                                        char *expanded_command = expand_macros(view, prog_copy, NULL);
 
704
                                        int m = 0;
 
705
                                        char *expanded_command = expand_macros(view, prog_copy, NULL, &m, 0);
700
706
                                        shellout(expanded_command, 0);
701
707
                                        my_free(expanded_command);
702
708
                                        free(free_this);
716
722
                }
717
723
                if(strchr(prog_str, '%'))
718
724
                {
719
 
                        char *expanded_command = expand_macros(view, prog_copy, NULL);
 
725
                        int m = 0;
 
726
                        char *expanded_command = expand_macros(view, prog_copy, NULL, &m, 0);
720
727
                        shellout(expanded_command, 0);
721
728
                        my_free(expanded_command);
722
729
                        free(free_this);
1043
1050
 
1044
1051
        box(menu_win, 0, 0);
1045
1052
 
1046
 
        if(m->win_rows >= m->len)
 
1053
        if(m->win_rows - 2 >= m->len)
1047
1054
        {
1048
1055
                m->top = 0;
1049
1056
        }
1435
1442
}
1436
1443
 
1437
1444
void
1438
 
show_user_menu(FileView *view, char *get_info_script, char *action_prog )
 
1445
show_user_menu(FileView *view, char *command)
1439
1446
{
1440
1447
        int x;
1441
1448
        char buf[256];
1454
1461
        m.title = NULL;
1455
1462
        m.args = NULL;
1456
1463
        m.data = NULL;
1457
 
        m.get_info_script = get_info_script;
1458
 
        m.action_program = action_prog;
 
1464
        m.get_info_script = command;
 
1465
        m.action_program = NULL;
1459
1466
 
1460
1467
        getmaxyx(menu_win, m.win_rows, x);
1461
1468
 
1462
 
        snprintf(buf, sizeof(buf), "%s",  m.get_info_script);
 
1469
        snprintf(buf, sizeof(buf), " %s ",  m.get_info_script);
1463
1470
        m.title = strdup(buf);
1464
1471
        file = popen(buf, "r");
1465
1472
 
1475
1482
 
1476
1483
        while(fgets(buf, sizeof(buf), file))
1477
1484
        {
 
1485
                show_progress();
1478
1486
                m.data = (char **)realloc(m.data, sizeof(char *) * (x + 1));
1479
1487
                m.data[x] = (char *)malloc(sizeof(buf) + 2);
1480
1488
                snprintf(m.data[x], sizeof(buf), buf);
1558
1566
                {
1559
1567
                        m.data = (char **)realloc(m.data, sizeof(char *) * (x + 1));
1560
1568
                        m.data[x] = (char *)malloc(strlen(p->cmd) + 24);
1561
 
                        snprintf(m.data[x], strlen(p->cmd) + 22, " %d     %s  %s",
1562
 
                                        p->pid, p->cmd, p->stopped ? "Stopped" : "Running");
 
1569
                        snprintf(m.data[x], strlen(p->cmd) + 22, " %d     %s ",
 
1570
                                        p->pid, p->cmd);
1563
1571
 
1564
1572
                        x++;
1565
1573
                }
1598
1606
}
1599
1607
 
1600
1608
void
 
1609
show_register_menu(FileView *view)
 
1610
{
 
1611
        int x;
 
1612
 
 
1613
        menu_info m;
 
1614
        m.top = 0;
 
1615
        m.current = 1;
 
1616
        m.len = 0;
 
1617
        m.pos = 0;
 
1618
        m.win_rows = 0;
 
1619
        m.type = REGISTER;
 
1620
        m.matching_entries = 0;
 
1621
        m.match_dir = NONE;
 
1622
        m.regexp = NULL;
 
1623
        m.title = strdup(" Registers ");
 
1624
        m.args = NULL;
 
1625
        m.data = NULL;
 
1626
 
 
1627
        getmaxyx(menu_win, m.win_rows, x);
 
1628
 
 
1629
        for (x = 0; x < NUM_REGISTERS; x++)
 
1630
        {
 
1631
                if (reg[x].num_files > 0)
 
1632
                {
 
1633
                        char buf[56];
 
1634
                        int y = reg[x].num_files;
 
1635
                        snprintf(buf, sizeof(buf), "\"%c", reg[x].name);
 
1636
                        m.data = (char **)realloc(m.data, sizeof(char *) * (m.len + 1));
 
1637
                        m.data[m.len] = strdup(buf);
 
1638
                        m.len++;
 
1639
 
 
1640
                        while (y)
 
1641
                        {
 
1642
 
 
1643
                                y--;
 
1644
                                m.data = (char **)realloc(m.data, sizeof(char *) * (m.len + 1));
 
1645
                                m.data[m.len] = strdup(reg[x].files[y]);
 
1646
 
 
1647
                                m.len++;
 
1648
                        }
 
1649
                }
 
1650
        }
 
1651
 
 
1652
        if (!m.len)
 
1653
        {
 
1654
                m.data = (char **)realloc(m.data, sizeof(char *) * 1);
 
1655
                m.data[0] = strdup(" Registers are empty ");
 
1656
                m.len = 1;
 
1657
        }
 
1658
 
 
1659
        setup_menu(view);
 
1660
        draw_menu(view, &m);
 
1661
        moveto_menu_pos(view, 0, &m);
 
1662
        menu_key_cb(view, &m);
 
1663
        reset_popup_menu(&m);
 
1664
}
 
1665
 
 
1666
void
1601
1667
show_vifm_menu(FileView *view)
1602
1668
{
1603
1669
        int x;