Diff of /inst/@dataframe/display.m [afaced] .. [591ef1]  Maximize  Restore

Switch to unified view

a/inst/@dataframe/display.m b/inst/@dataframe/display.m
...
...
32
  if (isempty (dummy))
32
  if (isempty (dummy))
33
    dummy = "ans";
33
    dummy = "ans";
34
  endif
34
  endif
35
35
36
  if (2 == length (df._cnt))
36
  if (2 == length (df._cnt))
37
    head = sprintf ("%s = dataframe with %d rows and %d columns", \
37
    head = sprintf ("%s = dataframe with %d rows and %d columns", ...
38
                    dummy, df._cnt);
38
                    dummy, df._cnt);
39
  else
39
  else
40
    head = sprintf ("%s = dataframe with %d rows and %d columns on %d pages", \
40
    head = sprintf ("%s = dataframe with %d rows and %d columns on %d pages", ...
41
                    dummy, df._cnt);
41
                    dummy, df._cnt);
42
  endif
42
  endif
43
43
44
  if (~isempty (df._src))
44
  if (~isempty (df._src))
45
    for indi = (1:size (df._src, 1))
45
    for indi = (1:size (df._src, 1))
46
      head = strvcat\
46
      head = strvcat...
47
          (head, [repmat("Src: ", size (df._src{indi, 1}, 1), 1)\
47
          (head, [repmat("Src: ", size (df._src{indi, 1}, 1), 1)...
48
                  df._src{indi, 1}]);
48
                  df._src{indi, 1}]);
49
    endfor
49
    endfor
50
  endif
50
  endif
51
51
52
  if (~isempty (df._cmt))
52
  if (~isempty (df._cmt))
53
    for indi = (1:size(df._cmt, 1))
53
    for indi = (1:size(df._cmt, 1))
54
      head = strvcat\
54
      head = strvcat...
55
          (head, [repmat("Comment: ", size (df._cmt{indi, 1}, 1), 1)\
55
          (head, [repmat("Comment: ", size (df._cmt{indi, 1}, 1), 1)...
56
                  df._cmt{indi, 1}]);
56
                  df._cmt{indi, 1}]);
57
    endfor
57
    endfor
58
  endif
58
  endif
59
  
59
  
60
  if (all (df._cnt > 0))  %# stop for empty df
60
  if (all (df._cnt > 0))  %# stop for empty df
...
...
107
        otherwise
107
        otherwise
108
          %# keep only one horizontal space per line
108
          %# keep only one horizontal space per line
109
          unfolded = df._data{indc}(:, df._rep{indc});
109
          unfolded = df._data{indc}(:, df._rep{indc});
110
          indk = 1; while (indk <= size (unfolded, 2))
110
          indk = 1; while (indk <= size (unfolded, 2))
111
            dummy{3, 2+indi} = disp (unfolded(:, indk));
111
            dummy{3, 2+indi} = disp (unfolded(:, indk));
112
            tmp_str = char (regexp (dummy{3, 2+indi}, \
112
            tmp_str = char (regexp (dummy{3, 2+indi}, ...
113
                                    '[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?(\s??[-+]\s??[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?i)?', \
113
                                    '[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?(\s??[-+]\s??[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?i)?', ...
114
                                    'match', 'dotexceptnewline'));
114
                                    'match', 'dotexceptnewline'));
115
            tmp_str = horzcat...
115
            tmp_str = horzcat...
116
                (vspace, char (regexp (dummy{3, 2+indi}, '\S.*', ...
116
                (vspace, char (regexp (dummy{3, 2+indi}, '\S.*', ...
117
                                       'match', 'dotexceptnewline')));
117
                                       'match', 'dotexceptnewline')));
118
            dummy{3, 2+indi} = tmp_str;
118
            dummy{3, 2+indi} = tmp_str;
...
...
125
    vspace = [' '; ' '; vspace];
125
    vspace = [' '; ' '; vspace];
126
    %# second line content
126
    %# second line content
127
    resu = []; 
127
    resu = []; 
128
    if (~isempty (df._ridx))
128
    if (~isempty (df._ridx))
129
      for (ind1 = 1:size (df._ridx, 2))
129
      for (ind1 = 1:size (df._ridx, 2))
130
        if ((1 == size(df._ridx, 3)) && \
130
        if ((1 == size(df._ridx, 3)) && ...
131
              (any (~isna (df._ridx(1:df._cnt(1), ind1)))))
131
              (any (~isna (df._ridx(1:df._cnt(1), ind1)))))
