"Fossies" - the Fresh Open Source Software Archive

Member "regexxer-0.10/src/filebuffer.h" (6 Oct 2011, 4255 Bytes) of package /linux/privat/old/regexxer-0.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "filebuffer.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (c) 2002-2007  Daniel Elstner  <daniel.kitta@gmail.com>
    3  *
    4  * This file is part of regexxer.
    5  *
    6  * regexxer is free software; you can redistribute it and/or modify
    7  * it under the terms of the GNU General Public License as published by
    8  * the Free Software Foundation; either version 2 of the License, or
    9  * (at your option) any later version.
   10  *
   11  * regexxer is distributed in the hope that it will be useful,
   12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14  * GNU General Public License for more details.
   15  *
   16  * You should have received a copy of the GNU General Public License
   17  * along with regexxer; if not, write to the Free Software Foundation,
   18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   19  */
   20 
   21 #ifndef REGEXXER_FILEBUFFER_H_INCLUDED
   22 #define REGEXXER_FILEBUFFER_H_INCLUDED
   23 
   24 #include "fileshared.h"
   25 #include "signalutils.h"
   26 #include "undostack.h"
   27 
   28 #include <gtksourceviewmm/buffer.h>
   29 #include <set>
   30 #include <stack>
   31 
   32 
   33 namespace Regexxer
   34 {
   35 
   36 class FileBufferActionRemoveMatch;
   37 
   38 
   39 class FileBuffer : public Gsv::Buffer
   40 {
   41 public:
   42   static Glib::RefPtr<FileBuffer> create();
   43   static Glib::RefPtr<FileBuffer> create_with_error_message(
   44       const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, const Glib::ustring& message);
   45 
   46   static void pango_context_changed(const Glib::RefPtr<Pango::Context>& context);
   47 
   48   virtual ~FileBuffer();
   49 
   50   bool is_freeable() const;
   51   bool in_user_action() const;
   52 
   53   int find_matches(const Glib::RefPtr<Glib::Regex>& pattern, bool multiple,
   54                    const sigc::slot<void, int, const Glib::ustring&>& feedback);
   55 
   56   int get_match_count() const;
   57   int get_match_index() const;
   58   int get_original_match_count() const;
   59 
   60   Glib::RefPtr<Mark> get_next_match(bool move_forward);
   61   void forget_current_match();
   62 
   63   BoundState get_bound_state();
   64 
   65   void replace_current_match(const Glib::ustring& substitution);
   66   void replace_all_matches(const Glib::ustring& substitution);
   67 
   68   int get_line_preview(const Glib::ustring& substitution, Glib::ustring& preview);
   69 
   70   // Special API for the FileBufferAction classes.
   71   void increment_stamp();
   72   void decrement_stamp();
   73   void undo_remove_match(const MatchDataPtr& match, int offset);
   74   void undo_add_weak(FileBufferActionRemoveMatch* ptr);
   75   void undo_remove_weak(FileBufferActionRemoveMatch* ptr);
   76 
   77   sigc::signal<void>                signal_match_count_changed;
   78   sigc::signal<void>                signal_bound_state_changed;
   79   Util::QueuedSignal                signal_preview_line_changed;
   80   sigc::signal<bool>                signal_pulse;
   81   sigc::signal<void, UndoActionPtr> signal_undo_stack_push;
   82 
   83 protected:
   84   FileBuffer();
   85 
   86   virtual void on_insert(const iterator& pos, const Glib::ustring& text, int bytes);
   87   virtual void on_erase(const iterator& rbegin, const iterator& rend);
   88   virtual void on_mark_deleted(const Glib::RefPtr<Mark>& mark);
   89   virtual void on_apply_tag(const Glib::RefPtr<Tag>& tag,
   90                             const iterator& range_begin, const iterator& range_end);
   91   virtual void on_modified_changed();
   92   virtual void on_begin_user_action();
   93   virtual void on_end_user_action();
   94 
   95 private:
   96   class ScopedLock;
   97   class ScopedUserAction;
   98 
   99   typedef std::set<MatchDataPtr, MatchDataLess>     MatchSet;
  100   typedef std::stack<FileBufferActionRemoveMatch*>  WeakUndoStack;
  101 
  102   MatchSet            match_set_;
  103   MatchSet::iterator  current_match_;
  104   UndoStackPtr        user_action_stack_;
  105   WeakUndoStack       weak_undo_stack_;
  106   int                 match_count_;
  107   int                 original_match_count_;
  108   unsigned long       stamp_modified_;
  109   unsigned long       stamp_saved_;
  110   BoundState          cached_bound_state_;
  111   bool                match_removed_;
  112   bool                locked_;
  113 
  114   void replace_match(MatchSet::const_iterator pos, const Glib::ustring& substitution);
  115   void remove_match_at_iter(const iterator& start);
  116 
  117   void remove_tag_current();
  118   void apply_tag_current();
  119 
  120   static bool is_match_start(const iterator& where);
  121   static void find_line_bounds(iterator& line_begin, iterator& line_end);
  122 
  123   void update_bound_state();
  124   void notify_weak_undos();
  125 };
  126 
  127 } // namespace Regexxer
  128 
  129 #endif /* REGEXXER_FILEBUFFER_H_INCLUDED */