diff --git a/android/Makefile b/android/Makefile
index 28c41f8..b9ca47e 100644
--- a/android/Makefile
+++ b/android/Makefile
@@ -28,17 +28,20 @@ JAVAC=javac
NDKBUILD=/opt/android-ndk-r8/ndk-build
CLASSPATH=br/com/bb/pw3270
ANDROIDSDK=/opt/android-sdk
-
-# package android.os does not exist
-# javac -d bin/classes
-
-# /opt/android-sdk/tools/lib/
-
MKDIR=/bin/mkdir -p
CONVERT=rsvg-convert
RESOLUTION=xhdpi mdpi ldpi hdpi
+#---[ Rules ]------------------------------------------------------------------
+
+bin/classes/$(CLASSPATH)/%.class: src/$(CLASSPATH)/%.java
+ @$(MKDIR) `dirname $@`
+ @echo "Compile thumb : `basename $@` <= `basename $<`"
+ @$(JAVAC) -classpath $(ANDROIDSDK)/platforms/android-15/android.jar -d bin/classes $<
+
+#---[ Targets ]----------------------------------------------------------------
+
Debug: jni/lib3270jni.h icons
@$(NDKBUILD)
@@ -73,10 +76,6 @@ res/drawable-hdpi/ic_launcher.png: ../src/pw3270/pixmaps/pw3270.svg
@$(MKDIR) `dirname $@`
@$(CONVERT) --format=png --width=72 --height=72 --output=$@ $<
-bin/classes/$(CLASSPATH)/lib3270.class: src/$(CLASSPATH)/lib3270.java
- @$(MKDIR) `dirname $@`
- @$(JAVAC) -classpath $(ANDROIDSDK)/platforms/android-15/android.jar -d bin/classes src/$(CLASSPATH)/lib3270.java
-
sigs.txt: bin/classes/$(CLASSPATH)/lib3270.class
@javap -classpath ./bin/classes -s -p br.com.bb.pw3270.lib3270 > $@
diff --git a/android/jni/main.cpp b/android/jni/main.cpp
index bf757a4..3bb13e6 100644
--- a/android/jni/main.cpp
+++ b/android/jni/main.cpp
@@ -165,7 +165,7 @@ static void remove_timer(void *id)
if(timer == NULL)
{
- __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, "Invalid timer ID %08lx",(unsigned long) timer);
+// __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, "Invalid timer ID %08lx",(unsigned long) timer);
return;
}
@@ -181,7 +181,7 @@ JNIEXPORT void JNICALL Java_br_com_bb_pw3270_lib3270_timerFinish(JNIEnv *env, jo
if(timer == NULL)
{
- __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, "Unexpected call to %s: No timer ID",__FUNCTION__);
+// __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, "Unexpected call to %s: No timer ID",__FUNCTION__);
return;
}
diff --git a/android/jni/text.cpp b/android/jni/text.cpp
index 5117b59..81f6aa3 100644
--- a/android/jni/text.cpp
+++ b/android/jni/text.cpp
@@ -113,10 +113,9 @@ JNIEXPORT jbyteArray JNICALL Java_br_com_bb_pw3270_lib3270_getText(JNIEnv *env,
JNIEXPORT void JNICALL Java_br_com_bb_pw3270_lib3270_setTextAt(JNIEnv *env, jobject obj, jint pos, jbyteArray inText, jint szText)
{
- char str[szText+1];
- int f;
- jbyte * bt;
-
+ unsigned char str[szText+1];
+ int f;
+ jbyte * bt;
session_request(env,obj);
@@ -129,7 +128,29 @@ JNIEXPORT void JNICALL Java_br_com_bb_pw3270_lib3270_setTextAt(JNIEnv *env, jobj
str[f] = (char) bt[f];
str[szText] = 0;
- trace("Buffer(%d)=\"%s\"",(int) pos, str);
+ trace("Buffer(%d/%d)=\"%s\"",(int) pos, lib3270_field_addr(session, (int) pos), str);
+
+
+ if( ((int) pos) == lib3270_field_addr(session, (int) pos))
+ {
+ // Begin of field, clear it first
+ int sz = lib3270_field_length(session,pos);
+ unsigned char * buffer = (unsigned char *) lib3270_malloc(sz+1);
+
+ memset(buffer,' ',sz);
+
+ lib3270_clear_operator_error(session);
+ lib3270_set_cursor_address(session,(int) pos);
+ lib3270_set_string(session,buffer);
+
+ lib3270_free(buffer);
+ }
+
+ lib3270_clear_operator_error(session);
+ lib3270_set_cursor_address(session,(int) pos);
+ lib3270_set_string(session,str);
+
+ lib3270_clear_operator_error(session);
env->ReleaseByteArrayElements(inText,bt,JNI_ABORT);
session_release();
diff --git a/android/lib3270NDK.cbp b/android/lib3270NDK.cbp
index 3a5d397..41392b9 100644
--- a/android/lib3270NDK.cbp
+++ b/android/lib3270NDK.cbp
@@ -38,6 +38,9 @@
+
+
+
diff --git a/android/res/raw/jsmain.js b/android/res/raw/jsmain.js
index 3328574..0196684 100644
--- a/android/res/raw/jsmain.js
+++ b/android/res/raw/jsmain.js
@@ -24,10 +24,12 @@ function xmit()
if(form.elements[i].name.substr(0,1) == "F")
{
var offset = parseInt(form.elements[i].name.substr(1,4));
- alert("offset="+offset+" \""+form.elements[i].value+"\"");
pw3270.setStringAt(offset,form.elements[i].value);
}
}
+
+ pw3270.sendEnter();
+
return false;
}
diff --git a/android/res/raw/theme.css b/android/res/raw/theme.css
index 891b6d6..ae1fed0 100644
--- a/android/res/raw/theme.css
+++ b/android/res/raw/theme.css
@@ -33,22 +33,22 @@ input:focus
input[type="text"]
{
- border: 1px solid #004000
+ background-color: #101010;
}
input[type="text"]:focus
{
- border: 1px solid #008000
+ background-color: #101010;
}
input[type="password"]
{
- border: 1px solid #400000
+ background-color: #101010;
}
input[type="password"]:focus
{
- border: 1px solid #800000
+ background-color: #101010;
}
#terminal
@@ -294,7 +294,7 @@ a
.IW042
{
- width: 22em;
+ width: 25.5em;
}
.IW043
@@ -484,5 +484,7 @@ a
.IW080
{
- width: 41em;
+ margin-left: 0px;
+ margin-right: 0px;
+ width: 48em;
}
diff --git a/android/src/br/com/bb/pw3270/lib3270.java b/android/src/br/com/bb/pw3270/lib3270.java
index ead7c73..3cf1e59 100644
--- a/android/src/br/com/bb/pw3270/lib3270.java
+++ b/android/src/br/com/bb/pw3270/lib3270.java
@@ -19,6 +19,7 @@ public class lib3270
private boolean changed;
private boolean connected = false;
+ private boolean refresh = true;
DataOutputStream outData = null;
DataInputStream inData = null;
@@ -289,7 +290,8 @@ public class lib3270
case 2: // Screen changed
Log.d(TAG,"Screen changed");
changed = true;
- redraw();
+ if(refresh)
+ redraw();
break;
case 3: // Popup
@@ -382,10 +384,12 @@ public class lib3270
public void setStringAt(int offset, String str)
{
+ refresh = false;
try
{
setTextAt(offset,str.getBytes(getEncoding()),str.length());
} catch( Exception e ) { }
+ refresh = true;
}
diff --git a/android/stacktrace.sh b/android/stacktrace.sh
new file mode 100755
index 0000000..96692b9
--- /dev/null
+++ b/android/stacktrace.sh
@@ -0,0 +1,3 @@
+#!/bin/bash -x
+adb logcat | ndk-stack -sym obj/local/armeabi
+
diff --git a/pw3270.cbp b/pw3270.cbp
index a5d5559..50057b7 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -46,6 +46,7 @@
+
diff --git a/src/include/lib3270.h b/src/include/lib3270.h
index e898286..677ec45 100644
--- a/src/include/lib3270.h
+++ b/src/include/lib3270.h
@@ -730,7 +730,39 @@
*/
LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len);
- LIB3270_EXPORT char * lib3270_get_field_at(H3270 *session, int baddr);
+ /**
+ * Get contents of the field at position.
+ *
+ * @param h Session Handle.
+ * @param baddr Reference position.
+ *
+ * @return Contents of the entire field, release it with lib3270_free()
+ *
+ */
+ LIB3270_EXPORT char * lib3270_get_field_at(H3270 *h, int baddr);
+
+ /**
+ * Find the buffer address of the field attribute for a given buffer address.
+ *
+ * @param h Session handle.
+ * @param addr Buffer address of the field.
+ *
+ * @return field address or -1 if the screen isn't formatted.
+ *
+ */
+ LIB3270_EXPORT int lib3270_field_addr(H3270 *h, int baddr);
+
+ /**
+ * Get the length of the field at given buffer address.
+ *
+ * @param h Session handle.
+ * @param addr Buffer address of the field.
+ *
+ * @return field length.
+ *
+ */
+ LIB3270_EXPORT int lib3270_field_length(H3270 *h, int baddr);
+
/**
* Get a terminal character and attribute.
@@ -818,6 +850,8 @@
LIB3270_EXPORT char * lib3270_vsprintf(const char *fmt, va_list args);
+ LIB3270_EXPORT int lib3270_clear_operator_error(H3270 *hSession);
+
LIB3270_EXPORT void lib3270_trace_event(H3270 *session, const char *fmt, ...);
LIB3270_EXPORT void lib3270_set_trace_handler( void (*handler)(H3270 *session, const char *fmt, va_list args) );
LIB3270_EXPORT void lib3270_write_dstrace(H3270 *session, const char *fmt, ...);
diff --git a/src/lib3270/api.h b/src/lib3270/api.h
index ee176fa..4663319 100644
--- a/src/lib3270/api.h
+++ b/src/lib3270/api.h
@@ -331,20 +331,6 @@
#define find_field_attribute(s,a) lib3270_field_addr(s,a)
#define find_field_length(s,a) find_field_length(s,a)
- /**
- * Find the buffer address of the field attribute for a given buffer address.
- *
- * @param h Session handle.
- * @param addr Buffer address of the field.
- *
- * @return field address or -1 if the screen isn't formatted.
- *
- */
- LIB3270_EXPORT int lib3270_field_addr(H3270 *h, int baddr);
-
- LIB3270_EXPORT int lib3270_field_length(H3270 *session, int baddr);
-
-
LOCAL_EXTERN unsigned char get_field_attribute(H3270 *session, int baddr);
// LOCAL_EXTERN int screen_read(char *dest, int baddr, int count);
LOCAL_EXTERN void Input_String(const unsigned char *str);
diff --git a/src/lib3270/kybd.c b/src/lib3270/kybd.c
index 643998c..49128e8 100644
--- a/src/lib3270/kybd.c
+++ b/src/lib3270/kybd.c
@@ -180,7 +180,7 @@ static struct ta
static const char dxl[] = "0123456789abcdef";
#define FROM_HEX(c) (strchr(dxl, tolower(c)) - dxl)
-#define KYBDLOCK_IS_OERR (h3270.kybdlock && !(h3270.kybdlock & ~KL_OERR_MASK))
+#define KYBDLOCK_IS_OERR(hSession) (hSession->kybdlock && !(hSession->kybdlock & ~KL_OERR_MASK))
/*
@@ -379,26 +379,26 @@ kybdlock_set(unsigned int bits, const char *cause unused)
}
}
-/* Clear bits in the keyboard lock. */
-void
-kybdlock_clr(H3270 *session, unsigned int bits, const char *cause unused)
+/**
+ * Clear bits in the keyboard lock.
+ *
+ */
+void lib3270_kybdlock_clear(H3270 *hSession, LIB3270_KL_STATE bits)
{
- unsigned int n;
-
- n = session->kybdlock & ~bits;
+ unsigned int n = hSession->kybdlock & ~( (unsigned int) bits);
- if (n != session->kybdlock)
+ if (n != hSession->kybdlock)
{
#if defined(KYBDLOCK_TRACE)
- trace_event(" %s: kybdlock &= ~0x%04x, 0x%04x -> 0x%04x\n",cause, bits, kybdlock, n);
+ trace_event(" %s: kybdlock &= ~0x%04x, 0x%04x -> 0x%04x\n", __FUNCTION__, bits, kybdlock, n);
#endif
- if ((session->kybdlock ^ n) & KL_DEFERRED_UNLOCK)
+ if ((hSession->kybdlock ^ n) & KL_DEFERRED_UNLOCK)
{
/* Turned off deferred unlock. */
- session->unlock_delay_time = 0;
+ hSession->unlock_delay_time = 0;
}
- session->kybdlock = n;
- status_changed(session,LIB3270_STATUS_KYBDLOCK);
+ hSession->kybdlock = n;
+ status_changed(hSession,LIB3270_STATUS_KYBDLOCK);
}
}
@@ -1399,11 +1399,14 @@ LIB3270_KEY_ACTION( tab )
// reset_idle_timer();
- if (hSession->kybdlock) {
- if (KYBDLOCK_IS_OERR) {
+ if (hSession->kybdlock)
+ {
+ if(KYBDLOCK_IS_OERR(hSession))
+ {
kybdlock_clr(hSession,KL_OERR_MASK, "Tab");
status_reset(hSession);
- } else {
+ } else
+ {
ENQUEUE_ACTION(lib3270_tab);
return 0;
}
@@ -1418,6 +1421,20 @@ LIB3270_KEY_ACTION( tab )
return 0;
}
+LIB3270_EXPORT int lib3270_clear_operator_error(H3270 *hSession)
+{
+ if(!hSession->kybdlock)
+ return ENOENT;
+
+ if(KYBDLOCK_IS_OERR(hSession))
+ {
+ lib3270_kybdlock_clear(hSession,KL_OERR_MASK);
+ status_reset(hSession);
+ return 0;
+ }
+ return EINVAL;
+}
+
/*
* Tab backward to previous field.
@@ -1429,11 +1446,15 @@ LIB3270_KEY_ACTION( backtab )
// reset_idle_timer();
- if (hSession->kybdlock) {
- if (KYBDLOCK_IS_OERR) {
+ if (hSession->kybdlock)
+ {
+ if (KYBDLOCK_IS_OERR(hSession))
+ {
kybdlock_clr(hSession,KL_OERR_MASK, "BackTab");
status_reset(hSession);
- } else {
+ }
+ else
+ {
ENQUEUE_ACTION(lib3270_backtab);
return 0;
}
@@ -1602,7 +1623,7 @@ LIB3270_CURSOR_ACTION( left )
{
if (hSession->kybdlock)
{
- if (KYBDLOCK_IS_OERR)
+ if(KYBDLOCK_IS_OERR(hSession))
{
kybdlock_clr(hSession,KL_OERR_MASK, "Left");
status_reset(&h3270);
@@ -1865,7 +1886,7 @@ LIB3270_CURSOR_ACTION( right )
if (hSession->kybdlock)
{
- if (KYBDLOCK_IS_OERR)
+ if (KYBDLOCK_IS_OERR(hSession))
{
kybdlock_clr(hSession,KL_OERR_MASK, "Right");
status_reset(hSession);
@@ -2093,8 +2114,9 @@ LIB3270_CURSOR_ACTION( up )
register int baddr;
// reset_idle_timer();
- if (hSession->kybdlock) {
- if (KYBDLOCK_IS_OERR)
+ if (hSession->kybdlock)
+ {
+ if (KYBDLOCK_IS_OERR(hSession))
{
kybdlock_clr(hSession,KL_OERR_MASK, "Up");
status_reset(hSession);
@@ -2132,7 +2154,7 @@ LIB3270_CURSOR_ACTION( down )
// reset_idle_timer();
if (hSession->kybdlock)
{
- if (KYBDLOCK_IS_OERR)
+ if (KYBDLOCK_IS_OERR(hSession))
{
kybdlock_clr(hSession,KL_OERR_MASK, "Down");
status_reset(hSession);
diff --git a/src/lib3270/kybdc.h b/src/lib3270/kybdc.h
index 6a26324..c072a8b 100644
--- a/src/lib3270/kybdc.h
+++ b/src/lib3270/kybdc.h
@@ -61,7 +61,11 @@
LIB3270_INTERNAL void clear_xks(void);
LIB3270_INTERNAL void do_reset(H3270 *session, Boolean explicit);
LIB3270_INTERNAL void hex_input(char *s);
- LIB3270_INTERNAL void kybdlock_clr(H3270 *session, unsigned int bits, const char *cause);
+
+ #define kybdlock_clr(session, bits, cause) lib3270_kybdlock_clear(session, bits)
+ LIB3270_INTERNAL void lib3270_kybdlock_clear(H3270 *hSession, LIB3270_KL_STATE bits);
+
+
LIB3270_INTERNAL void kybd_inhibit(H3270 *session, Boolean inhibit);
LIB3270_INTERNAL void kybd_init(void);
LIB3270_INTERNAL int kybd_prime(void);
diff --git a/src/lib3270/sources.mak b/src/lib3270/sources.mak
index 0e4c83f..401c173 100644
--- a/src/lib3270/sources.mak
+++ b/src/lib3270/sources.mak
@@ -26,13 +26,14 @@
# Terminal only sources
TERMINAL_SOURCES = bounds.c ctlr.c util.c toggles.c screen.c selection.c kybd.c telnet.c \
- host.c sf.c ansi.c resolver.c tables.c utf8.c charset.c \
- version.c session.c state.c html.c trace_ds.c see.c
+ host.c sf.c ansi.c resolver.c tables.c utf8.c charset.c \
+ version.c session.c state.c html.c trace_ds.c see.c \
+ paste.c
# Network I/O Sources
NETWORK_SOURCES = iocalls.c proxy.c
# Full library sources
SOURCES = $(TERMINAL_SOURCES) $(NETWORK_SOURCES) ft.c ft_cut.c ft_dft.c glue.c resources.c \
- rpq.c paste.c macros.c fallbacks.c log.c
+ rpq.c macros.c fallbacks.c log.c
--
libgit2 0.21.2