From ef3cb3177ebc4eef96421e9378d934965f0e54e8 Mon Sep 17 00:00:00 2001
From: "Silas S. Brown" <ssb22@cam.ac.uk>
Date: Mon, 20 Apr 2015 20:59:43 +0000
Subject: [PATCH] Update adjuster/annogen/termlayout

git-svn-id: http://svn.code.sf.net/p/e-guidedog/code/ssb22/adjuster@2165 29193198-4895-4776-b068-10539e920549
---
 annogen.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/annogen.py b/annogen.py
index a43fcb5..22eb112 100755
--- a/annogen.py
+++ b/annogen.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-program_name = "Annotator Generator v0.585 (c) 2012-15 Silas S. Brown"
+program_name = "Annotator Generator v0.586 (c) 2012-15 Silas S. Brown"
 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -490,6 +490,8 @@ and under iOS / Application choose Single View Application.
 Fill in the dialogue box as you like, then use this file
 to replace the generated ViewController.m file.  You should
 then be able to press the Run button on the toolbar.
+Tested on an iOS 6.1 simulator in Xcode 4.6 on Mac OS 10.7
+(hopefully compatible with later versions too)
 
 */
 
@@ -795,7 +797,11 @@ if ios:
     self.myWebView.scalesPageToFit = YES;
     self.myWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
     self.myWebView.delegate = self;
+    [self.view addGestureRecognizer:[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeBack:)]];
     [self.view addSubview:self.myWebView];
+    [self loadInitialPage];
+}
+- (void)loadInitialPage {
 """
   ios=ios.replace('\\','\\\\').replace('"','\\"').replace('\n','\\n')
   if ios.startswith('<'): c_end += '[self.myWebView loadHTMLString:@"'+ios+'" baseURL:nil];'
@@ -805,6 +811,12 @@ if ios:
     c_end += '[self.myWebView loadRequest:[[NSURLRequest alloc] initWithURL:[[NSURL alloc] initWithString:@"'+ios+'"]]];'
   c_end += r"""
 }
+-(void)swipeBack:(UISwipeGestureRecognizer *)recognizer {
+    if (recognizer.state == UIGestureRecognizerStateEnded) {
+        if ([self.myWebView canGoBack]) [self.myWebView goBack];
+        else [self loadInitialPage];
+    }
+}
 - (void)webViewDidFinishLoad:(UIWebView *)webView
 {
     [webView stringByEvaluatingJavaScriptFromString:@" """+jsAnnot("window.alertTitle=f(e.firstChild)+' '+f(e.firstChild.nextSibling); window.alertMessage=e.title; window.location='alert:a'","var texts,tLen,oldTexts,otPtr,replacements; ","texts = new Array(); tLen=0; otPtr=0; ","oldTexts = new Array(); replacements = new Array(); tw0(); window.location='scan:a'",r"""var i=otPtr;while (i<oldTexts.length && oldTexts[i]!=c.nodeValue) i++;if(i<replacements.length) {var newNode=document.createElement('span');newNode.className='_adjust0';n.replaceChild(newNode, c);var r=replacements[i]; if(!inLink) r=r.replace(/<ruby title=/g,'<ruby onclick=\"annotPopAll(this)\" title=');newNode.innerHTML=r; otPtr=i;} else if (tLen < 1024) { texts[texts.length]=c.nodeValue;tLen += c.nodeValue.length;} else return""")+r""""];
-- 
GitLab