MCPcopy Create free account
hub / github.com/Genivia/ugrep / view

Method view

src/query.cpp:2361–2683  ·  view source on GitHub ↗

view or edit the file located under the cursor or just above in the screen (when not in selection mode)

Source from the content-addressed store, hash-verified

2359
2360// view or edit the file located under the cursor or just above in the screen (when not in selection mode)
2361void Query::view()
2362{
2363 if (row_ >= rows_ || flag_text || flag_format != NULL)
2364 {
2365 Screen::alert();
2366 return;
2367 }
2368
2369 // if no viewer, then give up
2370 if (flag_view == NULL || *flag_view == '\0' || (*flag_view == '+' && flag_view[1] == '\0'))
2371 {
2372 Screen::alert();
2373 return;
2374 }
2375
2376 bool keypress = (*flag_view == '+');
2377 std::string command(flag_view + keypress);
2378 int ref = select_ >= 0 ? select_ : row_;
2379 size_t line_number = 0;
2380
2381 // -n: extract line number from ugrep output if the specified pager supports +linenum
2382 if (flag_line_number &&
2383 !flag_files_with_matches &&
2384 !flag_count &&
2385 !flag_hex &&
2386 !flag_with_hex &&
2387 (command == "less" ||
2388 command == "moar-pager" ||
2389 command == "moar" ||
2390 command == "moor" ||
2391 command == "more" ||
2392 command == "most" ||
2393 command == "w3m" ||
2394 command == "emacs" ||
2395 command == "joe" ||
2396 command == "vi" ||
2397 command == "vim" ||
2398 command == "vis" ||
2399 command == "kak" ||
2400 command == "nano" ||
2401 command == "pico" ||
2402 command == "vile" ||
2403 command == "zile"))
2404 {
2405 line_number = get_line_number();
2406 }
2407
2408 std::string filename;
2409 std::string partname;
2410 bool found = false;
2411
2412 if (rows_ > 0)
2413 {
2414 if (flag_tree && (flag_files_with_matches || flag_count))
2415 {
2416 // --tree with -c or -l: move down over non-filename lines to reach a filename
2417 while (ref + 1 < rows_ && (view_[ref].empty() || view_[ref].front() != '\0'))
2418 ++ref;

Callers

nothing calls this directly

Calls 11

timer_startFunction · 0.85
ugrep_extractFunction · 0.85
timer_elapsedFunction · 0.85
atMethod · 0.80
utf8_decodeFunction · 0.70
statClass · 0.70
popenFunction · 0.70
pcloseFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected