about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/ui.h4
-rw-r--r--src/ui/window.c16
-rw-r--r--src/ui/windows.c18
3 files changed, 19 insertions, 19 deletions
diff --git a/src/ui/ui.h b/src/ui/ui.h
index e2ede545..4c5c7013 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -52,8 +52,8 @@
 #include "xmpp/xmpp.h"
 
 #define INP_WIN_MAX 1000
-#define OCCUPANT_WIN_RATIO 5
-#define OCCUPANT_WIN_WIDTH 100
+#define SUB_WIN_RATIO 5
+#define SUB_WIN_WIDTH 100
 
 void ui_init_module(void);
 void console_init_module(void);
diff --git a/src/ui/window.c b/src/ui/window.c
index d245a333..9ded46ca 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -62,11 +62,11 @@ win_create(const char * const title, int cols, win_type_t type)
     ProfWin *new_win = malloc(sizeof(struct prof_win_t));
     new_win->from = strdup(title);
 
-    if (type == WIN_MUC && prefs_get_boolean(PREF_OCCUPANTS)) {
-        new_win->win = newpad(PAD_SIZE, (cols/OCCUPANT_WIN_RATIO) * (OCCUPANT_WIN_RATIO-1));
+    if ((type == WIN_MUC && prefs_get_boolean(PREF_OCCUPANTS)) || (type == WIN_CONSOLE)) {
+        new_win->win = newpad(PAD_SIZE, (cols/SUB_WIN_RATIO) * (SUB_WIN_RATIO-1));
         wbkgd(new_win->win, COLOUR_TEXT);
 
-        new_win->subwin = newpad(PAD_SIZE, OCCUPANT_WIN_WIDTH);
+        new_win->subwin = newpad(PAD_SIZE, SUB_WIN_WIDTH);
         wbkgd(new_win->subwin, COLOUR_TEXT);
     } else {
         new_win->win = newpad(PAD_SIZE, (cols));
@@ -108,11 +108,11 @@ void
 win_show_subwin(ProfWin *window)
 {
     if (!window->subwin) {
-        window->subwin = newpad(PAD_SIZE, OCCUPANT_WIN_WIDTH);
+        window->subwin = newpad(PAD_SIZE, SUB_WIN_WIDTH);
         wbkgd(window->subwin, COLOUR_TEXT);
 
         int cols = getmaxx(stdscr);
-        wresize(window->win, PAD_SIZE, (cols/OCCUPANT_WIN_RATIO) * (OCCUPANT_WIN_RATIO-1));
+        wresize(window->win, PAD_SIZE, (cols/SUB_WIN_RATIO) * (SUB_WIN_RATIO-1));
         win_redraw(window);
     }
 }
@@ -136,9 +136,9 @@ win_update_virtual(ProfWin *window)
     int rows, cols;
     getmaxyx(stdscr, rows, cols);
 
-    if ((window->type == WIN_MUC) && (window->subwin)) {
-        pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, ((cols/OCCUPANT_WIN_RATIO) * (OCCUPANT_WIN_RATIO-1)) -1);
-        pnoutrefresh(window->subwin, window->sub_y_pos, 0, 1, (cols/OCCUPANT_WIN_RATIO) * (OCCUPANT_WIN_RATIO-1), rows-3, cols-1);
+    if (((window->type == WIN_MUC) || (window->type == WIN_CONSOLE)) && (window->subwin)) {
+        pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, ((cols/SUB_WIN_RATIO) * (SUB_WIN_RATIO-1)) -1);
+        pnoutrefresh(window->subwin, window->sub_y_pos, 0, 1, (cols/SUB_WIN_RATIO) * (SUB_WIN_RATIO-1), rows-3, cols-1);
     } else {
         pnoutrefresh(window->win, window->y_pos, 0, 1, 0, rows-3, cols-1);
     }
diff --git a/src/ui/windows.c b/src/ui/windows.c
index c9f04cb5..89988996 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -294,8 +294,8 @@ wins_resize_all(void)
     GList *curr = values;
     while (curr != NULL) {
         ProfWin *window = curr->data;
-        if ((window->type == WIN_MUC) && (window->subwin)) {
-            wresize(window->win, PAD_SIZE, (cols/OCCUPANT_WIN_RATIO) * (OCCUPANT_WIN_RATIO-1));
+        if (((window->type == WIN_MUC) || (window->type == WIN_CONSOLE)) && (window->subwin)) {
+            wresize(window->win, PAD_SIZE, (cols/SUB_WIN_RATIO) * (SUB_WIN_RATIO-1));
         } else {
             wresize(window->win, PAD_SIZE, cols);
         }
@@ -305,9 +305,9 @@ wins_resize_all(void)
     g_list_free(values);
 
     ProfWin *current_win = wins_get_current();
-    if ((current_win->type == WIN_MUC) && (current_win->subwin)) {
-        pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, ((cols/OCCUPANT_WIN_RATIO) * (OCCUPANT_WIN_RATIO-1)) -1);
-        pnoutrefresh(current_win->subwin, current_win->sub_y_pos, 0, 1, (cols/OCCUPANT_WIN_RATIO) * (OCCUPANT_WIN_RATIO-1), rows-3, cols-1);
+    if (((current_win->type == WIN_MUC) || (current_win->type == WIN_CONSOLE)) && (current_win->subwin)) {
+        pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, ((cols/SUB_WIN_RATIO) * (SUB_WIN_RATIO-1)) -1);
+        pnoutrefresh(current_win->subwin, current_win->sub_y_pos, 0, 1, (cols/SUB_WIN_RATIO) * (SUB_WIN_RATIO-1), rows-3, cols-1);
     } else {
         pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, cols-1);
     }
@@ -322,7 +322,7 @@ wins_hide_subwin(ProfWin *window)
     win_hide_subwin(window);
 
     ProfWin *current_win = wins_get_current();
-    if (current_win->type == WIN_MUC) {
+    if ((current_win->type == WIN_MUC) || (current_win->type == WIN_CONSOLE)) {
         pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, cols-1);
     }
 }
