3 * Copyright (c) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
4 * Copyright (c) 2008 Robert Ancell
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, or (at your option)
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
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., 59 Temple Place - Suite 330, Boston, MA
29 #define UNDO_HISTORY_LENGTH 16 /* Arithmetic mode undo history length */
30 #define MAX_DISPLAY 512
32 /* Expression mode state */
34 MPNumber ans
; /* Previously calculated answer */
35 char *expression
; /* Expression entered by user */
39 /* Circular list of Arithmetic Precedence Mode states*/
44 GCDisplayState e
[UNDO_HISTORY_LENGTH
]; /* Expression mode state */
47 /* Number display mode. */
48 typedef enum { ENG
, FIX
, SCI
, MAXDISPMODES
} DisplayFormat
;
52 GCDisplayHistory h
; /* History of expression mode states */
53 int show_tsep
; /* Set if the thousands separator should be shown. */
54 int show_zeroes
; /* Set if trailing zeroes should be shown. */
55 DisplayFormat format
; /* Number display mode. */
59 void display_init(GCDisplay
*);
60 void display_set_accuracy(GCDisplay
*display
, int accuracy
);
61 void display_set_show_thousands_separator(GCDisplay
*display
, gboolean visible
);
62 void display_set_show_trailing_zeroes(GCDisplay
*display
, gboolean visible
);
63 void display_set_base(GCDisplay
*display
, int base
);
64 void display_set_format(GCDisplay
*display
, DisplayFormat format
);
65 void display_clear(GCDisplay
*);
67 gboolean
display_get_integer(GCDisplay
*display
, gint64
*value
);
68 gboolean
display_get_unsigned_integer(GCDisplay
*display
, guint64
*value
);
69 MPNumber
*display_get_answer(GCDisplay
*);
70 int display_get_cursor(GCDisplay
*);
72 void display_set_number(GCDisplay
*display
, const MPNumber
*);
73 void display_set_answer(GCDisplay
*display
);
74 void display_set_string(GCDisplay
*display
, const char *, int);
75 void display_set_cursor(GCDisplay
*display
, int);
76 void display_set_error(GCDisplay
*display
, const char *);
78 void display_clear_stack(GCDisplay
*);
79 void display_push(GCDisplay
*);
80 void display_pop(GCDisplay
*);
81 void display_unpop(GCDisplay
*);
82 gboolean
display_is_undo_step(GCDisplay
*display
);
84 void display_insert(GCDisplay
*display
, int, const char *);
85 void display_insert_at_cursor(GCDisplay
*display
, const char *);
86 void display_insert_number(GCDisplay
*display
, int, const MPNumber
*);
87 void display_insert_number_at_cursor(GCDisplay
*display
, const MPNumber
*value
);
88 void display_backspace(GCDisplay
*);
89 void display_delete(GCDisplay
*);
90 void display_surround(GCDisplay
*display
, const char *, const char *);
92 gboolean
display_is_empty(GCDisplay
*);
93 gboolean
display_is_result(GCDisplay
*);
94 gboolean
display_is_usable_number(GCDisplay
*display
, MPNumber
*);
96 int display_solve(GCDisplay
*display
, MPNumber
*);
98 void display_make_number(GCDisplay
*display
, char *target
, int target_len
, const MPNumber
*MPnumber
, int base
, int ignoreError
);
100 #endif /* DISPLAY_H */