~vcs-imports/mousepad/trunk

« back to all changes in this revision

Viewing changes to mousepad/mousepad-window.c

  • Committer: Matthew Brush
  • Author(s): Tamaranch
  • Date: 2020-06-05 01:12:36 UTC
  • Revision ID: git-v1:d4e7368aa92dc7690cb08a3e61849cd86d387fbb
Add regex search

Closes #1, #9

Show diffs side-by-side

added added

removed removed

Lines of Context:
3399
3399
 
3400
3400
  g_return_val_if_fail (MOUSEPAD_IS_WINDOW (window), -1);
3401
3401
 
3402
 
  if (flags & MOUSEPAD_SEARCH_FLAGS_ACTION_HIGHTLIGHT)
3403
 
    {
3404
 
      /* highlight all the matches */
3405
 
      nmatches = mousepad_util_highlight (window->active->buffer, window->active->tag, string, flags);
3406
 
    }
3407
 
  else if (flags & MOUSEPAD_SEARCH_FLAGS_ALL_DOCUMENTS)
 
3402
  if (flags & MOUSEPAD_SEARCH_FLAGS_ACTION_HIGHLIGHT_ON)
 
3403
    gtk_source_search_context_set_highlight (window->active->search_context, TRUE);
 
3404
  else if (flags & MOUSEPAD_SEARCH_FLAGS_ACTION_HIGHLIGHT_OFF)
 
3405
    gtk_source_search_context_set_highlight (window->active->search_context, FALSE);
 
3406
  else if (flags & MOUSEPAD_SEARCH_FLAGS_AREA_ALL_DOCUMENTS)
3408
3407
    {
3409
3408
      /* get the number of documents in this window */
3410
3409
      npages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook));
3416
3415
          document = gtk_notebook_get_nth_page (GTK_NOTEBOOK (window->notebook), i);
3417
3416
 
3418
3417
          /* replace the matches in the document */
3419
 
          nmatches += mousepad_util_search (MOUSEPAD_DOCUMENT (document)->buffer, string, replacement, flags);
 
3418
          nmatches += mousepad_util_search (MOUSEPAD_DOCUMENT (document)->search_context, string,
 
3419
                                            replacement, flags);
3420
3420
        }
3421
3421
    }
3422
3422
  else if (window->active != NULL)
3423
3423
    {
3424
3424
      /* search or replace in the active document */
3425
 
      nmatches = mousepad_util_search (window->active->buffer, string, replacement, flags);
 
3425
      nmatches = mousepad_util_search (window->active->search_context, string, replacement, flags);
3426
3426
 
3427
3427
      /* make sure the selection is visible */
3428
 
      if (flags & (MOUSEPAD_SEARCH_FLAGS_ACTION_SELECT | MOUSEPAD_SEARCH_FLAGS_ACTION_REPLACE) && nmatches > 0)
 
3428
      if (flags & (MOUSEPAD_SEARCH_FLAGS_ACTION_SELECT | MOUSEPAD_SEARCH_FLAGS_ACTION_REPLACE)
 
3429
          && nmatches > 0)
3429
3430
        mousepad_view_scroll_to_cursor (window->active->textview);
3430
3431
    }
3431
3432
  else
3452
3453
  g_return_if_fail (MOUSEPAD_IS_SEARCH_BAR (window->search_bar));
3453
3454
 
3454
3455
  /* setup flags */
3455
 
  flags = MOUSEPAD_SEARCH_FLAGS_ACTION_HIGHTLIGHT
3456
 
          | MOUSEPAD_SEARCH_FLAGS_ACTION_CLEANUP;
 
3456
  flags = MOUSEPAD_SEARCH_FLAGS_ACTION_HIGHLIGHT_OFF;
3457
3457
 
3458
3458
  /* remove the highlight */
3459
3459
  mousepad_window_search (window, flags, NULL, NULL);