File: action.cc

package info (click to toggle)
xd 5.00.03-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 708 kB
  • sloc: cpp: 1,852; fortran: 161; makefile: 107; sh: 36; ansic: 30
file content (36 lines) | stat: -rw-r--r-- 1,244 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "selector.ih"

    // by showalternatives.cc

Selector::Action Selector::action(Block const &block)
{
    OneKey oneKey;

    int ch = oneKey.get();                      // get the reply

    imsg << "Selector::action received oneKey " << static_cast<char>(ch) << 
                                                                        endl;

    if (accept(ch, s_inc, block.prompt))        // go to the next block
        return INC;

    if (accept(ch, s_dec, block.prompt))        // to the previous block
        return DEC;

    string blockChars = s_allChars.substr(0, block.end - block.begin);

    if (size_t idx = blockChars.find(ch); idx != string::npos)
        d_index = block.begin + idx;
    else 
        d_index = block.end;

    if (isspace(ch))                            // change space chars to ' ' 
        ch = ' ';                               // to prevent extra prompt

    if (d_index < block.end)                    // directory was selected
        chdir();                                // chdir to the alt.[d_index]
    else
        noCD(ch);                               // at --input: shell-input 
                                                // the entered character
    return Action::INPUT;
}