Module: IdEdit

Includes:
IdOperations
Included in:
Id
Defined in:
lib/id-edit.rb

Instance Method Summary collapse

Methods included from IdOperations

#process_operations

Instance Method Details

#edit(node) ⇒ Object



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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/id-edit.rb', line 6

def edit node
  @node = node
  @nodes[node] = [] if not @nodes[node]
  save
  while true
    @nodes["a"] = `ls`.split("\n")
    header node
    if line = readline
      @prompt = @default_prompt
      line = sub line
      if line == "#" 
        @msg = ""
        @raw = @raw.!
        if @raw
          @prompt = " # ".style("blue", "black")
        else
          @prompt = @default_prompt
        end
      elsif process_operations(line)
        msg ""
        edit node
      elsif op = parse_op(line, ";") and not @raw
        ins op[0]
        ins op[1]
        @promptnode = op[1]
        edit op[0]
      else
 
        @msg = ""
        save
        if line != ""
          if @nodes[node].find_index(line) or line == "e" and not @raw
            unless ["<", "%"].find_index line[0]
              @path << node
              node_changed
              edit line
            end
          else
            if @raw
              ins node, line
            else
              ins node, line unless line[-1] == "*" or line == "e"
            end
          end
        else
          back node
        end
      end
    else
      exit
    end
    save
  end
  @nodes["a"] = `ls`.split("\n")
end