📄 prnhnd.pro
字号:
project "register"
check_determ
include "globals.pro"
/****************************************************************
PRINTER TOOLS
=============
Controls printer output. Takes care of printer initialization,
pagelength and pageshift, indentation of leftmargin, printing
of foothers and headers and a possible character convertion.
Uses the global domain prn_file as printer output.
The predicates mk_foother and mk_header should be defined globally.
Print should be initiated by init_printer and finished by
close_printer.
Output should be performed by write_ch and write_str.
****************************************************************/
/* NESSECARRY GLOBAL DECLARATIONS
GLOBAL DOMAINS
file = prn_file
GLOBAL PREDICATES
/* init_printer(MARGIN,TOPMARGIN,PAGELENGTH,CHARCONV,INITCODE,PRINTDEST) */
determ init_printer(INTEGER,INTEGER,INTEGER,STRING,STRING,STRING)-(i,i,i,i,i,i)
determ close_printer
determ write_ch(CHAR) - (i)
determ write_str(STRING) - (i)
determ make_footer
determ make_header
determ check_page(STRING,INTEGER)-(i,i)
determ shift_page()
determ getpageno(INTEGER)-(o)
*/
/****************************************************************
Local database used as global information during output
****************************************************************/
DATABASE - prn_dba
prn_lineno(INTEGER) /* Current line number */
prn_pageno(INTEGER) /* Current page number */
prn_margin(INTEGER) /* Left margin */
prn_topmargin(INTEGER) /* Noof empty toplines */
prn_pagelength(INTEGER) /* Pagelength */
prn_charconv /* Character convertion */
/****************************************************************
HELP PREDICATES
****************************************************************/
PREDICATES
printercode(STRING)
count_lines(STRING,INTEGER,INTEGER)
inc_lineno
inc_lineno1(INTEGER)
inc_pageno
conv_char(CHAR,CHAR)
mk_margin(integer)
mk_topmargin(INTEGER)
setwritedevice(STRING,STRING)
CLAUSES
/* Interpreet escape sequences as: "\027I\001abc"
A backslash can be followed by an integer number
*/
printercode(""):-!.
printercode(CODE):-
frontchar(CODE,'\\',REST),
fronttoken(REST,NUM,RESTCODE),
str_int(NUM,CHI),
char_int(CH,CHI),
write(CH),!,
printercode(RESTCODE).
printercode(CODE):-
frontchar(CODE,CH,REST),
write(CH),
printercode(REST).
count_lines("",N,N):-!.
count_lines(STR,N,N1):-
frontchar(STR,'\n',STR1),!,
N2=N+1,
count_lines(STR1,N2,N1).
count_lines(STR,N,N1):-
frontchar(STR,_,STR1),
count_lines(STR1,N,N1).
inc_lineno:-
retract(prn_lineno(N)),!,
inc_lineno1(N).
inc_lineno.
inc_lineno1(N):-
prn_pagelength(N),!,
shift_page.
inc_lineno1(N):-
N1=N+1,
assert(prn_lineno(N1)).
inc_pageno:-
retract(prn_pageno(N)),!,
N1=N+1,
assert(prn_pageno(N1)).
mk_margin(0):-!.
mk_margin(N):-
write(' '),
N1=N-1,
mk_margin(N1).
conv_char('{','
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -