1 /*
2 * calltip.c
3 *
4 * Copyright 2011 Alexander Petukhov <devel(at)apetukhov(dot)ru>
5 *
6 * This program 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 * This program 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 this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 * MA 02110-1301, USA.
20 */
21
22 /*
23 * Formatting calltip text.
24 */
25
26 #include <gtk/gtk.h>
27
28 #include "breakpoint.h"
29 #include "debug_module.h"
30 #include "calltip.h"
31
32 #define FIRST_LINE "\002\t%s = (%s) %s"
33 #define FIRST_LINE_NO_CHILDERN "%s = (%s) %s"
34 #define REST_LINES "\t▸\t%s = (%s) %s"
35 #define REST_LINES_NO_CHILDERN "\t\t%s = (%s) %s"
36
37 /*
38 * creates text for a tooltip taking list or variables
39 */
get_calltip_line(variable * var,gboolean firstline)40 GString* get_calltip_line(variable *var, gboolean firstline)
41 {
42 GString *calltip = NULL;
43 if (var && var->evaluated)
44 {
45 calltip = g_string_new("");
46 if (firstline)
47 {
48 g_string_append_printf(calltip,
49 var->has_children ? FIRST_LINE : FIRST_LINE_NO_CHILDERN,
50 var->name->str,
51 var->type->str,
52 var->value->str);
53 }
54 else
55 {
56 g_string_append_printf(calltip,
57 var->has_children ? REST_LINES : REST_LINES_NO_CHILDERN,
58 var->name->str,
59 var->type->str,
60 var->value->str);
61 }
62
63 if (calltip->len > MAX_CALLTIP_LENGTH)
64 {
65 g_string_truncate(calltip, MAX_CALLTIP_LENGTH);
66 g_string_append(calltip, " ...");
67 }
68 }
69
70 return calltip;
71 }
72
73