【问题标题】:are there any tree libraries/widgets for (n)curses [closed]是否有(n)curses的任何树库/小部件[关闭]
【发布时间】:2011-01-23 09:28:59
【问题描述】:

我想知道是否有任何可用于 (n) 诅咒的树库。

我正在尝试编写一个显示文件夹树的组件,并且很好奇是否有预建的 curses 组件可以做到这一点。

我已经检查了“核心”诅咒以及 CDK 之类的库 - 我似乎找不到任何东西。

如果不存在,我不反对建立自己的 - 但我似乎找不到任何像样的教程,所以在这方面的任何帮助也将不胜感激。

谢谢,王牌

【问题讨论】:

    标签: ncurses curses


    【解决方案1】:

    “我正在尝试编写一个显示文件夹树的组件”

    CDK 有CDKFSELECT 小部件。

    它显示可能对您有用的目录和文件列表,或者 CDKFSELECT 的源代码可用于您自己的自定义编写 解决方案。

    CDKFSELECT *fSelect = 0;
    
    /*
    Height of zero means to extent of xterm
    Width of zero means to extent of xterm
    */
    int HEIGHT = 0;
    int WIDTH = 0;
    
    char *title = new char[strlen("Pick a file to open") + 1];
    strcpy(title, "Pick a file to open");
    
    char *prompt = new char[strlen("==> ") + 1];
    strcpy(prompt, "==> ");
    
    char *directoryAttribute = new char[strlen("</B>") + 1]; /* bold */
    strcpy(directoryAttribute, "</B>");
    
    char *fileAttribute = new char[strlen("</N>") + 1]; /* normal */
    strcpy(fileAttribute, "</N>");
    
    char *linkAttribute = new char[strlen("</D>") + 1]; /* dim */
    strcpy(linkAttribute, "</D>");
    
    char *sockAttribute = new char[strlen("</D>") + 1]; /* dim */
    strcpy(sockAttribute, "</D>");
    
    boolean displayBox = TRUE;
    boolean displayShadow = FALSE;
    
    fSelect = newCDKFselect(pCdkScreen,
              TOP, LEFT, HEIGHT, WIDTH,
              title, prompt,
              A_NORMAL, '_', A_REVERSE,
              directoryAttribute, fileAttribute, linkAttribute, sockAttribute,
              displayBox, displayShadow);
    
    char *filename = activateCDKFselect(fSelect, 0);
    /*
    2014-06-13, using DDD, filename being correctly populated
    by CDK
    */
    
    /* do other stuff... */
    
    /*
     free the memory of any dynamically created objects
     that were created with new or malloc, or such
    */
    destroyCDKFselect(fSelect);
    
    delete [] title;
    delete [] prompt;
    delete [] directoryAttribute;
    delete [] fileAttribute;
    delete [] linkAttribute;
    delete [] sockAttribute;
    

    【讨论】:

      【解决方案2】:

      dialog 程序(具有文档库接口)有一个 "tree" 小部件。该程序适用于 (n)curses,与 CDK 不同,它适用于 UTF-8。

      它还有一个file(/directory) 选择小部件。

      还有wcd(虽然像mc的可重用性是不确定的)。但是,这是 OP 可能想要的一个很好的例子:

      关于 urwid,这是值得商榷的。在引擎盖下,您实际上可能没有诅咒。对于它的价值,treeview 脚本的屏幕截图:

      在我的 Debian/测试系统上,该脚本不使用 ncurses。它是硬编码的(即使用raw_display)。

      【讨论】:

        【解决方案3】:

        Urwid 有一个树小部件 FWIW。

        更新:2020-10-01 - 我在 2010 年写了我的答案,当时我为 Urwid 写了一个树小部件,因为我找不到任何东西。 Urwid 仍然有树小部件,但这些天,我会查看 Python's prompt-toolkitone of the alternatives

        【讨论】:

          【解决方案4】:

          查看午夜指挥官源代码 (http://www.midnight-commander.org/) 它有一个树形存储小部件。

          【讨论】:

            猜你喜欢
            • 2011-02-25
            • 1970-01-01
            • 2021-11-30
            • 1970-01-01
            • 2020-12-19
            • 1970-01-01
            • 2023-01-04
            • 2011-10-17
            • 2020-11-23
            相关资源
            最近更新 更多