diff --git a/lib3270.cbp b/lib3270.cbp
index c120b40..ac48d80 100644
--- a/lib3270.cbp
+++ b/lib3270.cbp
@@ -110,6 +110,9 @@
+
+
+
diff --git a/src/core/ansi.c b/src/core/ansi.c
index bc55047..5b5d22c 100644
--- a/src/core/ansi.c
+++ b/src/core/ansi.c
@@ -533,10 +533,10 @@ static enum lib3270_ansi_state ansi_newline(H3270 *hSession, int GNUC_UNUSED(ig1
{
int nc;
- cursor_move(hSession,hSession->cursor_addr - (hSession->cursor_addr % hSession->cols));
- nc = hSession->cursor_addr + hSession->cols;
+ cursor_move(hSession,hSession->cursor_addr - (hSession->cursor_addr % hSession->view.cols));
+ nc = hSession->cursor_addr + hSession->view.cols;
- if (nc < hSession->scroll_bottom * hSession->cols)
+ if (nc < hSession->scroll_bottom * hSession->view.cols)
cursor_move(hSession,nc);
else
ansi_scroll(hSession);
@@ -552,11 +552,11 @@ ansi_cursor_up(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
if (nn < 1)
nn = 1;
- rr = hSession->cursor_addr / hSession->cols;
+ rr = hSession->cursor_addr / hSession->view.cols;
if (rr - nn < 0)
- cursor_move(hSession, hSession->cursor_addr % hSession->cols);
+ cursor_move(hSession, hSession->cursor_addr % hSession->view.cols);
else
- cursor_move(hSession, hSession->cursor_addr - (nn * hSession->cols));
+ cursor_move(hSession, hSession->cursor_addr - (nn * hSession->view.cols));
hSession->held_wrap = 0;
return DATA;
}
@@ -607,17 +607,17 @@ static enum lib3270_ansi_state ansi_reset(H3270 *hSession, int GNUC_UNUSED(ig1),
hSession->saved_altbuffer = 0;
hSession->scroll_top = 1;
- hSession->scroll_bottom = hSession->rows;
+ hSession->scroll_bottom = hSession->view.rows;
- Replace(hSession->tabs, (unsigned char *)lib3270_malloc((hSession->cols+7)/8));
- for (i = 0; i < (hSession->cols+7)/8; i++)
+ Replace(hSession->tabs, (unsigned char *)lib3270_malloc((hSession->view.cols+7)/8));
+ for (i = 0; i < (hSession->view.cols+7)/8; i++)
hSession->tabs[i] = 0x01;
hSession->held_wrap = 0;
if (!hSession->ansi_reset)
{
ctlr_altbuffer(hSession,True);
- ctlr_aclear(hSession, 0, hSession->rows * hSession->cols, 1);
+ ctlr_aclear(hSession, 0, hSession->view.rows * hSession->view.cols, 1);
ctlr_altbuffer(hSession,False);
ctlr_clear(hSession,False);
hSession->cbk.set_width(hSession,80);
@@ -630,8 +630,8 @@ static enum lib3270_ansi_state ansi_reset(H3270 *hSession, int GNUC_UNUSED(ig1),
static enum lib3270_ansi_state
ansi_insert_chars(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
{
- int cc = hSession->cursor_addr % hSession->cols; /* current col */
- int mc = hSession->cols - cc; /* max chars that can be inserted */
+ int cc = hSession->cursor_addr % hSession->view.cols; /* current col */
+ int mc = hSession->view.cols - cc; /* max chars that can be inserted */
int ns; /* chars that are shifting */
if (nn < 1)
@@ -656,11 +656,11 @@ ansi_cursor_down(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
if (nn < 1)
nn = 1;
- rr = hSession->cursor_addr / hSession->cols;
- if (rr + nn >= hSession->cols)
- cursor_move(hSession,(hSession->cols-1)*hSession->cols + (hSession->cursor_addr%hSession->cols));
+ rr = hSession->cursor_addr / hSession->view.cols;
+ if (rr + nn >= hSession->view.cols)
+ cursor_move(hSession,(hSession->view.cols-1)*hSession->view.cols + (hSession->cursor_addr % hSession->view.cols));
else
- cursor_move(hSession,hSession->cursor_addr + (nn * hSession->cols));
+ cursor_move(hSession,hSession->cursor_addr + (nn * hSession->view.cols));
hSession->held_wrap = 0;
return DATA;
}
@@ -671,11 +671,11 @@ static enum lib3270_ansi_state ansi_cursor_right(H3270 *hSession, int nn, int GN
if (nn < 1)
nn = 1;
- cc = hSession->cursor_addr % hSession->cols;
- if (cc == hSession->cols-1)
+ cc = hSession->cursor_addr % hSession->view.cols;
+ if (cc == hSession->view.cols-1)
return DATA;
- if (cc + nn >= hSession->cols)
- nn = hSession->cols - 1 - cc;
+ if (cc + nn >= hSession->view.cols)
+ nn = hSession->view.cols - 1 - cc;
cursor_move(hSession,hSession->cursor_addr + nn);
hSession->held_wrap = 0;
return DATA;
@@ -693,7 +693,7 @@ ansi_cursor_left(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
}
if (nn < 1)
nn = 1;
- cc = hSession->cursor_addr % hSession->cols;
+ cc = hSession->cursor_addr % hSession->view.cols;
if (!cc)
return DATA;
if (nn > cc)
@@ -706,10 +706,10 @@ static enum lib3270_ansi_state
ansi_cursor_motion(H3270 *hSession, int n1, int n2)
{
if (n1 < 1) n1 = 1;
- if (n1 > hSession->rows) n1 = hSession->rows;
+ if (n1 > hSession->view.rows) n1 = hSession->view.rows;
if (n2 < 1) n2 = 1;
- if (n2 > hSession->cols) n2 = hSession->cols;
- cursor_move(hSession,(n1 - 1) * hSession->cols + (n2 - 1));
+ if (n2 > hSession->view.cols) n2 = hSession->view.cols;
+ cursor_move(hSession,(n1 - 1) * hSession->view.cols + (n2 - 1));
hSession->held_wrap = 0;
return DATA;
}
@@ -719,14 +719,14 @@ ansi_erase_in_display(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
{
switch (nn) {
case 0: /* below */
- ctlr_aclear(hSession, hSession->cursor_addr, (hSession->rows * hSession->cols) - hSession->cursor_addr, 1);
+ ctlr_aclear(hSession, hSession->cursor_addr, (hSession->view.rows * hSession->view.cols) - hSession->cursor_addr, 1);
break;
case 1: /* above */
ctlr_aclear(hSession, 0, hSession->cursor_addr + 1, 1);
break;
case 2: /* all (without moving cursor) */
// if (hSession->cursor_addr == 0 && !hSession->is_altbuffer) scroll_save(hSession->rows, True);
- ctlr_aclear(hSession, 0, hSession->rows * hSession->cols, 1);
+ ctlr_aclear(hSession, 0, hSession->view.rows * hSession->view.cols, 1);
break;
}
return DATA;
@@ -735,17 +735,17 @@ ansi_erase_in_display(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
static enum lib3270_ansi_state
ansi_erase_in_line(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
{
- int nc = hSession->cursor_addr % hSession->cols;
+ int nc = hSession->cursor_addr % hSession->view.cols;
switch (nn) {
case 0: /* to right */
- ctlr_aclear(hSession, hSession->cursor_addr, hSession->cols - nc, 1);
+ ctlr_aclear(hSession, hSession->cursor_addr, hSession->view.cols - nc, 1);
break;
case 1: /* to left */
ctlr_aclear(hSession, hSession->cursor_addr - nc, nc+1, 1);
break;
case 2: /* all */
- ctlr_aclear(hSession, hSession->cursor_addr - nc, hSession->cols, 1);
+ ctlr_aclear(hSession, hSession->cursor_addr - nc, hSession->view.cols, 1);
break;
}
return DATA;
@@ -754,7 +754,7 @@ ansi_erase_in_line(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
static enum lib3270_ansi_state
ansi_insert_lines(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
{
- int rr = hSession->cursor_addr / hSession->cols; /* current row */
+ int rr = hSession->cursor_addr / hSession->view.cols; /* current row */
int mr = hSession->scroll_bottom - rr; /* rows left at and below this one */
int ns; /* rows that are shifting */
@@ -770,17 +770,17 @@ ansi_insert_lines(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
/* Move the victims down */
ns = mr - nn;
if (ns)
- ctlr_bcopy(hSession,rr * hSession->cols, (rr + nn) * hSession->cols, ns * hSession->cols, 1);
+ ctlr_bcopy(hSession,rr * hSession->view.cols, (rr + nn) * hSession->view.cols, ns * hSession->view.cols, 1);
/* Clear the middle of the screen */
- ctlr_aclear(hSession, rr * hSession->cols, nn * hSession->cols, 1);
+ ctlr_aclear(hSession, rr * hSession->view.cols, nn * hSession->view.cols, 1);
return DATA;
}
static enum lib3270_ansi_state
ansi_delete_lines(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
{
- int rr = hSession->cursor_addr / hSession->cols; /* current row */
+ int rr = hSession->cursor_addr / hSession->view.cols; /* current row */
int mr = hSession->scroll_bottom - rr; /* max rows that can be deleted */
int ns; /* rows that are shifting */
@@ -796,19 +796,19 @@ ansi_delete_lines(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
/* Move the surviving rows up */
ns = mr - nn;
if (ns)
- ctlr_bcopy(hSession,(rr + nn) * hSession->cols, rr * hSession->cols, ns * hSession->cols, 1);
+ ctlr_bcopy(hSession,(rr + nn) * hSession->view.cols, rr * hSession->view.cols, ns * hSession->view.cols, 1);
/* Clear the rest of the screen */
- ctlr_aclear(hSession, (rr + ns) * hSession->cols, nn * hSession->cols, 1);
+ ctlr_aclear(hSession, (rr + ns) * hSession->view.cols, nn * hSession->view.cols, 1);
return DATA;
}
static enum lib3270_ansi_state
ansi_delete_chars(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
{
- int cc = hSession->cursor_addr % hSession->cols; /* current col */
- int mc = hSession->cols - cc; /* max chars that can be deleted */
- int ns; /* chars that are shifting */
+ int cc = hSession->cursor_addr % hSession->view.cols; /* current col */
+ int mc = hSession->view.cols - cc; /* max chars that can be deleted */
+ int ns; /* chars that are shifting */
if (nn < 1)
nn = 1;
@@ -947,12 +947,12 @@ static enum lib3270_ansi_state ansi_backspace(H3270 *hSession, int GNUC_UNUSED(i
if (hSession->rev_wraparound_mode)
{
- if (hSession->cursor_addr > (hSession->scroll_top - 1) * hSession->cols)
+ if (hSession->cursor_addr > (hSession->scroll_top - 1) * hSession->view.cols)
cursor_move(hSession,hSession->cursor_addr - 1);
}
else
{
- if (hSession->cursor_addr % hSession->cols)
+ if (hSession->cursor_addr % hSession->view.cols)
cursor_move(hSession,hSession->cursor_addr - 1);
}
return DATA;
@@ -960,8 +960,8 @@ static enum lib3270_ansi_state ansi_backspace(H3270 *hSession, int GNUC_UNUSED(i
static enum lib3270_ansi_state ansi_cr(H3270 *hSession, int GNUC_UNUSED(ig1), int GNUC_UNUSED(ig2))
{
- if (hSession->cursor_addr % hSession->cols)
- cursor_move(hSession,hSession->cursor_addr - (hSession->cursor_addr % hSession->cols));
+ if (hSession->cursor_addr % hSession->view.cols)
+ cursor_move(hSession,hSession->cursor_addr - (hSession->cursor_addr % hSession->view.cols));
if (hSession->auto_newline_mode)
(void) ansi_lf(hSession, 0, 0);
@@ -972,19 +972,19 @@ static enum lib3270_ansi_state ansi_cr(H3270 *hSession, int GNUC_UNUSED(ig1), in
static enum lib3270_ansi_state ansi_lf(H3270 *hSession, int GNUC_UNUSED(ig1), int GNUC_UNUSED(ig2))
{
- int nc = hSession->cursor_addr + hSession->cols;
+ int nc = hSession->cursor_addr + hSession->view.cols;
hSession->held_wrap = 0;
// If we're below the scrolling region, don't scroll.
- if((hSession->cursor_addr / hSession->cols) >= hSession->scroll_bottom)
+ if((hSession->cursor_addr / hSession->view.cols) >= hSession->scroll_bottom)
{
- if (nc < hSession->rows * hSession->cols)
+ if (nc < hSession->view.rows * hSession->view.cols)
cursor_move(hSession,nc);
return DATA;
}
- if (nc < hSession->scroll_bottom * hSession->cols)
+ if (nc < hSession->scroll_bottom * hSession->view.cols)
cursor_move(hSession,nc);
else
ansi_scroll(hSession);
@@ -993,13 +993,13 @@ static enum lib3270_ansi_state ansi_lf(H3270 *hSession, int GNUC_UNUSED(ig1), in
static enum lib3270_ansi_state ansi_htab(H3270 *hSession, int GNUC_UNUSED(ig1), int GNUC_UNUSED(ig2))
{
- int col = hSession->cursor_addr % hSession->cols;
+ int col = hSession->cursor_addr % hSession->view.cols;
int i;
hSession->held_wrap = 0;
- if (col == hSession->cols-1)
+ if (col == hSession->view.cols-1)
return DATA;
- for (i = col+1; i < hSession->cols-1; i++)
+ for (i = col+1; i < hSession->view.cols-1; i++)
if (hSession->tabs[i/8] & 1<<(i%8))
break;
cursor_move(hSession,hSession->cursor_addr - col + i);
@@ -1018,14 +1018,14 @@ static enum lib3270_ansi_state ansi_nop(H3270 GNUC_UNUSED(*hSession), int GNUC_U
#define PWRAP { \
nc = hSession->cursor_addr + 1; \
- if (nc < hSession->scroll_bottom * hSession->cols) \
+ if (nc < hSession->scroll_bottom * hSession->view.cols) \
cursor_move(hSession,nc); \
else { \
- if (hSession->cursor_addr / hSession->cols >= hSession->scroll_bottom) \
- cursor_move(hSession,hSession->cursor_addr / hSession->cols * hSession->cols); \
+ if (hSession->cursor_addr / hSession->view.cols >= hSession->scroll_bottom) \
+ cursor_move(hSession,hSession->cursor_addr / hSession->view.cols * hSession->view.cols); \
else { \
ansi_scroll(hSession); \
- cursor_move(hSession,nc - hSession->cols); \
+ cursor_move(hSession,nc - hSession->view.cols); \
} \
} \
}
@@ -1198,13 +1198,13 @@ ansi_printing(H3270 *hSession, int GNUC_UNUSED(ig1), int GNUC_UNUSED(ig2))
* In my opinion, very strange, but among other things, 'vi'
* depends on it!
*/
- if (!((hSession->cursor_addr + 1) % hSession->cols)) {
+ if (!((hSession->cursor_addr + 1) % hSession->view.cols)) {
hSession->held_wrap = 1;
} else {
PWRAP;
}
} else {
- if ((hSession->cursor_addr % hSession->cols) != (hSession->cols - 1))
+ if ((hSession->cursor_addr % hSession->view.cols) != (hSession->view.cols - 1))
cursor_move(hSession,hSession->cursor_addr + 1);
}
return DATA;
@@ -1277,10 +1277,10 @@ static enum lib3270_ansi_state ansi_digit(H3270 *hSession, int GNUC_UNUSED(ig1),
static enum lib3270_ansi_state ansi_reverse_index(H3270 *hSession, int GNUC_UNUSED(ig1), int GNUC_UNUSED(ig2))
{
- int rr = hSession->cursor_addr / hSession->cols; /* current row */
- int np = (hSession->scroll_top - 1) - rr; /* number of rows in the scrolling region, above this line */
- int ns; /* number of rows to scroll */
- int nn = 1; /* number of rows to index */
+ int rr = hSession->cursor_addr / hSession->view.cols; /* current row */
+ int np = (hSession->scroll_top - 1) - rr; /* number of rows in the scrolling region, above this line */
+ int ns; /* number of rows to scroll */
+ int nn = 1; /* number of rows to index */
hSession->held_wrap = 0;
@@ -1360,7 +1360,7 @@ static enum lib3270_ansi_state ansi_status_report(H3270 *hSession, int nn, int G
break;
case 6:
- (void) snprintf(cpr, 22, "\033[%d;%dR",(hSession->cursor_addr/hSession->cols) + 1, (hSession->cursor_addr%hSession->cols) + 1);
+ (void) snprintf(cpr, 22, "\033[%d;%dR",(hSession->cursor_addr/hSession->view.cols) + 1, (hSession->cursor_addr%hSession->view.cols) + 1);
net_sends(hSession,cpr);
break;
}
@@ -1564,10 +1564,10 @@ dec_scrolling_region(H3270 *hSession, int top, int bottom)
{
if (top < 1)
top = 1;
- if (bottom > hSession->rows)
- bottom = hSession->rows;
+ if (bottom > hSession->view.rows)
+ bottom = hSession->view.rows;
- if (top <= bottom && (top > 1 || bottom < hSession->rows))
+ if (top <= bottom && (top > 1 || bottom < hSession->view.rows))
{
hSession->scroll_top = top;
hSession->scroll_bottom = bottom;
@@ -1576,7 +1576,7 @@ dec_scrolling_region(H3270 *hSession, int top, int bottom)
else
{
hSession->scroll_top = 1;
- hSession->scroll_bottom = hSession->rows;
+ hSession->scroll_bottom = hSession->view.rows;
}
return DATA;
}
@@ -1651,7 +1651,7 @@ xterm_text_do(H3270 GNUC_UNUSED(*hSession), int GNUC_UNUSED(ig1), int GNUC_UNUSE
static enum lib3270_ansi_state
ansi_htab_set(H3270 *hSession, int GNUC_UNUSED(ig1), int GNUC_UNUSED(ig2))
{
- register int col = hSession->cursor_addr % hSession->cols;
+ register int col = hSession->cursor_addr % hSession->view.cols;
hSession->tabs[col/8] |= 1<<(col%8);
return DATA;
@@ -1665,11 +1665,11 @@ ansi_htab_clear(H3270 *hSession, int nn, int GNUC_UNUSED(ig2))
switch (nn)
{
case 0:
- col = hSession->cursor_addr % hSession->cols;
+ col = hSession->cursor_addr % hSession->view.cols;
hSession->tabs[col/8] &= ~(1<<(col%8));
break;
case 3:
- for (i = 0; i < (hSession->cols+7)/8; i++)
+ for (i = 0; i < (hSession->view.cols+7)/8; i++)
hSession->tabs[i] = 0;
break;
}
@@ -1684,7 +1684,7 @@ static void ansi_scroll(H3270 *hSession)
hSession->held_wrap = 0;
/* Save the top line */
- if (hSession->scroll_top == 1 && hSession->scroll_bottom == hSession->rows)
+ if (hSession->scroll_top == 1 && hSession->scroll_bottom == hSession->view.rows)
{
// if (!hSession->is_altbuffer)
// scroll_save(1, False);
@@ -1694,13 +1694,13 @@ static void ansi_scroll(H3270 *hSession)
/* Scroll all but the last line up */
if (hSession->scroll_bottom > hSession->scroll_top)
- ctlr_bcopy(hSession,hSession->scroll_top * hSession->cols,
- (hSession->scroll_top - 1) * hSession->cols,
- (hSession->scroll_bottom - hSession->scroll_top) * hSession->cols,
+ ctlr_bcopy(hSession,hSession->scroll_top * hSession->view.cols,
+ (hSession->scroll_top - 1) * hSession->view.cols,
+ (hSession->scroll_bottom - hSession->scroll_top) * hSession->view.cols,
1);
/* Clear the last line */
- ctlr_aclear(hSession, (hSession->scroll_bottom - 1) * hSession->cols, hSession->cols, 1);
+ ctlr_aclear(hSession, (hSession->scroll_bottom - 1) * hSession->view.cols, hSession->view.cols, 1);
}
/* Callback for when we enter ANSI mode. */
diff --git a/src/core/bounds.c b/src/core/bounds.c
index db65c15..9788337 100644
--- a/src/core/bounds.c
+++ b/src/core/bounds.c
@@ -61,7 +61,7 @@ LIB3270_EXPORT int lib3270_get_field_bounds(H3270 *hSession, int baddr, int *sta
if(end)
{
- int maxlen = (hSession->rows * hSession->cols)-1;
+ int maxlen = (hSession->view.rows * hSession->view.cols)-1;
*end = first + lib3270_field_length(hSession,first);
if(*end > maxlen)
*end = maxlen;
@@ -88,7 +88,7 @@ LIB3270_EXPORT int lib3270_get_word_bounds(H3270 *session, int baddr, int *start
if(end)
{
- int maxlen = session->rows * session->cols;
+ int maxlen = session->view.rows * session->view.cols;
for(pos = baddr; pos < maxlen && !isspace(session->text[pos].chr);pos++);
*end = pos < maxlen ? pos-1 : maxlen;
diff --git a/src/core/charset.c b/src/core/charset.c
index 82522a1..eab2b10 100644
--- a/src/core/charset.c
+++ b/src/core/charset.c
@@ -302,10 +302,10 @@ LIB3270_EXPORT int lib3270_charsettable(H3270 *hSession)
trace("%s","Showing charset table");
- (void) memset((char *) hSession->ea_buf, 0, hSession->rows*hSession->cols*sizeof(struct lib3270_ea));
+ (void) memset((char *) hSession->ea_buf, 0, hSession->view.rows * hSession->view.cols * sizeof(struct lib3270_ea));
- baddr = margin_left+hSession->maxCOLS;
- s = (hSession->maxCOLS * 0x11);
+ baddr = margin_left+hSession->max.cols;
+ s = (hSession->max.cols * 0x11);
for(f=4;f<=0x0f;f++)
{
baddr += 2;
@@ -316,7 +316,7 @@ LIB3270_EXPORT int lib3270_charsettable(H3270 *hSession)
hSession->ea_buf[baddr+s].gr = hSession->ea_buf[baddr].gr = 0;
}
- baddr = margin_left+(hSession->maxCOLS*2);
+ baddr = margin_left+(hSession->max.cols*2);
s = 0x1a;
for(f=0;f<=0x0f;f++)
{
@@ -325,14 +325,14 @@ LIB3270_EXPORT int lib3270_charsettable(H3270 *hSession)
hSession->ea_buf[baddr+s].cs = hSession->ea_buf[baddr].cs = 0;
hSession->ea_buf[baddr+s].cc = hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) hChars[f]];
hSession->ea_buf[baddr+s].gr = hSession->ea_buf[baddr].gr = 0;
- baddr += hSession->maxCOLS;
+ baddr += hSession->max.cols;
}
chr = 0x40;
for(f=0;f<0x0c;f++)
{
- baddr = (margin_left+(hSession->maxCOLS*2))+(f*2)+2;
+ baddr = (margin_left+(hSession->max.cols*2))+(f*2)+2;
for(r=0;r<=0x0f;r++)
{
hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_YELLOW;
@@ -340,11 +340,11 @@ LIB3270_EXPORT int lib3270_charsettable(H3270 *hSession)
hSession->ea_buf[baddr].cs = 0;
hSession->ea_buf[baddr].cc = chr++;
hSession->ea_buf[baddr].gr = 0;
- baddr += hSession->maxCOLS;
+ baddr += hSession->max.cols;
}
}
- baddr = margin_left+0x1d+(hSession->maxCOLS*2);
+ baddr = margin_left+0x1d+(hSession->max.cols*2);
for(ptr=label;*ptr;ptr++)
{
hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_WHITE;
diff --git a/src/core/ctlr.c b/src/core/ctlr.c
index eb786ab..e692fac 100644
--- a/src/core/ctlr.c
+++ b/src/core/ctlr.c
@@ -97,7 +97,7 @@ static const unsigned char code_table[64] =
#define IsBlank(c) ((c == EBC_null) || (c == EBC_space))
-#define ALL_CHANGED(h) if(lib3270_in_ansi(h)) (h)->cbk.changed(h,0,(h)->rows*(h)->cols);
+#define ALL_CHANGED(h) if(lib3270_in_ansi(h)) (h)->cbk.changed(h,0,(h)->view.rows*(h)->view.cols);
#define REGION_CHANGED(h, f, l) if(lib3270_in_ansi(h)) (h)->cbk.changed(h,f,l)
#define ONE_CHANGED(h,n) if(lib3270_in_ansi(h)) (h)->cbk.changed(h,n,n+1);
@@ -136,7 +136,7 @@ void ctlr_reinit(H3270 *session, unsigned cmask)
{
/* Allocate buffers */
struct lib3270_ea *tmp;
- size_t sz = (session->maxROWS * session->maxCOLS);
+ size_t sz = (session->max.rows * session->max.cols);
session->buffer[0] = tmp = lib3270_calloc(sizeof(struct lib3270_ea), sz+1, session->buffer[0]);
session->ea_buf = tmp + 1;
@@ -152,168 +152,6 @@ void ctlr_reinit(H3270 *session, unsigned cmask)
}
}
- /**
- * @brief Parse the model number.
- *
- * @param session Session Handle.
- * @param m Model number.
- *
- * @return -1 (error), 0 (default), or the specified number.
- */
-static int parse_model_number(H3270 *session, const char *m)
-{
- int sl;
- int n;
-
- if(!m)
- return 0;
-
- sl = strlen(m);
-
- /* An empty model number is no good. */
- if (!sl)
- return 0;
-
- if (sl > 1) {
- /*
- * If it's longer than one character, it needs to start with
- * '327[89]', and it sets the m3279 resource.
- */
- if (!strncmp(m, "3278", 4))
- {
- session->m3279 = 0;
- }
- else if (!strncmp(m, "3279", 4))
- {
- session->m3279 = 1;
- }
- else
- {
- return -1;
- }
- m += 4;
- sl -= 4;
-
- /* Check more syntax. -E is allowed, but ignored. */
- switch (m[0]) {
- case '\0':
- /* Use default model number. */
- return 0;
- case '-':
- /* Model number specified. */
- m++;
- sl--;
- break;
- default:
- return -1;
- }
- switch (sl) {
- case 1: /* n */
- break;
- case 3: /* n-E */
- if (strcasecmp(m + 1, "-E")) {
- return -1;
- }
- break;
- default:
- return -1;
- }
- }
-
- /* Check the numeric model number. */
- n = atoi(m);
- if (n >= 2 && n <= 5) {
- return n;
- } else {
- return -1;
- }
-
-}
-
-/**
- * @brief Get current 3270 model.
- *
- * @param hSession selected 3270 session.
- * @return Current model number.
- */
-int lib3270_get_model_number(H3270 *hSession)
-{
- CHECK_SESSION_HANDLE(hSession);
- return hSession->model_num;
-}
-
-const char * lib3270_get_model(H3270 *hSession)
-{
- CHECK_SESSION_HANDLE(hSession);
- return hSession->model_name;
-}
-
-int lib3270_set_model(H3270 *hSession, const char *model)
-{
- int ovc, ovr;
- char junk;
- int model_number;
-
- if(hSession->cstate != LIB3270_NOT_CONNECTED)
- return errno = EISCONN;
-
- strncpy(hSession->full_model_name,"IBM-",LIB3270_FULL_MODEL_NAME_LENGTH);
- hSession->model_name = &hSession->full_model_name[4];
-
- if(!*model)
- model = "2"; // No model, use the default one
-
- model_number = parse_model_number(hSession,model);
- if (model_number < 0)
- {
- popup_an_error(hSession,"Invalid model number: %s", model);
- model_number = 0;
- }
-
- if (!model_number)
- {
-#if defined(RESTRICT_3279)
- model_number = 3;
-#else
- model_number = 4;
-#endif
- }
-
- if(hSession->mono)
- hSession->m3279 = 0;
- else
- hSession->m3279 = 1;
-
- if(!hSession->extended)
- hSession->oversize = CN;
-
-#if defined(RESTRICT_3279)
- if (hSession->m3279 && model_number == 4)
- model_number = 3;
-#endif
-
- trace("Model_number: %d",model_number);
-
- if (!hSession->extended || hSession->oversize == CN || sscanf(hSession->oversize, "%dx%d%c", &ovc, &ovr, &junk) != 2)
- {
- ovc = 0;
- ovr = 0;
- }
- ctlr_set_rows_cols(hSession, model_number, ovc, ovr);
-
- if (hSession->termname != CN)
- hSession->termtype = hSession->termname;
- else
- hSession->termtype = hSession->full_model_name;
-
- trace("Termtype: %s",hSession->termtype);
-
- ctlr_reinit(hSession,MODEL_CHANGE);
- screen_update(hSession,0,hSession->rows*hSession->cols);
-
- return 0;
-}
-
void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr)
{
static const struct _sz
@@ -340,23 +178,74 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr)
update_model_info(session,mn,sz[idx].cols,sz[idx].rows);
// Apply oversize.
- session->ov_cols = 0;
- session->ov_rows = 0;
+ session->oversize.cols = 0;
+ session->oversize.rows = 0;
if (ovc != 0 || ovr != 0)
{
if (ovc <= 0 || ovr <= 0)
- popup_an_error(session,"Invalid %s %dx%d:\nNegative or zero",ResOversize, ovc, ovr);
+ {
+ lib3270_popup_dialog(
+ session,
+ LIB3270_NOTIFY_ERROR,
+ _( "Invalid oversize" ),
+ _( "The oversize values are invalid." ), \
+ _( "%dx%d is negative or zero" ),
+ ovc, ovr
+ );
+
+ // popup_an_error(session,"Invalid %s %dx%d:\nNegative or zero",ResOversize, ovc, ovr);
+
+ }
else if (ovc * ovr >= 0x4000)
- popup_an_error(session,"Invalid %s %dx%d:\nToo big",ResOversize, ovc, ovr);
- else if (ovc > 0 && ovc < session->maxCOLS)
- popup_an_error(session,"Invalid %s cols (%d):\nLess than model %d cols (%d)",ResOversize, ovc, session->model_num, session->maxCOLS);
- else if (ovr > 0 && ovr < session->maxROWS)
- popup_an_error(session,"Invalid %s rows (%d):\nLess than model %d rows (%d)",ResOversize, ovr, session->model_num, session->maxROWS);
+ {
+ lib3270_popup_dialog(
+ session,
+ LIB3270_NOTIFY_ERROR,
+ _( "Invalid oversize" ),
+ _( "The oversize values are too big." ), \
+ _( "%dx%d screen size is bigger than the maximum size" ),
+ ovc, ovr
+ );
+
+// popup_an_error(session,"Invalid %s %dx%d:\nToo big",ResOversize, ovc, ovr);
+
+ }
+ else if (ovc > 0 && ovc < session->max.cols)
+ {
+
+ lib3270_popup_dialog(
+ session,
+ LIB3270_NOTIFY_ERROR,
+ _( "Invalid oversize" ),
+ _( "The oversize width is too small." ), \
+ _( "The width %d is less than model %d columns (%d)" ),
+ ovc, session->model_num, session->max.cols
+ );
+
+// popup_an_error(session,"Invalid %s cols (%d):\nLess than model %d cols (%d)",ResOversize, ovc, session->model_num, session->maxCOLS);
+ }
+ else if (ovr > 0 && ovr < session->max.rows)
+ {
+
+ lib3270_popup_dialog(
+ session,
+ LIB3270_NOTIFY_ERROR,
+ _( "Invalid oversize" ),
+ _( "The oversize height is too small." ), \
+ _( "The height %d is less than model %d rows (%d)" ),
+ ovr, session->model_num, session->max.rows
+ );
+
+// popup_an_error(session,"Invalid %s rows (%d):\nLess than model %d rows (%d)",ResOversize, ovr, session->model_num, session->maxROWS);
+
+ }
else
- update_model_info(session,mn,session->ov_cols = ovc,session->ov_rows = ovr);
+ {
+ update_model_info(session,mn,session->oversize.cols = ovc,session->oversize.rows = ovr);
+ }
}
- set_viewsize(session,sz[idx].rows,sz[idx].cols);
+ set_viewsize(session,session->max.rows,session->max.cols);
}
@@ -636,8 +525,8 @@ LIB3270_EXPORT int lib3270_get_next_unprotected(H3270 *hSession, int baddr0)
return 0;
}
-LIB3270_EXPORT int lib3270_get_is_protected_at(H3270 *h, int row, int col) {
- return lib3270_get_is_protected(h, ((row-1) * h->cols) + (col-1));
+LIB3270_EXPORT int lib3270_get_is_protected_at(H3270 *h, unsigned int row, unsigned int col) {
+ return lib3270_get_is_protected(h, ((row-1) * h->view.cols) + (col-1));
}
LIB3270_EXPORT int lib3270_get_is_protected(H3270 *hSession, int baddr)
@@ -659,7 +548,7 @@ LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr)
/**
- * Perform an erase command, which may include changing the (virtual) screen size.
+ * @brief Perform an erase command, which may include changing the (virtual) screen size.
*
*/
void ctlr_erase(H3270 *session, int alt)
@@ -677,13 +566,12 @@ void ctlr_erase(H3270 *session, int alt)
{
// Going from 24x80 to maximum.
session->cbk.display(session);
-
- set_viewsize(session,session->maxROWS,session->maxCOLS);
+ set_viewsize(session,session->max.rows,session->max.cols);
}
else
{
// Going from maximum to 24x80.
- if (session->maxROWS > 24 || session->maxCOLS > 80)
+ if (session->max.rows > 24 || session->max.cols > 80)
{
if(session->vcontrol)
{
@@ -694,7 +582,7 @@ void ctlr_erase(H3270 *session, int alt)
if(lib3270_get_toggle(session,LIB3270_TOGGLE_ALTSCREEN))
set_viewsize(session,24,80);
else
- set_viewsize(session,session->maxROWS,80);
+ set_viewsize(session,session->max.rows,80);
}
}
@@ -702,8 +590,8 @@ void ctlr_erase(H3270 *session, int alt)
}
-/*
- * Interpret an incoming 3270 command.
+/**
+ * @brief Interpret an incoming 3270 command.
*/
enum pds process_ds(H3270 *hSession, unsigned char *buf, int buflen)
{
@@ -943,7 +831,7 @@ void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all)
space3270out(hSession,3);
*hSession->obptr++ = ORDER_SBA;
ENCODE_BADDR(hSession->obptr, baddr);
- trace_ds(hSession," SetBufferAddress%s (Cols: %d Rows: %d)", rcba(hSession,baddr), hSession->cols, hSession->rows);
+ trace_ds(hSession," SetBufferAddress%s (Cols: %d Rows: %d)", rcba(hSession,baddr), hSession->view.cols, hSession->view.rows);
while (!hSession->ea_buf[baddr].fa)
{
@@ -1357,7 +1245,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
END_TEXT("SetBufferAddress");
previous = SBA;
trace_ds(hSession,"%s",rcba(hSession,hSession->buffer_addr));
- if(hSession->buffer_addr >= hSession->cols * hSession->rows)
+ if(hSession->buffer_addr >= hSession->view.cols * hSession->view.rows)
{
ABORT_WRITE("invalid SBA address");
}
@@ -1508,7 +1396,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
trace_ds(hSession,"'");
}
- if (baddr >= hSession->cols * hSession->rows)
+ if (baddr >= hSession->view.cols * hSession->view.rows)
{
ABORT_WRITE("invalid RA address");
}
@@ -1556,7 +1444,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
trace_ds(hSession,"%s",rcba(hSession,baddr));
previous = ORDER;
- if (baddr >= hSession->cols * hSession->rows)
+ if (baddr >= hSession->view.cols * hSession->view.rows)
{
ABORT_WRITE("invalid EUA address");
}
@@ -1861,7 +1749,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
DEC_BA(baddr);
while (!aborted &&
((fa_addr >= 0 && baddr != fa_addr) ||
- (fa_addr < 0 && baddr != hSession->rows*hSession->cols - 1))) {
+ (fa_addr < 0 && baddr != hSession->view.rows*hSession->view.cols - 1))) {
if (hSession->ea_buf[baddr].cc == FCORDER_SI) {
ABORT_WRITE("double SI");
}
@@ -2069,8 +1957,8 @@ void ctlr_write_sscp_lu(H3270 *hSession, unsigned char buf[], int buflen)
* Insert NULLs to the end of the line and advance to
* the beginning of the next line.
*/
- s_row = hSession->buffer_addr / hSession->cols;
- while ((hSession->buffer_addr / hSession->cols) == s_row)
+ s_row = hSession->buffer_addr / hSession->view.cols;
+ while ((hSession->buffer_addr / hSession->view.cols) == s_row)
{
ctlr_add(hSession,hSession->buffer_addr, EBC_null, hSession->default_cs);
ctlr_add_fg(hSession,hSession->buffer_addr, hSession->default_fg);
@@ -2450,7 +2338,7 @@ int ctlr_any_data(H3270 *session)
{
register int i;
- for(i = 0; i < session->rows*session->cols; i++)
+ for(i = 0; i < session->view.rows * session->view.cols; i++)
{
if (!IsBlank(session->ea_buf[i].cc))
return 1;
@@ -2477,7 +2365,7 @@ void ctlr_clear(H3270 *session, Boolean can_snap)
#endif
/* Clear the screen. */
- (void) memset((char *)session->ea_buf, 0, session->rows*session->cols*sizeof(struct lib3270_ea));
+ (void) memset((char *)session->ea_buf, 0, session->view.rows * session->view.cols * sizeof(struct lib3270_ea));
cursor_move(session,0);
session->buffer_addr = 0;
@@ -2506,7 +2394,7 @@ static void ctlr_blanks(H3270 *session)
{
int baddr;
- for (baddr = 0; baddr < session->rows*session->cols; baddr++)
+ for (baddr = 0; baddr < session->view.rows * session->view.cols; baddr++)
{
if (!session->ea_buf[baddr].fa)
session->ea_buf[baddr].cc = EBC_space;
@@ -2634,8 +2522,8 @@ static void ctlr_add_ic(H3270 *hSession, int baddr, unsigned char ic)
hSession->ea_buf[baddr].ic = ic;
}
-/*
- * Wrapping bersion of ctlr_bcopy.
+/**
+ * @brief Wrapping bersion of ctlr_bcopy.
*/
void ctlr_wrapping_memmove(H3270 *hSession, int baddr_to, int baddr_from, int count)
{
@@ -2647,8 +2535,8 @@ void ctlr_wrapping_memmove(H3270 *hSession, int baddr_to, int baddr_from, int co
* It's faster to figure out if none of this is true, then do a slow
* location-at-a-time version only if it happens.
*/
- if (baddr_from + count <= hSession->rows*hSession->cols &&
- baddr_to + count <= hSession->rows*hSession->cols) {
+ if (baddr_from + count <= hSession->view.rows * hSession->view.cols &&
+ baddr_to + count <= hSession->view.rows * hSession->view.cols) {
ctlr_bcopy(hSession,baddr_from, baddr_to, count, True);
} else {
int i, from, to;
@@ -2656,12 +2544,12 @@ void ctlr_wrapping_memmove(H3270 *hSession, int baddr_to, int baddr_from, int co
for (i = 0; i < count; i++) {
if (baddr_to > baddr_from) {
/* Shifting right, move left. */
- to = (baddr_to + count - 1 - i) % hSession->rows*hSession->cols;
- from = (baddr_from + count - 1 - i) % hSession->rows*hSession->cols;
+ to = (baddr_to + count - 1 - i) % hSession->view.rows * hSession->view.cols;
+ from = (baddr_from + count - 1 - i) % hSession->view.rows * hSession->view.cols;
} else {
/* Shifting left, move right. */
- to = (baddr_to + i) % hSession->rows*hSession->cols;
- from = (baddr_from + i) % hSession->rows*hSession->cols;
+ to = (baddr_to + i) % hSession->view.rows * hSession->view.cols;
+ from = (baddr_from + i) % hSession->view.rows * hSession->view.cols;
}
ctlr_bcopy(hSession,from, to, 1, True);
}
@@ -2714,7 +2602,7 @@ void ctlr_aclear(H3270 *hSession, int baddr, int count, int GNUC_UNUSED(clear_ea
*/
void ctlr_scroll(H3270 *hSession)
{
- int qty = (hSession->rows - 1) * hSession->cols;
+ int qty = (hSession->view.rows - 1) * hSession->view.cols;
/* Make sure nothing is selected. (later this can be fixed) */
// unselect(0, ROWS*COLS);
@@ -2722,10 +2610,10 @@ void ctlr_scroll(H3270 *hSession)
/* Synchronize pending changes prior to this. */
/* Move ea_buf. */
- (void) memmove(&hSession->ea_buf[0], &hSession->ea_buf[hSession->cols],qty * sizeof(struct lib3270_ea));
+ (void) memmove(&hSession->ea_buf[0], &hSession->ea_buf[hSession->view.cols],qty * sizeof(struct lib3270_ea));
/* Clear the last line. */
- (void) memset((char *) &hSession->ea_buf[qty], 0, hSession->cols * sizeof(struct lib3270_ea));
+ (void) memset((char *) &hSession->ea_buf[qty], 0, hSession->view.cols * sizeof(struct lib3270_ea));
hSession->cbk.display(hSession);
diff --git a/src/core/cursor.c b/src/core/cursor.c
index 6c3987b..0a2bbfb 100644
--- a/src/core/cursor.c
+++ b/src/core/cursor.c
@@ -263,9 +263,9 @@ static int cursor_up(H3270 *hSession)
}
#endif /*]*/
- baddr = hSession->cursor_addr - hSession->cols;
+ baddr = hSession->cursor_addr - hSession->view.cols;
if (baddr < 0)
- baddr = (hSession->cursor_addr + (hSession->rows * hSession->cols)) - hSession->cols;
+ baddr = (hSession->cursor_addr + (hSession->view.rows * hSession->view.cols)) - hSession->view.cols;
cursor_move(hSession,baddr);
return 0;
}
@@ -294,7 +294,7 @@ static int cursor_down(H3270 *hSession)
return 0;
}
#endif /*]*/
- baddr = (hSession->cursor_addr + hSession->cols) % (hSession->cols * hSession->rows);
+ baddr = (hSession->cursor_addr + hSession->view.cols) % (hSession->view.cols * hSession->view.rows);
cursor_move(hSession,baddr);
return 0;
}
diff --git a/src/core/keyboard/actions.c b/src/core/keyboard/actions.c
index 9b0c7a3..ccaf55f 100644
--- a/src/core/keyboard/actions.c
+++ b/src/core/keyboard/actions.c
@@ -201,7 +201,8 @@ LIB3270_EXPORT int lib3270_firstfield(H3270 *hSession)
cursor_move(hSession,0);
return 0;
}
- cursor_move(hSession,lib3270_get_next_unprotected(hSession,hSession->rows*hSession->cols-1));
+
+ cursor_move(hSession,lib3270_get_next_unprotected(hSession,hSession->view.rows * hSession->view.cols-1));
return 0;
}
@@ -288,9 +289,9 @@ static Boolean do_delete(H3270 *hSession)
}
else
{
- if ((baddr % hSession->cols) == hSession->cols - ndel)
+ if ((baddr % hSession->view.cols) == hSession->view.cols - ndel)
return True;
- end_baddr = baddr + (hSession->cols - (baddr % hSession->cols)) - 1;
+ end_baddr = baddr + (hSession->view.cols - (baddr % hSession->view.cols)) - 1;
}
/* Shift the remainder of the field left. */
@@ -301,8 +302,8 @@ static Boolean do_delete(H3270 *hSession)
else if (end_baddr != baddr)
{
/* XXX: Need to verify this. */
- ctlr_bcopy(hSession,baddr + ndel, baddr,((hSession->rows * hSession->cols) - 1) - (baddr + ndel) + 1, 0);
- ctlr_bcopy(hSession,0, (hSession->rows * hSession->cols) - ndel, ndel, 0);
+ ctlr_bcopy(hSession,baddr + ndel, baddr,((hSession->view.rows * hSession->view.cols) - 1) - (baddr + ndel) + 1, 0);
+ ctlr_bcopy(hSession,0, (hSession->view.rows * hSession->view.cols) - ndel, ndel, 0);
ctlr_bcopy(hSession,ndel, 0, end_baddr - ndel + 1, 0);
}
diff --git a/src/core/keyboard/kybd.c b/src/core/keyboard/kybd.c
index cf38639..69cb8c5 100644
--- a/src/core/keyboard/kybd.c
+++ b/src/core/keyboard/kybd.c
@@ -574,7 +574,7 @@ static Boolean ins_prep(H3270 *hSession, int faddr, int baddr, int count)
if (faddr == -1)
{
/* Unformatted. Use the end of the line. */
- next_faddr = (((baddr / hSession->cols) + 1) * hSession->cols) % (hSession->rows*hSession->cols);
+ next_faddr = (((baddr / hSession->view.cols) + 1) * hSession->view.cols) % (hSession->view.rows*hSession->view.cols);
}
else
{
@@ -639,8 +639,8 @@ static Boolean ins_prep(H3270 *hSession, int faddr, int baddr, int count)
/* Shift right n_nulls worth. */
copy_len = first_null - baddr;
if (copy_len < 0)
- copy_len += hSession->rows*hSession->cols;
- to = (baddr + n_nulls) % (hSession->rows*hSession->cols);
+ copy_len += hSession->view.rows * hSession->view.cols;
+ to = (baddr + n_nulls) % (hSession->view.rows * hSession->view.cols);
/*
#if defined(_ST)
printf("found %d NULLs at %d\n", n_nulls, first_null);
@@ -876,7 +876,7 @@ static Boolean key_Character(H3270 *hSession, int code, Boolean with_ge, Boolean
while (baddr_fill != faddr) {
/* Check for backward line wrap. */
- if ((baddr_fill % hSession->cols) == hSession->cols - 1)
+ if ((baddr_fill % hSession->view.cols) == hSession->view.cols - 1)
{
Boolean aborted = True;
register int baddr_scan = baddr_fill;
@@ -891,7 +891,7 @@ static Boolean key_Character(H3270 *hSession, int code, Boolean with_ge, Boolean
aborted = False;
break;
}
- if (!(baddr_scan % hSession->cols))
+ if (!(baddr_scan % hSession->view.cols))
break;
DEC_BA(baddr_scan);
}
@@ -947,7 +947,7 @@ LIB3270_EXPORT int lib3270_input_string(H3270 *hSession, const unsigned char *st
for(pos = 0; pos < length && str[pos] && !rc; pos++)
rc = key_ACharacter(hSession,(str[pos] & 0xff), KT_STD, IA_KEY, NULL);
- screen_update(hSession,0,hSession->rows*hSession->cols);
+ screen_update(hSession,0,hSession->view.rows * hSession->view.cols);
return rc;
}
@@ -1228,8 +1228,8 @@ LIB3270_EXPORT int lib3270_newline(H3270 *hSession)
return 0;
}
#endif /*]*/
- baddr = (hSession->cursor_addr + hSession->cols) % (hSession->cols * hSession->rows); /* down */
- baddr = (baddr / hSession->cols) * hSession->cols; /* 1st col */
+ baddr = (hSession->cursor_addr + hSession->view.cols) % (hSession->view.cols * hSession->view.rows); /* down */
+ baddr = (baddr / hSession->view.cols) * hSession->view.cols; /* 1st col */
faddr = lib3270_field_addr(hSession,baddr);
fa = hSession->ea_buf[faddr].fa;
if (faddr != baddr && !FA_IS_PROTECTED(fa))
diff --git a/src/core/model.c b/src/core/model.c
new file mode 100644
index 0000000..5e32abd
--- /dev/null
+++ b/src/core/model.c
@@ -0,0 +1,222 @@
+/*
+ * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
+ * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
+ * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.
+ *
+ * Copyright (C) <2008>
+ *
+ * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
+ * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
+ * Free Software Foundation.
+ *
+ * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
+ * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
+ * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
+ * obter mais detalhes.
+ *
+ * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
+ * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
+ * St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Este programa está nomeado como - e possui - linhas de código.
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ */
+
+ #include
+ #include "screen.h"
+ #include "ctlrc.h"
+ #include "popupsc.h"
+ #include
+ #include
+
+ const char * lib3270_get_oversize(H3270 *hSession)
+ {
+ return hSession->oversize.str;
+ }
+
+ int lib3270_set_oversize(H3270 *hSession, const char GNUC_UNUSED(*value))
+ {
+ if(hSession->cstate != LIB3270_NOT_CONNECTED)
+ return errno = EISCONN;
+
+ if(!hSession->extended)
+ return errno = ENOTSUP;
+
+ // TODO: Implement it!
+ // Replace(hSession->oversize.str,value);
+
+ return errno = ENOTSUP;
+
+ }
+
+/**
+ * @brief Get current 3270 model.
+ *
+ * @param hSession selected 3270 session.
+ * @return Current model number.
+ */
+int lib3270_get_model_number(H3270 *hSession)
+{
+ CHECK_SESSION_HANDLE(hSession);
+ return hSession->model_num;
+}
+
+const char * lib3270_get_model(H3270 *hSession)
+{
+ CHECK_SESSION_HANDLE(hSession);
+ return hSession->model_name;
+}
+
+ /**
+ * @brief Parse the model number.
+ *
+ * @param session Session Handle.
+ * @param m Model number.
+ *
+ * @return -1 (error), 0 (default), or the specified number.
+ */
+static int parse_model_number(H3270 *session, const char *m)
+{
+ int sl;
+ int n;
+
+ if(!m)
+ return 0;
+
+ sl = strlen(m);
+
+ /* An empty model number is no good. */
+ if (!sl)
+ return 0;
+
+ if (sl > 1) {
+ /*
+ * If it's longer than one character, it needs to start with
+ * '327[89]', and it sets the m3279 resource.
+ */
+ if (!strncmp(m, "3278", 4))
+ {
+ session->m3279 = 0;
+ }
+ else if (!strncmp(m, "3279", 4))
+ {
+ session->m3279 = 1;
+ }
+ else
+ {
+ return -1;
+ }
+ m += 4;
+ sl -= 4;
+
+ /* Check more syntax. -E is allowed, but ignored. */
+ switch (m[0]) {
+ case '\0':
+ /* Use default model number. */
+ return 0;
+ case '-':
+ /* Model number specified. */
+ m++;
+ sl--;
+ break;
+ default:
+ return -1;
+ }
+ switch (sl) {
+ case 1: /* n */
+ break;
+ case 3: /* n-E */
+ if (strcasecmp(m + 1, "-E")) {
+ return -1;
+ }
+ break;
+ default:
+ return -1;
+ }
+ }
+
+ /* Check the numeric model number. */
+ n = atoi(m);
+ if (n >= 2 && n <= 5) {
+ return n;
+ } else {
+ return -1;
+ }
+
+}
+
+int lib3270_set_model(H3270 *hSession, const char *model)
+{
+ int ovc, ovr;
+ char junk;
+ int model_number;
+
+ if(hSession->cstate != LIB3270_NOT_CONNECTED)
+ return errno = EISCONN;
+
+ strncpy(hSession->full_model_name,"IBM-",LIB3270_FULL_MODEL_NAME_LENGTH);
+ hSession->model_name = &hSession->full_model_name[4];
+
+ if(!*model)
+ model = "2"; // No model, use the default one
+
+ model_number = parse_model_number(hSession,model);
+ if (model_number < 0)
+ {
+ popup_an_error(hSession,"Invalid model number: %s", model);
+ model_number = 0;
+ }
+
+ if (!model_number)
+ {
+#if defined(RESTRICT_3279)
+ model_number = 3;
+#else
+ model_number = 4;
+#endif
+ }
+
+ if(hSession->mono)
+ hSession->m3279 = 0;
+ else
+ hSession->m3279 = 1;
+
+ if(!hSession->extended)
+ {
+ if(hSession->oversize.str)
+ lib3270_free(hSession->oversize.str);
+ hSession->oversize.str = CN;
+ }
+
+#if defined(RESTRICT_3279)
+ if (hSession->m3279 && model_number == 4)
+ model_number = 3;
+#endif
+
+ trace("Model_number: %d",model_number);
+
+ if (!hSession->extended || hSession->oversize.str == CN || sscanf(hSession->oversize.str, "%dx%d%c", &ovc, &ovr, &junk) != 2)
+ {
+ ovc = 0;
+ ovr = 0;
+ }
+ ctlr_set_rows_cols(hSession, model_number, ovc, ovr);
+
+ if (hSession->termname != CN)
+ hSession->termtype = hSession->termname;
+ else
+ hSession->termtype = hSession->full_model_name;
+
+ trace("Termtype: %s",hSession->termtype);
+
+ ctlr_reinit(hSession,MODEL_CHANGE);
+ screen_update(hSession,0,hSession->view.rows*hSession->view.cols);
+
+ return 0;
+}
+
diff --git a/src/core/paste.c b/src/core/paste.c
index 602f41d..9cc3b7a 100644
--- a/src/core/paste.c
+++ b/src/core/paste.c
@@ -193,8 +193,8 @@ static int set_string(H3270 *hSession, const unsigned char *str, int length)
int faddr;
unsigned char fa;
- baddr = (hSession->cursor_addr + hSession->cols) % (hSession->cols * hSession->rows); /* down */
- baddr = (baddr / hSession->cols) * hSession->cols; /* 1st col */
+ baddr = (hSession->cursor_addr + hSession->view.cols) % (hSession->view.cols * hSession->view.rows); /* down */
+ baddr = (baddr / hSession->view.cols) * hSession->view.cols; /* 1st col */
faddr = lib3270_field_addr(hSession,baddr);
fa = hSession->ea_buf[faddr].fa;
if (faddr != baddr && !FA_IS_PROTECTED(fa))
@@ -248,12 +248,12 @@ LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, unsigned int row, unsi
row--;
col--;
- if(row > hSession->rows || col > hSession->cols)
+ if(row > hSession->view.rows || col > hSession->view.cols)
return - (errno = EOVERFLOW);
hSession->cbk.suspend(hSession);
- hSession->cursor_addr = (row * hSession->cols) + col;
+ hSession->cursor_addr = (row * hSession->view.cols) + col;
rc = set_string(hSession, str, length);
hSession->cbk.resume(hSession);
diff --git a/src/core/properties/string.c b/src/core/properties/string.c
index e96daeb..f950d1e 100644
--- a/src/core/properties/string.c
+++ b/src/core/properties/string.c
@@ -132,6 +132,13 @@
NULL // Set value.
},
+ {
+ "oversize", // Property name.
+ N_( "Screen oversize if larger than the chosen model"), // Property description.
+ lib3270_get_oversize, // Get value.
+ lib3270_set_oversize // Set value.
+ },
+
/*
{
"", // Property name.
diff --git a/src/core/screen.c b/src/core/screen.c
index f09303e..61ff3cd 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -99,9 +99,9 @@ LIB3270_EXPORT LIB3270_ATTR lib3270_get_attribute_at_address(H3270 *hSession, un
if(check_online_session(hSession))
return (LIB3270_ATTR) -1;
- if(!hSession->text ||baddr > (hSession->rows*hSession->cols))
+ if(!hSession->text ||baddr > (hSession->view.rows*hSession->view.cols))
{
- errno = EINVAL;
+ errno = EOVERFLOW;
return (LIB3270_ATTR) -1;
}
@@ -112,9 +112,9 @@ LIB3270_EXPORT int lib3270_is_selected(H3270 *hSession, unsigned int baddr)
{
FAIL_IF_NOT_ONLINE(hSession);
- if(!hSession->text || baddr > (hSession->rows*hSession->cols))
+ if(!hSession->text || baddr > (hSession->view.rows * hSession->view.cols))
{
- errno = EINVAL;
+ errno = EOVERFLOW;
return -1;
}
@@ -125,9 +125,9 @@ LIB3270_EXPORT int lib3270_get_element(H3270 *hSession, unsigned int baddr, unsi
{
FAIL_IF_NOT_ONLINE(hSession);
- if(!hSession->text || baddr > (hSession->rows*hSession->cols))
+ if(!hSession->text || baddr > (hSession->view.rows * hSession->view.cols))
{
- errno = EINVAL;
+ errno = EOVERFLOW;
return -1;
}
@@ -248,14 +248,14 @@ static unsigned short calc_attrs(H3270 *session, int baddr, int fa_addr, int fa)
LIB3270_EXPORT unsigned int lib3270_get_length(H3270 *h)
{
CHECK_SESSION_HANDLE(h);
- return h->rows * h->cols;
+ return h->view.rows * h->view.cols;
}
LIB3270_EXPORT void lib3270_get_screen_size(H3270 *h, unsigned int *r, unsigned int *c)
{
CHECK_SESSION_HANDLE(h);
- *r = h->rows;
- *c = h->cols;
+ *r = h->view.rows;
+ *c = h->view.cols;
// trace("%s: %d - %d",__FUNCTION__, h->rows, h->cols);
@@ -264,22 +264,22 @@ LIB3270_EXPORT void lib3270_get_screen_size(H3270 *h, unsigned int *r, unsigned
LIB3270_EXPORT unsigned int lib3270_get_width(H3270 *h)
{
CHECK_SESSION_HANDLE(h);
- return h->cols;
+ return h->view.cols;
}
LIB3270_EXPORT unsigned int lib3270_get_height(H3270 *h)
{
CHECK_SESSION_HANDLE(h);
- return h->rows;
+ return h->view.rows;
}
void update_model_info(H3270 *session, unsigned int model, unsigned int cols, unsigned int rows)
{
- if(model == session->model_num && session->maxROWS == rows && session->maxCOLS == cols)
+ if(model == session->model_num && session->max.rows == rows && session->max.cols == cols)
return;
- session->maxCOLS = cols;
- session->maxROWS = rows;
+ session->max.cols = cols;
+ session->max.rows = rows;
session->model_num = model;
/* Update the model name. */
@@ -296,7 +296,7 @@ LIB3270_EXPORT int lib3270_get_contents(H3270 *h, int first, int last, unsigned
CHECK_SESSION_HANDLE(h);
- len = h->rows * h->cols;
+ len = h->view.rows * h->view.cols;
if(first > len || last > len || first < 0 || last < 0)
return EFAULT;
@@ -377,7 +377,7 @@ void screen_update(H3270 *session, int bstart, int bend)
for(f=first;fcols == 0)
+ if(f%session->view.cols == 0)
len++;
}
@@ -430,10 +430,10 @@ LIB3270_EXPORT int lib3270_translate_to_address(H3270 *hSession, unsigned int ro
row--;
col--;
- if(row > hSession->rows || col > hSession->cols)
+ if(row > hSession->view.rows || col > hSession->view.cols)
return - (errno = EOVERFLOW);
- return (row * hSession->cols) + col;
+ return (row * hSession->view.cols) + col;
}
@@ -443,7 +443,7 @@ LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, unsigned int badd
trace("%s(%d)",__FUNCTION__,baddr);
- if(baddr > (hSession->rows * hSession->cols))
+ if(baddr > (hSession->view.rows * hSession->view.cols))
return - (errno = EOVERFLOW);
if(hSession->selected && !lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_SELECTED))
@@ -481,8 +481,8 @@ int cursor_move(H3270 *hSession, int baddr)
hSession->cursor_addr = baddr;
hSession->cbk.update_cursor(
hSession,
- (unsigned short) (baddr/hSession->cols),
- (unsigned short) (baddr%hSession->cols),
+ (unsigned short) (baddr/hSession->view.cols),
+ (unsigned short) (baddr%hSession->view.cols),
hSession->text[baddr].chr,
hSession->text[baddr].attr
);
@@ -652,16 +652,16 @@ void set_viewsize(H3270 *session, unsigned int rows, unsigned int cols)
{
CHECK_SESSION_HANDLE(session);
- if(rows == session->rows && session->cols == cols)
+ if(rows == session->view.rows && session->view.cols == cols)
return;
- session->rows = rows;
- session->cols = cols;
+ session->view.rows = rows;
+ session->view.cols = cols;
trace("View size changes to %dx%d",rows,cols);
if(session->cbk.configure)
- session->cbk.configure(session,session->rows,session->cols);
+ session->cbk.configure(session,session->view.rows,session->view.cols);
}
@@ -896,7 +896,7 @@ LIB3270_EXPORT int lib3270_testpattern(H3270 *hSession)
FAIL_IF_ONLINE(hSession);
- max = (hSession->maxROWS * hSession->maxCOLS);
+ max = (hSession->max.rows * hSession->max.cols);
for(f=0;frows*session->cols);
+ screen_update(session,0,session->view.rows*session->view.cols);
}
static void nop_int(H3270 GNUC_UNUSED(*session), int GNUC_UNUSED(width))
diff --git a/src/core/sf.c b/src/core/sf.c
index 4e7a412..96af413 100644
--- a/src/core/sf.c
+++ b/src/core/sf.c
@@ -552,14 +552,14 @@ static enum pds sf_create_partition(H3270 *hSession, unsigned char buf[], int bu
GET16(h, &buf[6]);
trace_ds(hSession,",h=%d", h);
} else
- h = hSession->maxROWS;
+ h = hSession->max.rows;
if (buflen > 9)
{
GET16(w, &buf[8]);
trace_ds(hSession,",w=%d", w);
} else
- w = hSession->maxCOLS;
+ w = hSession->max.cols;
if (buflen > 11)
{
@@ -579,14 +579,14 @@ static enum pds sf_create_partition(H3270 *hSession, unsigned char buf[], int bu
GET16(hv, &buf[14]);
trace_ds(hSession,",hv=%d", hv);
} else
- hv = (h > hSession->maxROWS)? hSession->maxROWS: h;
+ hv = (h > hSession->max.rows)? hSession->max.rows: h;
if (buflen > 17)
{
GET16(wv, &buf[16]);
trace_ds(hSession,",wv=%d", wv);
} else
- wv = (w > hSession->maxCOLS)? hSession->maxCOLS: w;
+ wv = (w > hSession->max.cols)? hSession->max.cols: w;
if (buflen > 19)
{
@@ -787,8 +787,8 @@ static void do_qr_usable_area(H3270 *hSession)
space3270out(hSession,19);
*hSession->obptr++ = 0x01; /* 12/14-bit addressing */
*hSession->obptr++ = 0x00; /* no special character features */
- SET16(hSession->obptr, hSession->maxCOLS); /* usable width */
- SET16(hSession->obptr, hSession->maxROWS); /* usable height */
+ SET16(hSession->obptr, hSession->max.cols); /* usable width */
+ SET16(hSession->obptr, hSession->max.rows); /* usable height */
*hSession->obptr++ = 0x01; /* units (mm) */
num = display_widthMM();
denom = display_width();
@@ -810,7 +810,7 @@ static void do_qr_usable_area(H3270 *hSession)
SET16(hSession->obptr, (int)denom); /* Yr denominator */
*hSession->obptr++ = *char_width; /* AW */
*hSession->obptr++ = *char_height; /* AH */
- SET16(hSession->obptr, hSession->maxCOLS * hSession->maxROWS); /* buffer, questionable */
+ SET16(hSession->obptr, hSession->max.cols * hSession->max.cols); /* buffer, questionable */
}
static void do_qr_color(H3270 *hSession)
@@ -897,7 +897,7 @@ static void do_qr_alpha_part(H3270 *hSession)
trace_ds(hSession,"> QueryReply(AlphanumericPartitions)\n");
space3270out(hSession,4);
*hSession->obptr++ = 0; /* 1 partition */
- SET16(hSession->obptr, hSession->maxROWS * hSession->maxCOLS); /* buffer space */
+ SET16(hSession->obptr, hSession->max.cols * hSession->max.rows); /* buffer space */
*hSession->obptr++ = 0; /* no special features */
}
@@ -1009,8 +1009,8 @@ static void do_qr_imp_part(H3270 *hSession)
*hSession->obptr++ = 0x00; /* reserved */
SET16(hSession->obptr, 80); /* implicit partition width */
SET16(hSession->obptr, 24); /* implicit partition height */
- SET16(hSession->obptr, hSession->maxCOLS); /* alternate height */
- SET16(hSession->obptr, hSession->maxROWS); /* alternate width */
+ SET16(hSession->obptr, hSession->max.cols); /* alternate height */
+ SET16(hSession->obptr, hSession->max.rows); /* alternate width */
}
static void query_reply_end(H3270 *hSession)
diff --git a/src/core/telnet.c b/src/core/telnet.c
index 060d185..82d933b 100644
--- a/src/core/telnet.c
+++ b/src/core/telnet.c
@@ -246,9 +246,8 @@ static const char *trsp_flag[2] = { "POSITIVE-RESPONSE", "NEGATIVE-RESPONSE" };
#endif /*]*/
#endif /*]*/
-#define XMIT_ROWS hSession->maxROWS
-#define XMIT_COLS hSession->maxCOLS
-
+#define XMIT_ROWS hSession->max.rows
+#define XMIT_COLS hSession->max.cols
#if defined(_WIN32) /*[*/
#define socket_errno() WSAGetLastError()
diff --git a/src/core/toggles.c b/src/core/toggles.c
index 1e834b7..cd00d78 100644
--- a/src/core/toggles.c
+++ b/src/core/toggles.c
@@ -338,7 +338,7 @@ LIB3270_EXPORT int lib3270_toggle(H3270 *session, LIB3270_TOGGLE ix)
static void toggle_altscreen(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_TYPE GNUC_UNUSED(tt))
{
if(!session->screen_alt)
- set_viewsize(session,t->value ? 24 : session->maxROWS,80);
+ set_viewsize(session,t->value ? 24 : session->max.rows,80);
}
static void toggle_redraw(H3270 *session, struct lib3270_toggle GNUC_UNUSED(*t), LIB3270_TOGGLE_TYPE GNUC_UNUSED(tt))
diff --git a/src/core/trace_ds.c b/src/core/trace_ds.c
index 37a073c..64070bb 100644
--- a/src/core/trace_ds.c
+++ b/src/core/trace_ds.c
@@ -77,7 +77,7 @@ static void wtrace(H3270 *session, const char *fmt, ...);
const char * rcba(H3270 *hSession, int baddr)
{
static char buf[48];
- (void) snprintf(buf, 48, "(%d,%d)", baddr/hSession->cols + 1, baddr%hSession->cols + 1);
+ (void) snprintf(buf, 48, "(%d,%d)", baddr/hSession->view.cols + 1, baddr%hSession->view.cols + 1);
return buf;
}
@@ -262,12 +262,12 @@ void trace_screen(H3270 *session)
{
unsigned int row, baddr;
- for(row=baddr=0;row < session->rows;row++)
+ for(row=baddr=0;row < session->view.rows;row++)
{
unsigned int col;
wtrace(session,"%02d ",row+1);
- for(col = 0; col < session->cols;col++)
+ for(col = 0; col < session->view.cols;col++)
{
if(session->text[baddr].attr & LIB3270_ATTR_CG)
wtrace(session,"%c",'.');
@@ -305,7 +305,7 @@ void trace_ansi_disc(H3270 *hSession)
unsigned int i;
wtrace(hSession,"%c",'\n');
- for (i = 0; i < hSession->cols; i++)
+ for (i = 0; i < hSession->view.cols; i++)
wtrace(hSession,"%c",'=');
wtrace(hSession,"%c",'\n');
diff --git a/src/include/3270ds.h b/src/include/3270ds.h
index ace5e8d..2bb1646 100644
--- a/src/include/3270ds.h
+++ b/src/include/3270ds.h
@@ -141,11 +141,11 @@
#define QR_IMP_PART 0xa6 /* implicit partition */
#define QR_NULL 0xff /* null */
-#define BA_TO_ROW(ba) ((ba) / hSession->cols)
-#define BA_TO_COL(ba) ((ba) % hSession->cols)
-#define ROWCOL_TO_BA(r,c) (((r) * hSession->cols) + c)
-#define INC_BA(ba) { (ba) = ((ba) + 1) % (hSession->cols * hSession->rows); }
-#define DEC_BA(ba) { (ba) = (ba) ? (ba - 1) : (((int) (hSession->cols*hSession->rows)) - 1); }
+#define BA_TO_ROW(ba) ((ba) / hSession->view.cols)
+#define BA_TO_COL(ba) ((ba) % hSession->view.cols)
+#define ROWCOL_TO_BA(r,c) (((r) * hSession->view.cols) + c)
+#define INC_BA(ba) { (ba) = ((ba) + 1) % (hSession->view.cols * hSession->view.rows); }
+#define DEC_BA(ba) { (ba) = (ba) ? (ba - 1) : (((int) (hSession->view.cols*hSession->view.rows)) - 1); }
/** Field attributes. */
#define FA_PRINTABLE 0xc0 ///< @brief these make the character "printable" */
diff --git a/src/include/lib3270-internals.h b/src/include/lib3270-internals.h
index 4a1c826..cfcf557 100644
--- a/src/include/lib3270-internals.h
+++ b/src/include/lib3270-internals.h
@@ -362,7 +362,7 @@ struct _h3270
int modified_sel : 1;
int mono : 1; ///< @brief Forces monochrome display
int m3279 : 1;
- int extended : 1;
+ int extended : 1; ///< @brief Extended data stream.
int typeahead : 1;
int numeric_lock : 1;
int oerr_lock : 1; ///< @brief If true, operator errors will lock the keyboard.
@@ -385,8 +385,6 @@ struct _h3270
int formatted : 1; /**< @brief Formatted screen flag */
int starting : 1; /**< @brief Is starting (no first screen)? */
- char * oversize;
-
struct lib3270_toggle
{
char value; /**< toggle value */
@@ -428,12 +426,28 @@ struct _h3270
H3270FT * ft; /**< @brief Active file transfer data */
// screen info
- unsigned int ov_rows;
- unsigned int ov_cols;
- unsigned int maxROWS;
- unsigned int maxCOLS;
- unsigned int rows;
- unsigned int cols;
+
+ // Oversize.
+ struct
+ {
+ char * str;
+ unsigned int rows;
+ unsigned int cols;
+ } oversize;
+
+ // Maximum screen size.
+ struct
+ {
+ unsigned int rows;
+ unsigned int cols;
+ } max;
+
+ // View size
+ struct {
+ unsigned int rows;
+ unsigned int cols;
+ } view;
+
LIB3270_POINTER pointer; /**< @brief Current pointer. */
int cursor_addr;
int buffer_addr;
diff --git a/src/include/lib3270.h b/src/include/lib3270.h
index eac57e5..02df917 100644
--- a/src/include/lib3270.h
+++ b/src/include/lib3270.h
@@ -1196,7 +1196,7 @@
* @param col Desired col.
*
*/
- LIB3270_EXPORT int lib3270_get_is_protected_at(H3270 *h, int row, int col);
+ LIB3270_EXPORT int lib3270_get_is_protected_at(H3270 *h, unsigned int row, unsigned int col);
/**
* @brief Get address of the first blank.
diff --git a/src/include/lib3270/properties.h b/src/include/lib3270/properties.h
index c6d1df9..b43785a 100644
--- a/src/include/lib3270/properties.h
+++ b/src/include/lib3270/properties.h
@@ -128,6 +128,7 @@
/**
* @brief Set lib3270 integer property by name.
*
+ * @param hSession Session handle.
* @param name Nome of the property.
* @param value New property value.
* @param seconds Time (in seconds) whe should wait for "ready" state (0 = none).
@@ -137,6 +138,31 @@
*/
LIB3270_EXPORT int lib3270_set_string_property(H3270 * hSession, const char *name, const char * value, int seconds);
+
+ /**
+ * @brief Get Oversize.
+ *
+ * @param hSession Session handle.
+ *
+ * @return Oversize definition (NULL if not set).
+ *
+ */
+ LIB3270_EXPORT const char * lib3270_get_oversize(H3270 *hSession);
+
+ /**
+ * @brief Set oversize.
+ *
+ * @param hSession Session handle.
+ * @param value Oversize value.
+ *
+ * @return 0 if success, error code if not (sets errno)
+ *
+ * @retval EISCONN Already connected to host.
+ * @retval ENOTSUP Oversize is not supported.
+ *
+ */
+ LIB3270_EXPORT int lib3270_set_oversize(H3270 *hSession, const char *value);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/selection/actions.c b/src/selection/actions.c
index d4fb48b..907d279 100644
--- a/src/selection/actions.c
+++ b/src/selection/actions.c
@@ -51,7 +51,7 @@ LIB3270_EXPORT int lib3270_unselect(H3270 *hSession)
{
hSession->selected = 0;
- for(a = 0; a < ((int) (hSession->rows*hSession->cols)); a++)
+ for(a = 0; a < ((int) (hSession->view.rows * hSession->view.cols)); a++)
{
if(hSession->text[a].attr & LIB3270_ATTR_SELECTED)
{
@@ -94,7 +94,7 @@ LIB3270_EXPORT int lib3270_select_region(H3270 *h, int start, int end)
if(!lib3270_connected(h))
return ENOTCONN;
- maxlen = (h->rows * h->cols);
+ maxlen = (h->view.rows * h->view.cols);
// Check bounds
if(start < 0 || start > maxlen || end < 0 || end > maxlen || start > end)
@@ -143,7 +143,7 @@ LIB3270_EXPORT int lib3270_select_all(H3270 * hSession)
{
FAIL_IF_NOT_ONLINE(hSession);
- do_select(hSession,0,(hSession->rows*hSession->cols)-1,0);
+ do_select(hSession,0,(hSession->view.rows * hSession->view.cols)-1,0);
return 0;
}
@@ -200,28 +200,28 @@ LIB3270_EXPORT int lib3270_move_selected_area(H3270 *hSession, int from, int to)
if(!lib3270_get_selection_bounds(hSession,&pos[0],&pos[1]))
return from;
- rows = (to / hSession->cols) - (from / hSession->cols);
- cols = (to % hSession->cols) - (from % hSession->cols);
+ rows = (to / hSession->view.cols) - (from / hSession->view.cols);
+ cols = (to % hSession->view.cols) - (from % hSession->view.cols);
for(f=0;f<2;f++)
{
- int row = (pos[f] / hSession->cols) + rows;
- int col = (pos[f] % hSession->cols) + cols;
+ int row = (pos[f] / hSession->view.cols) + rows;
+ int col = (pos[f] % hSession->view.cols) + cols;
if(row < 0)
- rows = - (pos[f] / hSession->cols);
+ rows = - (pos[f] / hSession->view.cols);
if(col < 0)
- cols = - (pos[f] % hSession->cols);
+ cols = - (pos[f] % hSession->view.cols);
- if(row >= ((int) hSession->rows))
- rows = hSession->rows - ((pos[f] / hSession->cols)+1);
+ if(row >= ((int) hSession->view.rows))
+ rows = hSession->view.rows - ((pos[f] / hSession->view.cols)+1);
- if(col >= ((int) hSession->cols))
- cols = hSession->cols - ((pos[f] % hSession->cols)+1);
+ if(col >= ((int) hSession->view.cols))
+ cols = hSession->view.cols - ((pos[f] % hSession->view.cols)+1);
}
- step = (rows * hSession->cols) + cols;
+ step = (rows * hSession->view.cols) + cols;
do_select(hSession,hSession->select.start + step,hSession->select.end + step,hSession->rectsel);
cursor_move(hSession,hSession->select.end);
@@ -251,20 +251,20 @@ LIB3270_EXPORT int lib3270_drag_selection(H3270 *h, unsigned char flag, int orig
else if((flag&0x8F) == SELECTION_ACTIVE)
return lib3270_move_selected_area(h,origin,baddr);
- row = baddr/h->cols;
- col = baddr%h->cols;
+ row = baddr/h->view.cols;
+ col = baddr%h->view.cols;
if(flag & SELECTION_LEFT) // Update left margin
- origin = first = ((first/h->cols)*h->cols) + col;
+ origin = first = ((first/h->view.cols)*h->view.cols) + col;
if(flag & SELECTION_TOP) // Update top margin
- origin = first = (row*h->cols) + (first%h->cols);
+ origin = first = (row*h->view.cols) + (first%h->view.cols);
if(flag & SELECTION_RIGHT) // Update right margin
- origin = last = ((last/h->cols)*h->cols) + col;
+ origin = last = ((last/h->view.cols)*h->view.cols) + col;
if(flag & SELECTION_BOTTOM) // Update bottom margin
- origin = last = (row*h->cols) + (last%h->cols);
+ origin = last = (row*h->view.cols) + (last%h->view.cols);
trace("origin=%d first=%d last=%d",origin,first,last);
@@ -291,28 +291,28 @@ LIB3270_EXPORT int lib3270_move_selection(H3270 *hSession, LIB3270_DIRECTION dir
switch(dir)
{
case LIB3270_DIR_UP:
- if(start <= ((int) hSession->cols))
+ if(start <= ((int) hSession->view.cols))
return EINVAL;
- start -= hSession->cols;
- end -= hSession->cols;
+ start -= hSession->view.cols;
+ end -= hSession->view.cols;
break;
case LIB3270_DIR_DOWN:
- if(end >= ((int) (hSession->cols * (hSession->rows-1))))
+ if(end >= ((int) (hSession->view.cols * (hSession->view.rows-1))))
return EINVAL;
- start += hSession->cols;
- end += hSession->cols;
+ start += hSession->view.cols;
+ end += hSession->view.cols;
break;
case LIB3270_DIR_LEFT:
- if( (start % hSession->cols) < 1)
+ if( (start % hSession->view.cols) < 1)
return EINVAL;
start--;
end--;
break;
case LIB3270_DIR_RIGHT:
- if( (end % hSession->cols) >= (hSession->cols-1))
+ if( (end % hSession->view.cols) >= (hSession->view.cols-1))
return EINVAL;
start++;
end++;
diff --git a/src/selection/get.c b/src/selection/get.c
index 4084987..2d23b35 100644
--- a/src/selection/get.c
+++ b/src/selection/get.c
@@ -53,7 +53,7 @@ LIB3270_EXPORT char * lib3270_get_selected_text(H3270 *hSession, char tok, LIB32
{
int row, col, baddr;
char * ret;
- size_t buflen = (hSession->rows * (hSession->cols+1))+1;
+ size_t buflen = (hSession->view.rows * (hSession->view.cols+1))+1;
size_t sz = 0;
unsigned short attr = 0xFFFF;
char cut = (options & LIB3270_SELECTION_CUT) != 0;
@@ -73,11 +73,11 @@ LIB3270_EXPORT char * lib3270_get_selected_text(H3270 *hSession, char tok, LIB32
baddr = 0;
unsigned char fa = 0;
- for(row=0;row < ((int) hSession->rows);row++)
+ for(row=0;row < ((int) hSession->view.rows);row++)
{
int cr = 0;
- for(col = 0; col < ((int) hSession->cols);col++)
+ for(col = 0; col < ((int) hSession->view.cols);col++)
{
if(hSession->ea_buf[baddr].fa) {
fa = hSession->ea_buf[baddr].fa;
diff --git a/src/selection/selection.c b/src/selection/selection.c
index 5610f59..961e410 100644
--- a/src/selection/selection.c
+++ b/src/selection/selection.c
@@ -65,10 +65,10 @@ static void update_selected_rectangle(H3270 *session)
get_selected_addr(session,&begin,&end);
// Get start & end posision
- p[0].row = (begin/session->cols);
- p[0].col = (begin%session->cols);
- p[1].row = (end/session->cols);
- p[1].col = (end%session->cols);
+ p[0].row = (begin/session->view.cols);
+ p[0].col = (begin%session->view.cols);
+ p[1].row = (end/session->view.cols);
+ p[1].col = (end%session->view.cols);
if(p[0].row > p[1].row)
{
@@ -86,9 +86,9 @@ static void update_selected_rectangle(H3270 *session)
// First remove unselected areas
baddr = 0;
- for(row=0;row < ((int) session->rows);row++)
+ for(row=0;row < ((int) session->view.rows);row++)
{
- for(col = 0; col < ((int) session->cols);col++)
+ for(col = 0; col < ((int) session->view.cols);col++)
{
if(!(row >= p[0].row && row <= p[1].row && col >= p[0].col && col <= p[1].col) && (session->text[baddr].attr & LIB3270_ATTR_SELECTED))
{
@@ -101,9 +101,9 @@ static void update_selected_rectangle(H3270 *session)
// Then, draw selected ones
baddr = 0;
- for(row=0;row < ((int) session->rows);row++)
+ for(row=0;row < ((int) session->view.rows);row++)
{
- for(col = 0; col < ((int) session->cols);col++)
+ for(col = 0; col < ((int) session->view.cols);col++)
{
if((row >= p[0].row && row <= p[1].row && col >= p[0].col && col <= p[1].col) && !(session->text[baddr].attr & LIB3270_ATTR_SELECTED))
{
@@ -119,7 +119,7 @@ static void update_selected_rectangle(H3270 *session)
static void update_selected_region(H3270 *session)
{
int baddr,begin,end;
- int len = session->rows*session->cols;
+ int len = session->view.rows * session->view.cols;
get_selected_addr(session,&begin,&end);
@@ -167,7 +167,7 @@ void toggle_rectselect(H3270 *session, struct lib3270_toggle GNUC_UNUSED(*t), LI
void do_select(H3270 *h, unsigned int start, unsigned int end, unsigned int rect)
{
- if(end > (h->rows * h->cols))
+ if(end > (h->view.rows * h->view.cols))
return;
// Do we really need to change selection?
@@ -209,11 +209,11 @@ LIB3270_EXPORT unsigned char lib3270_get_selection_flags(H3270 *hSession, int ba
if(!(lib3270_connected(hSession) && (hSession->text[baddr].attr & LIB3270_ATTR_SELECTED)))
return rc;
- row = baddr / hSession->cols;
- col = baddr % hSession->cols;
+ row = baddr / hSession->view.cols;
+ col = baddr % hSession->view.cols;
rc |= SELECTION_ACTIVE;
- if( (hSession->select.start % hSession->cols) == (hSession->select.end % hSession->cols) )
+ if( (hSession->select.start % hSession->view.cols) == (hSession->select.end % hSession->view.cols) )
{
rc |= SELECTION_SINGLE_COL;
}
@@ -224,20 +224,20 @@ LIB3270_EXPORT unsigned char lib3270_get_selection_flags(H3270 *hSession, int ba
/// FIXME: It should test if baddr is the last element before the +1.
- if( (col == ((int) hSession->cols)) || !(hSession->text[baddr+1].attr & LIB3270_ATTR_SELECTED) )
+ if( (col == ((int) hSession->view.cols)) || !(hSession->text[baddr+1].attr & LIB3270_ATTR_SELECTED) )
rc |= SELECTION_RIGHT;
}
- if( (hSession->select.start / hSession->cols) == (hSession->select.end / hSession->cols) )
+ if( (hSession->select.start / hSession->view.cols) == (hSession->select.end / hSession->view.cols) )
{
rc |= SELECTION_SINGLE_ROW;
}
else
{
- if( (row == 0) || !(hSession->text[baddr-hSession->cols].attr & LIB3270_ATTR_SELECTED) )
+ if( (row == 0) || !(hSession->text[baddr-hSession->view.cols].attr & LIB3270_ATTR_SELECTED) )
rc |= SELECTION_TOP;
- if( (row == ((int) hSession->rows)) || !(hSession->text[baddr+hSession->cols].attr & LIB3270_ATTR_SELECTED) )
+ if( (row == ((int) hSession->view.rows)) || !(hSession->text[baddr+hSession->view.cols].attr & LIB3270_ATTR_SELECTED) )
rc |= SELECTION_BOTTOM;
}
@@ -254,7 +254,7 @@ LIB3270_EXPORT char * lib3270_get_region(H3270 *h, int start_pos, int end_pos, u
if(check_online_session(h))
return NULL;
- maxlen = h->rows * (h->cols+1);
+ maxlen = h->view.rows * (h->view.cols+1);
if(start_pos < 0 || start_pos > maxlen || end_pos < 0 || end_pos > maxlen || end_pos < start_pos)
return NULL;
@@ -266,7 +266,7 @@ LIB3270_EXPORT char * lib3270_get_region(H3270 *h, int start_pos, int end_pos, u
if(all || h->text[baddr].attr & LIB3270_ATTR_SELECTED)
text[sz++] = (h->text[baddr].attr & LIB3270_ATTR_CG) ? ' ' : h->text[baddr].chr;
- if((baddr%h->cols) == 0 && sz > 0)
+ if((baddr%h->view.cols) == 0 && sz > 0)
text[sz++] = '\n';
}
text[sz++] = 0;
@@ -291,7 +291,7 @@ LIB3270_EXPORT char * lib3270_get_string_at_address(H3270 *h, int offset, int le
if(offset < 0)
offset = lib3270_get_cursor_address(h);
- maxlen = (h->rows * (h->cols+ (lf ? 1 : 0) )) - offset;
+ maxlen = (h->view.rows * (h->view.cols+ (lf ? 1 : 0) )) - offset;
if(maxlen <= 0 || offset < 0)
{
errno = EOVERFLOW;
@@ -321,7 +321,7 @@ LIB3270_EXPORT char * lib3270_get_string_at_address(H3270 *h, int offset, int le
offset++;
len--;
- if(lf && (offset%h->cols) == 0 && len > 0)
+ if(lf && (offset%h->view.cols) == 0 && len > 0)
{
*(ptr++) = lf;
len--;
@@ -408,16 +408,16 @@ LIB3270_EXPORT int lib3270_get_selection_rectangle(H3270 *hSession, unsigned int
if(!hSession->selected || hSession->select.start == hSession->select.end)
return errno = ENOENT;
- minRow = hSession->rows;
- minCol = hSession->cols;
+ minRow = hSession->view.rows;
+ minCol = hSession->view.cols;
maxRow = 0;
maxCol = 0;
baddr = 0;
count = 0;
- for(r=0;r < hSession->rows;r++)
+ for(r=0;r < hSession->view.rows;r++)
{
- for(c = 0; c < hSession->cols;c++)
+ for(c = 0; c < hSession->view.cols;c++)
{
if(hSession->text[baddr].attr & LIB3270_ATTR_SELECTED)
{
--
libgit2 0.21.2