@@ -336,9 +336,9 @@ wins_show_subwin(ProfWin *window)
     win_show_subwin(window);
 
     ProfWin *current_win = wins_get_current();
-    if (current_win->type == WIN_MUC) {
-        pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, ((cols/OCCUPANT_WIN_RATIO) * (OCCUPANT_WIN_RATIO-1)) -1);
-        pnoutrefresh(current_win->subwin, current_win->sub_y_pos, 0, 1, (cols/OCCUPANT_WIN_RATIO) * (OCCUPANT_WIN_RATIO-1), rows-3, cols-1);
+    if ((current_win->type == WIN_MUC) || (current_win->type == WIN_CONSOLE)) {
+        pnoutrefresh(current_win->win, current_win->y_pos, 0, 1, 0, rows-3, ((cols/SUB_WIN_RATIO) * (SUB_WIN_RATIO-1)) -1);
+        pnoutrefresh(current_win->subwin, current_win->sub_y_pos, 0, 1, (cols/SUB_WIN_RATIO) * (SUB_WIN_RATIO-1), rows-3, cols-1);
     }
 }
 
: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# write-int: add a single int to a stream

== code
#   instruction                     effective address                                                   register    displacement    immediate
# . op          subop               mod             rm32          base        index         scale       r32
# . 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes

