Download
jcs
/amend
/committer.h
(View History)
jcs *: Use new focusable API | Latest amendment: 83 on 2022-08-16 |
1 | /* |
2 | * Copyright (c) 2021 joshua stein <jcs@jcs.org> |
3 | * |
4 | * Permission to use, copy, modify, and distribute this software for any |
5 | * purpose with or without fee is hereby granted, provided that the above |
6 | * copyright notice and this permission notice appear in all copies. |
7 | * |
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
15 | */ |
16 | |
17 | #ifndef __COMMITTER_H__ |
18 | #define __COMMITTER_H__ |
19 | |
20 | #include "browser.h" |
21 | #include "util.h" |
22 | |
23 | #define WAIT_DLOG_ID 128 |
24 | |
25 | enum { |
26 | COMMITTER_STATE_IDLE, |
27 | COMMITTER_STATE_DO_DIFF, |
28 | COMMITTER_STATE_DO_COMMIT |
29 | }; |
30 | |
31 | struct committer { |
32 | struct browser *browser; |
33 | WindowPtr win; |
34 | short state; |
35 | TEHandle log_te; |
36 | ControlHandle log_scroller; |
37 | TEHandle diff_te; |
38 | unsigned long diff_te_len; |
39 | ControlHandle diff_scroller; |
40 | ControlHandle commit_button; |
41 | short ndiffed_files; |
42 | struct diffed_file *diffed_files; |
43 | bool allow_commit; |
44 | short diff_adds; |
45 | short diff_subs; |
46 | bool diff_too_big; |
47 | #define DIFF_LINE_SIZE 512 |
48 | Handle diff_line; |
49 | size_t diff_line_pos; |
50 | #define DIFF_CHUNK_SIZE (1024 * 4) |
51 | Handle diff_chunk; |
52 | size_t diff_chunk_pos; |
53 | TEHandle last_te; |
54 | }; |
55 | |
56 | void committer_init(struct browser *browser); |
57 | void committer_generate_diff(struct committer *committer); |
58 | |
59 | size_t diff_output(const char *format, ...); |
60 | |
61 | #endif |