2 * (c) 2011 Cyrill Gorcunov, gorcunov@gmail.com
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or (at
7 * your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20 #include <sys/types.h>
29 #include "backend-proto.h"
34 /* #define DBG(msg, ...) debug(msg, __VA_ARGS__) */
38 static unsigned long idx_last
;
39 static unsigned long idx_current
;
41 static struct mark_item marks
[MARKS_LIMIT
];
42 static int do_push
= 1;
46 idx_last
= idx_current
= 0;
47 memset(marks
, 0, sizeof(marks
));
54 for (i
= 0; i
< idx_last
; i
++)
55 free(marks
[i
].file_path
);
57 idx_last
= idx_current
= 0;
60 void mark_push(struct backend_proto_item
*item
)
66 if (idx_last
>= MARKS_LIMIT
) {
67 idx_last
= MARKS_LIMIT
;
68 free(marks
[idx_last
- 1].file_path
);
71 DBG("%s: %s:%lu", __func__
, item
->file
, item
->line
);
73 idx_current
= idx_last
- 1;
75 marks
[idx_last
- 1].file_path
= xstrdup(item
->file
);
76 marks
[idx_last
- 1].line
= item
->line
;
79 static void mark_switch_to(struct gscope_info
*info
, unsigned long idx
)
81 struct backend_proto_item item
= { 0 };
83 item
.file
= marks
[idx
].file_path
;
84 item
.line
= marks
[idx
].line
;
87 query_switch_or_read_source_into_notebook(info
, &item
);
91 void mark_switch_to_next(struct gscope_info
*info
)
93 DBG("%s: %lu %lu", __func__
, idx_last
, idx_current
);
95 if (idx_last
&& idx_current
< idx_last
- 1) {
97 mark_switch_to(info
, idx_current
);
101 void mark_switch_to_prev(struct gscope_info
*info
)
103 DBG("%s: %lu %lu", __func__
, idx_last
, idx_current
);
105 if (idx_current
> 0) {
107 mark_switch_to(info
, idx_current
);