132
          dummy{2, 1} = [sprintf("_%d", ind1) ; "Nr"];
132
          dummy{2, 1} = [sprintf("_%d", ind1) ; "Nr"];
133
          dummy{3, 1} = disp (df._ridx(1:df._cnt(1), ind1)); 
133
          dummy{3, 1} = disp (df._ridx(1:df._cnt(1), ind1)); 
134
          indi = regexp (dummy{3, 1}, '\b.*\b', 'match', 'dotexceptnewline');
134
          indi = regexp (dummy{3, 1}, '\b.*\b', 'match', 'dotexceptnewline');
135
          if (isempty (resu))
135
          if (isempty (resu))
136
            resu = strjust (char (dummy{2, 1}, indi), 'right');
136
            resu = strjust (char (dummy{2, 1}, indi), 'right');
137
          else
137
          else
138
            resu = horzcat(resu, vspace, strjust (char (dummy{2, 1}, indi), \
138
            resu = horzcat(resu, vspace, strjust (char (dummy{2, 1}, indi), ...
139
                                                  'right'), vspace);
139
                                                  'right'), vspace);
140
          endif
140
          endif
141
        else 
141
        else 
142
          for ind2 = (1:size (df._ridx, 3))
142
          for ind2 = (1:size (df._ridx, 3))
143
            if (any (~isna (df._ridx(1:df._cnt(1), ind1, ind2)))),
143
            if (any (~isna (df._ridx(1:df._cnt(1), ind1, ind2)))),
...
...
145
              dummy{3, 1} = disp (df._ridx(1:df._cnt(1), ind1, ind2)); 
145
              dummy{3, 1} = disp (df._ridx(1:df._cnt(1), ind1, ind2)); 
146
              indi = regexp (dummy{3, 1}, '\b.*\b', 'match', 'dotexceptnewline');
146
              indi = regexp (dummy{3, 1}, '\b.*\b', 'match', 'dotexceptnewline');
147
              if (isempty (resu)) 
147
              if (isempty (resu)) 
148
                resu = strjust (char (dummy{2, 1}, indi), 'right');
148
                resu = strjust (char (dummy{2, 1}, indi), 'right');
149
              else
149
              else
150
                resu = horzcat (resu, vspace, strjust (char(dummy{2, 1}, indi), \
150
                resu = horzcat (resu, vspace, strjust (char(dummy{2, 1}, indi), ...
151
                                                       'right'), vspace);
151
                                                       'right'), vspace);
152
              endif
152
              endif
153
            endif
153
            endif
154
          endfor
154
          endfor
155
        endif
155
        endif
...
...
167
    %# insert a vertical space
167
    %# insert a vertical space
168
    if (~isempty (dummy{3, 2}))
168
    if (~isempty (dummy{3, 2}))
169
      indi = ~cellfun ('isempty', dummy{3, 2});
169
      indi = ~cellfun ('isempty', dummy{3, 2});
170
      if (any (indi))
170
      if (any (indi))
171
        try
171
        try
172
          resu = horzcat (resu, vspace, strjust (char(dummy{2, 2}, dummy{3, 2}),\
172
          resu = horzcat (resu, vspace, strjust (char(dummy{2, 2}, dummy{3, 2}),...
173
                                                 'right'));
173
                                                 'right'));
174
        catch
174
        catch
175
          disp ('line 172 '); keyboard
175
          disp ('line 172 '); keyboard
176
        end_try_catch
176
        end_try_catch
177
      endif
177
      endif
...
...
180
    %# emit each colum
180
    %# emit each colum
181
    for indi = (1:size (dummy, 2) - 2)
181
    for indi = (1:size (dummy, 2) - 2)
182
      %# was max(df._cnt(2:end)),
182
      %# was max(df._cnt(2:end)),
183
      try
183
      try
184
        %# avoid this column touching the previous one
184
        %# avoid this column touching the previous one
185
        if (any (cellfun ('size', dummy(1:2, 2+indi), 2) >= \
185
        if (any (cellfun ('size', dummy(1:2, 2+indi), 2) >= ...
186
                 size (dummy{3, 2+indi}, 2)))
186
                 size (dummy{3, 2+indi}, 2)))
187
          resu = horzcat (resu, vspace);
187
          resu = horzcat (resu, vspace);
188
        endif
188
        endif
189
        resu = horzcat (resu, strjust (char (dummy{:, 2+indi}), 'right'));
189
        resu = horzcat (resu, strjust (char (dummy{:, 2+indi}), 'right'));
190
      catch
190
      catch