Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
E
esc_pos_print_plus
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dio Maulana
esc_pos_print_plus
Commits
3e88f053
Commit
3e88f053
authored
Jun 12, 2019
by
Andrey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added generic _print method
parent
0db38e74
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
15 deletions
+23
-15
commands.dart
lib/src/commands.dart
+1
-0
pos_string.dart
lib/src/pos_string.dart
+0
-2
printer.dart
lib/src/printer.dart
+22
-13
No files found.
lib/src/commands.dart
View file @
3e88f053
...
...
@@ -26,6 +26,7 @@ const cFontB = '${esc}M1'; // Font B
const
cAlignLeft
=
'
${esc}
a0'
;
// Left justification
const
cAlignCenter
=
'
${esc}
a1'
;
// Centered
const
cAlignRight
=
'
${esc}
a2'
;
// Right justification
const
cPos
=
'
$esc
\$
'
;
// Set absolute print position [nL] [nH]
// Print
const
cFeedN
=
'
${esc}
d'
;
// Print and feed n lines [N]
...
...
lib/src/pos_string.dart
View file @
3e88f053
...
...
@@ -10,7 +10,6 @@ class PosString {
this
.
height
=
PosTextSize
.
size1
,
this
.
width
=
PosTextSize
.
size1
,
this
.
fontType
=
PosFontType
.
fontA
,
this
.
linesAfter
=
0
,
});
String
text
;
...
...
@@ -21,7 +20,6 @@ class PosString {
PosTextSize
height
=
PosTextSize
.
size1
;
PosTextSize
width
=
PosTextSize
.
size1
;
PosFontType
fontType
=
PosFontType
.
fontA
;
int
linesAfter
=
0
;
@override
String
toString
()
{
...
...
lib/src/printer.dart
View file @
3e88f053
...
...
@@ -30,7 +30,13 @@ class Printer {
_socket
.
destroy
();
}
void
println
(
PosString
data
)
{
/// colInd range: 0..11
void
_print
(
PosString
data
,
{
int
colInd
=
0
,
int
linesAfter
=
0
})
{
final
int
pos
=
colInd
==
0
?
0
:
(
512
*
colInd
/
11
-
1
).
round
();
final
hexStr
=
pos
.
toRadixString
(
16
).
padLeft
(
3
,
'0'
);
final
hexPair
=
HEX
.
decode
(
hexStr
);
// print('dec: $pos \t hex: $hexStr \t pair $hexPair');
_socket
.
write
(
data
.
bold
?
cBoldOn
:
cBoldOff
);
_socket
.
write
(
data
.
reverse
?
cReverseOn
:
cReverseOff
);
_socket
.
write
(
data
.
underline
?
cUnderline1dot
:
cUnderlineOff
);
...
...
@@ -45,9 +51,20 @@ class Printer {
..
add
(
PosTextSize
.
decSize
(
data
.
height
,
data
.
width
)),
),
);
// Position
_socket
.
add
(
Uint8List
.
fromList
(
List
.
from
(
cPos
.
codeUnits
)..
addAll
([
hexPair
[
1
],
hexPair
[
0
]]),
),
);
_socket
.
writeln
(
data
.
text
);
emptyLines
(
data
.
linesAfter
);
_socket
.
write
(
data
.
text
);
}
void
println
(
PosString
data
,
{
int
linesAfter
=
0
})
{
_print
(
data
,
linesAfter:
linesAfter
);
_socket
.
writeln
();
emptyLines
(
linesAfter
);
reset
();
}
...
...
@@ -66,19 +83,11 @@ class Printer {
for
(
int
i
=
0
;
i
<
cols
.
length
;
++
i
)
{
final
colInd
=
cols
.
sublist
(
0
,
i
).
fold
(
0
,
(
int
sum
,
cur
)
=>
sum
+
cur
);
_print
Col
(
colInd
,
data
[
i
]
);
_print
(
data
[
i
],
colInd:
colInd
);
}
_socket
.
writeln
();
}
void
_printCol
(
int
i
,
PosString
data
)
{
final
int
pos
=
i
==
0
?
0
:
(
512
*
i
/
11
-
1
).
round
();
final
hexStr
=
pos
.
toRadixString
(
16
).
padLeft
(
3
,
'0'
);
final
hexPair
=
HEX
.
decode
(
hexStr
);
// print('dec: $pos \t hex: $hexStr \t pair $hexPair');
_socket
.
add
(
Uint8List
.
fromList
([
0x1b
,
0x24
,
hexPair
[
1
],
hexPair
[
0
]]));
_socket
.
write
(
data
);
reset
();
}
void
beep
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment