1

Add gaiji placeholders

This commit is contained in:
Alex Yatskov 2020-12-31 20:35:21 -08:00
parent 3e7b31df1d
commit e90a0f78f1
2 changed files with 24 additions and 54 deletions

View File

@ -1,15 +1,15 @@
#include "zig.h" #include "zig.h"
extern EB_Error_Code hookCallback( extern EB_Error_Code hookCallback(
EB_Book* ebBook, EB_Book* book,
EB_Appendix* ebAppendix, EB_Appendix* appendix,
void* container, void* container,
EB_Hook_Code ebHookCode, EB_Hook_Code hookCode,
int argc, int argc,
const unsigned int argv[] const unsigned int argv[]
); );
EB_Error_Code installHook(EB_Hookset* ebHookset, EB_Hook_Code ebHookCode) { EB_Error_Code installHook(EB_Hookset* hookset, EB_Hook_Code hookCode) {
const EB_Hook ebHook = {ebHookCode, hookCallback}; const EB_Hook hook = {hookCode, hookCallback};
return eb_set_hook(ebHookset, &ebHook); return eb_set_hook(hookset, &hook);
} }

View File

@ -17,8 +17,22 @@ import (
import "C" import "C"
//export hookCallback //export hookCallback
func hookCallback(ebBook *C.EB_Book, ebAppendix *C.EB_Appendix, container *C.void, ebHookCode C.EB_Hook_Code, argc C.int, argv *C.uint) C.EB_Error_Code { func hookCallback(book *C.EB_Book, appendix *C.EB_Appendix, container *C.void, hookCode C.EB_Hook_Code, argc C.int, argv *C.uint) C.EB_Error_Code {
return 0 var marker string
switch hookCode {
case C.EB_HOOK_NARROW_FONT:
marker = fmt.Sprintf("{{n_%d}}", *argv)
case C.EB_HOOK_WIDE_FONT:
marker = fmt.Sprintf("{{w_%d}}", *argv)
}
if len(marker) > 0 {
markerC := C.CString(marker)
defer C.free(unsafe.Pointer(markerC))
C.eb_write_text_string(book, markerC)
}
return C.EB_SUCCESS
} }
type blockType int type blockType int
@ -85,52 +99,8 @@ func (c *Context) shutdown() {
func (c *Context) installHooks() error { func (c *Context) installHooks() error {
hookCodes := []C.EB_Hook_Code{ hookCodes := []C.EB_Hook_Code{
C.EB_HOOK_BEGIN_CANDIDATE, C.EB_HOOK_NARROW_FONT,
C.EB_HOOK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UNICODE,
C.EB_HOOK_END_WAVE,
C.EB_HOOK_GRAPHIC_REFERENCE,
C.EB_HOOK_NEWLINE,
C.EB_HOOK_SET_INDENT,
} }
for _, hookCode := range hookCodes { for _, hookCode := range hookCodes {