mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-12 22:56:06 +09:00
more XML
This commit is contained in:
@@ -90,6 +90,7 @@ object BTeXParser {
|
||||
private var currentTheme = ""
|
||||
private var spanColour: String? = null
|
||||
private var codeMode: Boolean = false
|
||||
private var hrefMode: Boolean = false
|
||||
private var bucksMode: Boolean = false
|
||||
|
||||
|
||||
@@ -189,7 +190,7 @@ object BTeXParser {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getOrPutCodeTagRef(width: Int): ((BTeXDrawCall) -> BTeXBatchDrawCall)? {
|
||||
/*private fun getOrPutCodeTagRef(width: Int): ((BTeXDrawCall) -> BTeXBatchDrawCall)? {
|
||||
val tagname = "TAG@CODE-$width"
|
||||
if (!objDict.contains(tagname)) {
|
||||
objWidthDict[tagname] = 0
|
||||
@@ -207,7 +208,7 @@ object BTeXParser {
|
||||
}
|
||||
}
|
||||
return objDict[tagname]
|
||||
}
|
||||
}*/
|
||||
|
||||
fun dispose() {
|
||||
if (::testFont.isInitialized) testFont.tryDispose()
|
||||
@@ -309,6 +310,7 @@ object BTeXParser {
|
||||
|
||||
private var oldSpanColour: String? = null
|
||||
private var oldCodeMode = false
|
||||
private var oldHrefMode = false
|
||||
private var oldBucksMode = false
|
||||
private val CODE_TAG_MARGIN = 2
|
||||
|
||||
@@ -339,18 +341,30 @@ object BTeXParser {
|
||||
if (codeMode != oldCodeMode || codeMode) {
|
||||
if (!codeMode) {
|
||||
paragraphBuffer.append(TerrarumSansBitmap.charsetOverrideDefault)
|
||||
paragraphBuffer.append(ccDefault)
|
||||
paragraphBuffer.append(glueToString(CODE_TAG_MARGIN))
|
||||
}
|
||||
else {
|
||||
// println("CODE tag for str '$str'")
|
||||
val w = getFont().getWidth(str) + 2*CODE_TAG_MARGIN
|
||||
getOrPutCodeTagRef(w)
|
||||
paragraphBuffer.appendObjectPlaceholder("TAG@CODE-${w}")
|
||||
// val w = getFont().getWidth(str) + 2*CODE_TAG_MARGIN
|
||||
// getOrPutCodeTagRef(w)
|
||||
// paragraphBuffer.appendObjectPlaceholder("TAG@CODE-${w}")
|
||||
paragraphBuffer.append(glueToString(CODE_TAG_MARGIN))
|
||||
paragraphBuffer.append(ccCode)
|
||||
paragraphBuffer.append(TerrarumSansBitmap.charsetOverrideCodestyle)
|
||||
}
|
||||
}
|
||||
|
||||
// process href request
|
||||
if (hrefMode != oldHrefMode || hrefMode) {
|
||||
if (!hrefMode) {
|
||||
paragraphBuffer.append(ccDefault)
|
||||
}
|
||||
else {
|
||||
paragraphBuffer.append(ccHref)
|
||||
}
|
||||
}
|
||||
|
||||
// process bucks request
|
||||
if (bucksMode != oldBucksMode || bucksMode) {
|
||||
if (!bucksMode) {
|
||||
@@ -369,6 +383,7 @@ object BTeXParser {
|
||||
|
||||
oldSpanColour = spanColour
|
||||
oldCodeMode = codeMode
|
||||
oldHrefMode = hrefMode
|
||||
oldBucksMode = bucksMode
|
||||
}
|
||||
}
|
||||
@@ -618,7 +633,7 @@ object BTeXParser {
|
||||
)
|
||||
|
||||
private val ccEmph = "#C11"// TerrarumSansBitmap.toColorCode(0xfd44)
|
||||
private val ccItemName = "#14C" // TerrarumSansBitmap.toColorCode(0xf37d)
|
||||
private val ccItemName = "#03B" // TerrarumSansBitmap.toColorCode(0xf37d)
|
||||
private val ccTargetName = "#170" // TerrarumSansBitmap.toColorCode(0xf3c4)
|
||||
|
||||
@OpenTag // reflective access is impossible with 'private'
|
||||
@@ -726,6 +741,15 @@ object BTeXParser {
|
||||
handler.codeMode = false
|
||||
}
|
||||
|
||||
@OpenTag // reflective access is impossible with 'private'
|
||||
fun processElemA(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||
handler.hrefMode = true
|
||||
}
|
||||
@CloseTag
|
||||
fun closeElemA(handler: BTeXHandler, doc: BTeXDocument, uri: String, siblingIndex: Int) {
|
||||
handler.hrefMode = false
|
||||
}
|
||||
|
||||
@OpenTag // reflective access is impossible with 'private'
|
||||
fun processElemBUCKS(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap<String, String>) {
|
||||
handler.bucksMode = true
|
||||
@@ -830,7 +854,7 @@ object BTeXParser {
|
||||
val heading = if (part == null && cpt == null && sect == null)
|
||||
""
|
||||
else if (part != null && cpt == null && sect == null)
|
||||
"Part ${part.toRomanNum()}.${glueToString(9)}"
|
||||
"Part ${part.toRomanNum()}${glueToString(9)}"
|
||||
else
|
||||
listOfNotNull(cpt, sect).joinToString(".") + "${glueToString(9)}" +
|
||||
(if (cpt != null && cpt < 10) "${glueToString(9)}" else "")
|
||||
@@ -1408,6 +1432,8 @@ object BTeXParser {
|
||||
companion object {
|
||||
val ccDefault = TerrarumSansBitmap.toColorCode(0,0,0)
|
||||
val ccBucks = TerrarumSansBitmap.toColorCode(4,0,0)
|
||||
val ccCode = TerrarumSansBitmap.toColorCode(0,5,7)
|
||||
val ccHref = TerrarumSansBitmap.toColorCode(0,3,11)
|
||||
|
||||
private const val ZWSP = 0x200B
|
||||
private const val SHY = 0xAD
|
||||
|
||||
@@ -26,8 +26,8 @@ import kotlin.system.measureTimeMillis
|
||||
*/
|
||||
class BTeXTest : ApplicationAdapter() {
|
||||
|
||||
// val filePath = "btex.xml"
|
||||
val filePath = "test.xml"
|
||||
val filePath = "btex.xml"
|
||||
// val filePath = "test.xml"
|
||||
// val filePath = "literature/en/daniel_defoe_robinson_crusoe.xml"
|
||||
// val filePath = "literature/ruRU/anton_chekhov_palata_no_6.xml"
|
||||
// val filePath = "literature/koKR/yisang_nalgae.btexbin"
|
||||
|
||||
Reference in New Issue
Block a user