source: tags/initial/EDIT4/ed4_edit_string.hxx

Last change on this file was 2, checked in by oldcode, 23 years ago

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1
2struct ED4_work_info;
3
4//#define ALIGN_STRING ".-~?"   // characters allowed to change in align_mod
5//#define ADPP_IS_ALIGN_CHARACTER(chr) (strchr (ALIGN_STRING,chr))
6#define ADPP_IS_ALIGN_CHARACTER(chr) (ED4_is_align_character[chr]!=0)
7
8extern unsigned char ED4_is_align_character[255];
9void ED4_init_is_align_character(GB_CSTR gap_chars);
10
11const char SEQ_POINT = '.';
12
13class ED4_remap;
14
15class ED4_Edit_String {
16    GBDATA      *gbd;
17    char        *seq;
18    long        seq_len;
19    ED4_remap   *remap;
20    static int  nrepeat;
21    static int  nrepeat_is_already_set;
22    static int  nrepeat_zero_requested;
23   
24    int legal_curpos(long pos) const            { return pos>=0 && pos<=seq_len; }
25    int legal_seqpos(long pos) const            { return pos>=0 && pos<seq_len; }
26   
27    ED4_ERROR *moveBase(long source_position, long dest_position, unsigned char gap_to_use); // moves a base from source_position to dest_position
28   
29    ED4_ERROR *shiftBases(long source_pos, long source_endpos, long dest_position,
30                          int direction, long *dest_endpos, unsigned char gap_to_use); // shifts a line of bases from source_position to dest_position
31
32    long        get_next_base(long seq_position, int direction);
33    long        get_next_gap(long seq_position, int direction);
34   
35    long        get_next_visible_base(long position, int direction);
36    long        get_next_visible_gap(long position, int direction);
37    long        get_next_visible_pos(long position, int direction);
38
39    ED4_ERROR   *insert(char *,long position, int direction, int removeAtNextGap);
40    ED4_ERROR   *remove(int len,long position, int direction, int insertAtNextGap);
41    ED4_ERROR   *replace(char *text,long position, int direction);
42    ED4_ERROR   *swap_gaps(long position, char ch);
43    ED4_ERROR   *command( AW_key_mod keymod, AW_key_code keycode, char key, int direction, ED4_EDITMODI mode, bool is_consensus,
44                          long &cursorpos, bool& changed_flag, bool& center_cursor, bool& cannot_handle, bool& write_fault, GBDATA *gb_data, bool is_sequence);
45    unsigned char get_gap_type(long pos, int direction);
46
47public:
48    char *old_seq;
49    long old_seq_len;
50
51    ED4_Edit_String();
52    void init_edit();
53    void edit(ED4_work_info *info);
54    void finish_edit();
55    ~ED4_Edit_String();
56   
57    int use_nrepeat() { // external functions use this to get and use nrepeat
58        int nrep = nrepeat==0 ? 1 : nrepeat;
59        nrepeat = 0;
60        return nrep;
61    }
62};
63
Note: See TracBrowser for help on using the repository browser.