write-int:  # out : (address stream), n : int
    # . prologue
    55/push-ebp
    89/copy                         3/mod/direct    5/rm32/ebp    .           .             .           4/r32/esp   .               .                 # copy esp to ebp
    # . save registers
    50/push-eax
    51/push-ecx
    57/push-edi
    # edi = out
    8b/copy                         1/mod/*+disp8   5/rm32/ebp    .           .             .           7/r32/edi   8/disp8         .                 # copy *(ebp+8) to edi
    # ecx = out->write
    8b/copy                         0/mod/indirect  7/rm32/edi    .           .             .           1/r32/ecx   .               .                 # copy *edi to ecx
    # if (out->write >= out->length) abort
    3b/compare                      1/mod/*+disp8   7/rm32/edi    .           .             .           1/r32/ecx   8/disp8         .                 # compare ecx with *(edi+8)
    7d/jump-if-greater-or-equal  $write-int:abort/disp8
$write-int:to-stream:
    # out->data[out->write] = n
    8b/copy                         1/mod/*+disp8   5/rm32/ebp    .           .             .           0/r32/eax   0xc/disp8       .                 # copy *(ebp+12) to eax
    89/copy                         1/mod/*+disp8   4/rm32/sib    7/base/edi  1/index/ecx   .           0/r32/eax   0xc/disp8       .                 # copy eax to *(edi+ecx+12)
    # out->write += 4
    81          0/subop/add         0/mod/indirect  7/rm32/edi    .           .             .           .           .               4/imm32           # add to *edi
$write-int:end:
    # . restore registers
    5f/pop-to-edi
    59/pop-to-ecx
    58/pop-to-eax
    # . epilogue
    89/copy                         3/mod/direct    4/rm32/esp    .           .             .           5/r32/ebp   .               .                 # copy ebp to esp
    5d/pop-to-ebp
    c3/return

$write-int:abort:
    # . _write(2/stderr, error)
    # . . push args
    68/push  "write-int: out of space\n"/imm32
    68/push  2/imm32/stderr
    # . . call
    e8/call  _write/disp32
    # . . discard args
    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               8/imm32           # add to esp
    # . syscall(exit, 1)
    bb/copy-to-ebx  1/imm32
    b8/copy-to-eax  1/imm32/exit
    cd/syscall  0x80/imm8
    # never gets here

test-write-int-single:
    # - check that write-int writes to first int of 'stream'
    # setup
    # . clear-stream(_test-stream)
    # . . push args
    68/push  _test-stream/imm32
    # . . call
    e8/call  clear-stream/disp32
    # . . discard args
    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               4/imm32           # add to esp
    # write-int(_test-stream, "abcd")
    # . . push args
    68/push  0x64636261/imm32
    68/push  _test-stream/imm32
    # . . call
    e8/call  write-int/disp32
    # . . discard args
    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               8/imm32           # add to esp
    # check-stream-equal(_test-stream, "abcd", msg)
    # . . push args
    68/push  "F - test-write-int-single"/imm32
    68/push  "abcd"/imm32
    68/push  _test-stream/imm32
    # . . call
    e8/call  check-stream-equal/disp32
    # . . discard args
    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               0xc/imm32         # add to esp
    # . end
    c3/return

test-write-byte-buffered-multiple:
    # - check that write-int correctly appends multiple writes
    # setup
    # . clear-stream(_test-stream)
    # . . push args
    68/push  _test-stream/imm32
    # . . call
    e8/call  clear-stream/disp32
    # . . discard args
    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               4/imm32           # add to esp
    # write-int(_test-stream, "abcd")
    # . . push args
    68/push  0x64636261/imm32
    68/push  _test-stream/imm32
    # . . call
    e8/call  write-int/disp32
    # . . discard args
    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               8/imm32           # add to esp
    # write-int(_test-stream, "efgh")
    # . . push args
    68/push  0x68676665/imm32
    68/push  _test-stream/imm32
    # . . call
    e8/call  write-int/disp32
    # . . discard args
    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               8/imm32           # add to esp
    # check-stream-equal(_test-stream, "abcdefgh", msg)
    # . . push args
    68/push  "F - test-write-byte-buffered-multiple"/imm32
    68/push  "abcdefgh"/imm32
    68/push  _test-stream/imm32
    # . . call
    e8/call  check-stream-equal/disp32
    # . . discard args
    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               0xc/imm32         # add to esp
    # . end
    c3/return

# . . vim:nowrap:textwidth=0