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
211f5282
Commit
211f5282
authored
Sep 14, 2019
by
Andrey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Can print rows/cols with mixed chinese/non-chinese texts.
parent
422ba482
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
15 deletions
+42
-15
pos_column.dart
lib/src/pos_column.dart
+2
-0
printer.dart
lib/src/printer.dart
+40
-15
No files found.
lib/src/pos_column.dart
View file @
211f5282
...
...
@@ -12,6 +12,7 @@ import 'pos_styles.dart';
class
PosColumn
{
PosColumn
({
this
.
text
=
''
,
this
.
containsChinese
=
false
,
this
.
width
=
2
,
this
.
styles
=
const
PosStyles
(),
})
{
...
...
@@ -21,6 +22,7 @@ class PosColumn {
}
String
text
;
bool
containsChinese
;
int
width
;
PosStyles
styles
;
}
lib/src/printer.dart
View file @
211f5282
...
...
@@ -165,19 +165,14 @@ class Printer {
}
}
/// Prints one line of styled mixed (chinese and latin symbols) text
void
_printlnMixedKanji
(
String
text
,
{
PosStyles
styles
=
const
PosStyles
(),
int
linesAfter
=
0
,
})
{
// Break text into lexemes
final
List
<
String
>
lexemes
=
[];
final
List
<
bool
>
isLexemeChinese
=
[];
/// Break text into chinese/non-chinese lexemes
List
_getLexemes
(
String
text
)
{
bool
_isChinese
(
String
ch
)
{
return
ch
.
codeUnitAt
(
0
)
>
255
?
true
:
false
;
}
final
List
<
String
>
lexemes
=
[];
final
List
<
bool
>
isLexemeChinese
=
[];
int
start
=
0
;
int
end
=
0
;
bool
curLexemeChinese
=
_isChinese
(
text
[
0
]);
...
...
@@ -195,6 +190,19 @@ class Printer {
lexemes
.
add
(
text
.
substring
(
start
,
end
+
1
));
isLexemeChinese
.
add
(
curLexemeChinese
);
return
<
dynamic
>[
lexemes
,
isLexemeChinese
];
}
/// Prints one line of styled mixed (chinese and latin symbols) text
void
_printlnMixedKanji
(
String
text
,
{
PosStyles
styles
=
const
PosStyles
(),
int
linesAfter
=
0
,
})
{
final
list
=
_getLexemes
(
text
);
final
List
<
String
>
lexemes
=
list
[
0
];
final
List
<
bool
>
isLexemeChinese
=
list
[
1
];
// Print each lexeme using codetable OR kanji
for
(
var
i
=
0
;
i
<
lexemes
.
length
;
++
i
)
{
_print
(
...
...
@@ -250,12 +258,29 @@ class Printer {
for
(
int
i
=
0
;
i
<
cols
.
length
;
++
i
)
{
final
colInd
=
cols
.
sublist
(
0
,
i
).
fold
(
0
,
(
int
sum
,
col
)
=>
sum
+
col
.
width
);
if
(!
cols
[
i
].
containsChinese
)
{
_print
(
cols
[
i
].
text
,
styles:
cols
[
i
].
styles
,
colInd:
colInd
,
colWidth:
cols
[
i
].
width
,
);
}
else
{
final
list
=
_getLexemes
(
cols
[
i
].
text
);
final
List
<
String
>
lexemes
=
list
[
0
];
final
List
<
bool
>
isLexemeChinese
=
list
[
1
];
// Print each lexeme using codetable OR kanji
for
(
var
j
=
0
;
j
<
lexemes
.
length
;
++
j
)
{
_print
(
lexemes
[
j
],
styles:
cols
[
i
].
styles
,
colInd:
colInd
,
colWidth:
cols
[
i
].
width
,
kanjiOff:
!
isLexemeChinese
[
j
],
);
}
}
}
_socket
.
writeln
();
...
...
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