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
c4025e03
Commit
c4025e03
authored
Jun 12, 2019
by
Andrey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added emptyLines function. Updated example.
parent
fcfd5f77
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
23 deletions
+17
-23
example.dart
example/example.dart
+7
-1
printer.dart
lib/src/printer.dart
+10
-22
No files found.
example/example.dart
View file @
c4025e03
...
@@ -2,7 +2,13 @@ import 'package:esc_pos_printer/esc_pos_printer.dart';
...
@@ -2,7 +2,13 @@ import 'package:esc_pos_printer/esc_pos_printer.dart';
main
()
{
main
()
{
Printer
.
connect
(
'192.168.0.123'
).
then
((
printer
)
{
Printer
.
connect
(
'192.168.0.123'
).
then
((
printer
)
{
printer
.
println
(
'hello world :)'
);
printer
.
println
(
'Normal text'
);
printer
.
println
(
'Bold text'
,
bold:
true
);
printer
.
println
(
'Reverse text'
,
reverse:
true
);
printer
.
println
(
'Underlined text'
,
underline:
true
);
printer
.
println
(
'Align left'
,
align:
TextAlign
.
left
);
printer
.
println
(
'Align center'
,
align:
TextAlign
.
center
);
printer
.
println
(
'Align right'
,
align:
TextAlign
.
right
);
printer
.
cut
();
printer
.
cut
();
...
...
lib/src/printer.dart
View file @
c4025e03
...
@@ -40,30 +40,15 @@ class Printer {
...
@@ -40,30 +40,15 @@ class Printer {
_socket
.
destroy
();
_socket
.
destroy
();
}
}
// void writeAll(Iterable objects, [String separator = '']) {
// socket.writeAll(objects, separator);
// }
// void writeLine([Object obj = '']) {
// socket.writeln(obj);
// }
// void write(Object obj) {
// socket.write(obj);
// }
// TODO charHeight, charWidth range ?
// TODO should be ended by \n
void
println
(
void
println
(
Object
text
,
{
String
text
,
{
bool
bold
=
false
,
bool
bold
=
false
,
bool
reverse
=
false
,
bool
reverse
=
false
,
bool
underline
=
false
,
bool
underline
=
false
,
TextAlign
align
=
TextAlign
.
left
,
TextAlign
align
=
TextAlign
.
left
,
int
charHeight
=
-
1
,
int
charHeight
=
-
1
,
// TODO replace by font size
int
charWidth
=
-
1
,
int
charWidth
=
-
1
,
int
linesAfter
=
-
1
,
int
linesAfter
=
0
,
})
{
})
{
_socket
.
write
(
bold
?
cBoldOn
:
cBoldOff
);
_socket
.
write
(
bold
?
cBoldOn
:
cBoldOff
);
_socket
.
write
(
reverse
?
cReverseOn
:
cReverseOff
);
_socket
.
write
(
reverse
?
cReverseOn
:
cReverseOff
);
...
@@ -78,10 +63,7 @@ class Printer {
...
@@ -78,10 +63,7 @@ class Printer {
}
}
_socket
.
writeln
(
text
);
_socket
.
writeln
(
text
);
emptyLines
(
linesAfter
);
feed
(
linesAfter
);
// reset all to default
reset
();
reset
();
}
}
...
@@ -89,6 +71,12 @@ class Printer {
...
@@ -89,6 +71,12 @@ class Printer {
_socket
.
write
(
cInit
);
_socket
.
write
(
cInit
);
}
}
void
emptyLines
(
int
n
)
{
if
(
n
>
0
)
{
_socket
.
write
(
List
.
filled
(
n
,
'
\n
'
).
join
());
}
}
void
feed
(
int
n
)
{
void
feed
(
int
n
)
{
if
(
n
>=
0
&&
n
<=
255
)
{
if
(
n
>=
0
&&
n
<=
255
)
{
_socket
.
writeAll
([
cFeedN
,
n
.
toString
()]);
_socket
.
writeAll
([
cFeedN
,
n
.
toString
()]);
...
...
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