source: branches/stable/EDIT4/ed4_edit_string.hxx

Last change on this file was 18450, checked in by westram, 5 years ago
  • ED4_work_info:
    • use auto instance in executeKeystroke().
    • move → ed4_edit_string.hxx
    • pass down parent workinfo const into call_edit().
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : ed4_edit_string.hxx                               //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#ifndef ED4_EDIT_STRING_HXX
12#define ED4_EDIT_STRING_HXX
13
14#ifndef ED4_DEFS_HXX
15#include "ed4_defs.hxx"
16#endif
17#ifndef CHARTABLE_H
18#include <chartable.h>
19#endif
20
21class ED4_remap;
22
23const char SEQ_POINT = '.';
24
25inline bool ED4_is_gap_character(char chr) { return BaseFrequencies::isGap(safeCharIndex(chr)); } // defined via user setting (ED4_AWAR_GAP_CHARS)
26void ED4_setup_gaps_and_alitype(const char *gap_chars, GB_alignment_type alitype);
27
28struct ED4_work_info {
29    AW_event  event;
30    GBDATA   *gb_data;
31    char     *string;           // pointer to consensus; only if editing the consensus
32    long      char_position;    // screen position after cursor
33
34    bool rightward; // contains direction of editing (0 = leftward, 1 = rightward)
35
36    ED4_EDITMODE mode;
37
38    bool is_sequence;   // ==1 -> special handling for sequences
39    bool cannot_handle; // if TRUE then cannot edit
40
41    ED4_CursorJumpType cursor_jump;
42    bool               refresh_needed;
43
44    long out_seq_position; // sequence position (after editing)
45
46    char *out_string; // nur falls new malloc
47
48    int     repeat_count;       // only for keystrokes: contains # of times key should be repeated
49
50    ED4_terminal *working_terminal; // this contains the terminal
51};
52
53class ED4_Edit_String : virtual Noncopyable {
54    GBDATA *gbd;
55
56    char *seq;
57    long  seq_len;
58
59    char *old_seq;
60    long  old_seq_len;
61
62    ED4_remap *remap;
63
64    static int nrepeat; // @@@ reimplement repeat mechanism? this is a bad hack :-(
65    static int nrepeat_is_already_set;
66    static int nrepeat_zero_requested;
67
68    int legal_curpos(long pos) const            { return pos>=0 && pos<=seq_len; }
69    int legal_seqpos(long pos) const            { return pos>=0 && pos<seq_len; }
70
71    GB_ERROR moveBase(long source_position, long dest_position, unsigned char gap_to_use); // moves a base from source_position to dest_position
72
73    GB_ERROR shiftBases(long source_pos, long source_endpos, long dest_position,
74                        int direction, long *dest_endpos, unsigned char gap_to_use); // shifts a line of bases from source_position to dest_position
75
76    long get_next_base(long seq_position, int direction);
77    long get_next_gap(long seq_position, int direction);
78
79    long get_next_visible_base(long position, int direction);
80    long get_next_visible_gap(long position, int direction);
81    long get_next_visible_pos(long position, int direction);
82
83    GB_ERROR insert(char *, long position, int direction, int removeAtNextGap);
84    GB_ERROR remove(int len, long position, int direction, int insertAtNextGap);
85    GB_ERROR replace(char *text, long position, int direction);
86    GB_ERROR swap_gaps(long position, char ch);
87
88    GB_ERROR command(AW_key_mod keymod, AW_key_code keycode, char key, int direction, ED4_EDITMODE mode, bool is_consensus,
89                     long &cursorpos, bool& changed_flag, ED4_CursorJumpType& cursor_jump, bool& cannot_handle, bool& write_fault, GBDATA *gb_data, bool is_sequence);
90
91    unsigned char get_gap_type(long pos, int direction);
92
93public:
94
95    ED4_Edit_String();
96    GB_ERROR edit(ED4_work_info *info) __ATTR__USERESULT;
97    void finish_edit();
98    ~ED4_Edit_String();
99
100    int use_nrepeat() { // external functions use this to get and use nrepeat
101        int nrep = nrepeat==0 ? 1 : nrepeat;
102        nrepeat = 0;
103        return nrep;
104    }
105};
106
107#else
108#error ed4_edit_string.hxx included twice
109#endif // ED4_EDIT_STRING_HXX
Note: See TracBrowser for help on using the repository browser.