68 int default_cpp =
int(default_lpp * xy_ratio);
90 int default_cpp =
int(default_lpp * xy_ratio);
91 int mag = 100 * default_cpp * dx / x;
101 if (dy > 99) dy = 99;
104 int mag = 100 * default_lpp * dy /
y;
126 for (s = text;
s; s=ns) {
127 ns = strchr(s,
'\n');
132 int slen = strlen(s);
145 static void write_file(
const char *filename,
const char *file) {
146 fprintf(stderr,
"Printing to ASCII file '%s'\n", filename);
147 FILE *f = fopen(filename,
"r");
154 f = fopen(filename,
"w");
159 fprintf(f,
"%s", file);
195 char *y_begin = text;
202 int default_cpp =
int(default_lpp * xy_ratio);
203 default_cpp = default_cpp * 100 / mag;
204 default_lpp = default_lpp * 100 / mag;
212 for (y = 0; y < text_height; y += default_lpp) {
215 y_begin = strchr(y_begin,
'\n');
221 for (x = 0; x < text_width; x += default_cpp) {
222 char *
line = y_begin;
224 for (i=0; i<default_lpp; i++) {
226 char *next_line = strchr(line,
'\n');
229 line_length = next_line -
line;
233 line_length = strlen(line);
235 if (line_length > x + default_cpp) {
236 line_length = x + default_cpp;
238 if (line_length > x) {
239 fwrite(line + x,
sizeof(
char), line_length - x, tmpf);
249 char *a2ps_call =
NULp;
252 const char *oristring =
"";
255 oristring =
"-p -1 ";
258 oristring =
"-l -1 ";
261 oristring =
"-p -2 ";
267 quotedHeaderArg, oristring, default_lpp, tmp_file);
268 free(quotedHeaderArg);
271 const char *scall =
NULp;
282 fprintf(stderr,
"Printing to PS file %s\n", quotedFile);
300 a2ps_call, tmp_file2,
302 tmp_file, tmp_file2);
321 static void cutExt(
char *name,
const char *removeExt) {
322 char *found = strstr(name, removeExt);
323 if (found && strcmp(found, removeExt) == 0) {
332 char *
result = ARB_alloc<char>(strlen(noExt)+strlen(newExt)+1);
333 strcpy(result, noExt);
334 strcat(result, newExt);
335 if (strcmp(name, result) == 0) freenull(result);
346 char *new_name =
NULp;
363 static AW_window_simple *aws =
NULp;
373 aws =
new AW_window_simple;
374 aws->init(awr,
"PRINT",
"PRINT");
375 aws->load_xfig(
"awt/ascii_print.fig");
396 if (getenv(
"PRINTER")) {
411 aws->create_button(
"CLOSE",
"CLOSE");
415 aws->create_button(
"HELP",
"HELP");
419 aws->create_button(
"PRINT",
"PRINT");
427 aws->button_length(5);
434 aws->at(
"magnification");
437 aws->at(
"paper_size");
440 aws->insert_toggle(
"A4",
"A",
int(AWT_APRINT_PAPERSIZE_A4));
442 aws->update_toggle_field();
445 aws->at(
"orientation");
448 aws->insert_toggle(
"#print/portrait.xpm",
"P",
int(AWT_APRINT_ORIENTATION_PORTRAIT));
450 aws->update_toggle_field();
472 aws->update_toggle_field();
GB_ERROR GBK_system(const char *system_command)
#define AWAR_APRINT_PAPER_SIZE
static void cutExt(char *name, const char *removeExt)
#define AWAR_APRINT_PRINTTO
#define AWAR_APRINT_PRINTER
char * ARB_strdup(const char *str)
const char * GBS_global_string(const char *templat,...)
void AW_POPDOWN(AW_window *window)
static char * correct_extension(const char *name, const char *newExt)
char * GBS_replace_tabs_by_spaces(const char *text)
GB_CSTR GB_getenvARB_GS(void)
#define AWAR_APRINT_TITLE
AW_awar * add_callback(const RootCallback &cb)
const char * read_char_pntr() const
GB_ERROR GB_await_error()
static void awt_aps_go(AW_window *aww)
WindowCallback makeHelpCallback(const char *helpfile)
char * GB_create_tempfile(const char *name)
static void awt_aps_text_changed(AW_root *awr)
AWT_asciiprint_orientation
static void write_file(const char *filename, const char *file)
AW_awar * awar_float(const char *var_name, float default_value=0.0, AW_default default_file=AW_ROOT_DEFAULT)
static void error(const char *msg)
FILE * GB_fopen_tempfile(const char *filename, const char *fmode, char **res_fullname)
static void awt_aps_set_magnification_to_fit_xpage(AW_root *awr)
static double awt_aps_get_xy_ratio(AW_root *awr)
static void awt_aps_calc_pages_needed(AW_root *awr)
char * read_string() const
AW_awar * awar(const char *awar)
GB_CSTR GB_getenv(const char *env)
char * GB_unique_filename(const char *name_prefix, const char *suffix)
#define AWAR_APRINT_MAGNIFICATION
int aw_question(const char *unique_id, const char *question, const char *buttons, bool sameSizeButtons, const char *helpfile)
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
static char * printFile(AW_root *awr)
char * GBK_singlequote(const char *arg)
static int awt_aps_get_default_lines_per_page(AW_root *awr)
void AWT_create_ascii_print_window(AW_root *awr, const char *text_to_print, const char *title)
const char * name_only(const char *fullpath)
#define AWAR_APRINT_PAGES
void aw_message(const char *msg)
char * GBS_eval_env(GB_CSTR p)
void GB_split_full_path(const char *fullpath, char **res_dir, char **res_fullname, char **res_name_only, char **res_suffix)
static void aps_correct_filename(AW_root *aw_root)
void AWT_show_file(AW_root *awr, const char *filename)
GB_ERROR write_string(const char *aw_string)
static void awt_aps_set_magnification_to_fit_ypage(AW_root *awr)
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
GB_ERROR write_float(float aw_float)
AWT_asciiprint_destination
GB_ERROR write_int(long aw_int)
#define AWAR_APRINT_ORIENTATION
char * GBS_global_string_copy(const char *templat,...)
char * GB_read_file(const char *path)
GB_write_int const char s