Skip to content

Commit

Permalink
TTY: modified line drawing.
Browse files Browse the repository at this point in the history
  • Loading branch information
aborodin committed Aug 12, 2009
1 parent 28580ca commit 30fd7fc
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 148 deletions.
5 changes: 3 additions & 2 deletions edit/editdraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,10 @@ print_to_widget (WEdit *edit, long row, int start_col, int start_col_real,
int y = row + EDIT_TEXT_VERTICAL_OFFSET;
int cols_to_skip = abs (x);
unsigned char str[6 + 1];

tty_setcolor (EDITOR_NORMAL_COLOR);
edit_move (x1, y);
hline (' ', end_col + 1 - EDIT_TEXT_HORIZONTAL_OFFSET - x1);
tty_draw_hline (edit->widget.y + y, edit->widget.x + x1,
' ', end_col + 1 - EDIT_TEXT_HORIZONTAL_OFFSET - x1);

if (option_line_state) {
int i;
Expand Down
4 changes: 4 additions & 0 deletions src/cons.handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
#include <unistd.h>

#include "global.h"

#include "../src/tty/tty.h"
#include "../src/tty/color.h" /* tty_set_normal_attrs */
#include "../src/tty/win.h"

#include "cons.saver.h"

signed char console_flag = 0;
Expand Down
11 changes: 4 additions & 7 deletions src/dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,10 @@ static void dlg_broadcast_msg_to (Dlg_head * h, widget_msg_t message,
static void
slow_box (Dlg_head *h, int y, int x, int ys, int xs)
{
tty_gotoyx (h->y + y, h->x + x);
hline (' ', xs);
vline (' ', ys);
tty_gotoyx (h->y + y, h->x + x + xs - 1);
vline (' ', ys);
tty_gotoyx (h->y + y + ys - 1, h->x + x);
hline (' ', xs);
tty_draw_hline (h->y + y, h->x + x, ' ', xs);
tty_draw_vline (h->y + y, h->x + x, ' ', ys);
tty_draw_vline (h->y + y, h->x + x + xs - 1, ' ', ys);
tty_draw_hline (h->y + y + ys - 1, h->x + x, ' ', xs);
}

/* draw box in window */
Expand Down
4 changes: 2 additions & 2 deletions src/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ info_show_info (struct WInfo *info)
widget_move (&info->widget, 1, 3);
tty_printf (_("Midnight Commander %s"), VERSION);
tty_setcolor (NORMAL_COLOR);
widget_move (&info->widget, 2, 1);
hline (ACS_HLINE|NORMAL_COLOR, info->widget.cols-2);
tty_draw_hline (info->widget.y + 2, info->widget.x + 1,
ACS_HLINE, info->widget.cols - 2);
if (get_current_type () != view_listing)
return;

Expand Down
14 changes: 7 additions & 7 deletions src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,19 @@ static void menubar_paint_idx (WMenu *menubar, int idx, int color)
tty_print_alt_char (ACS_LTEE);
}

tty_print_hline (menubar->widget.y + y, menubar->widget.x + x,
menubar->max_entry_len + 2);
tty_draw_hline (menubar->widget.y + y, menubar->widget.x + x,
slow_terminal ? ' ' : ACS_HLINE, menubar->max_entry_len + 2);

if (!slow_terminal)
if (!slow_terminal) {
widget_move (&menubar->widget, y, x + menubar->max_entry_len + 2);
tty_print_alt_char (ACS_RTEE);
}
} else {
/* menu text */
tty_setcolor (color);
widget_move (&menubar->widget, y, x);
tty_print_char ((unsigned char) entry->first_letter);
hline (' ', menubar->max_entry_len + 1); /* clear line */
tty_draw_hline (-1, -1, ' ', menubar->max_entry_len + 1); /* clear line */
tty_print_string (entry->text.start);

if (entry->text.hotkey != NULL) {
Expand Down Expand Up @@ -152,9 +154,7 @@ static void menubar_draw (WMenu *menubar)

/* First draw the complete menubar */
tty_setcolor (SELECTED_COLOR);
widget_move (&menubar->widget, 0, 0);

hline (' ', menubar->widget.cols);
tty_draw_hline (menubar->widget.y, menubar->widget.x, ' ', menubar->widget.cols);

tty_setcolor (SELECTED_COLOR);
/* Now each one of the entries */
Expand Down
27 changes: 11 additions & 16 deletions src/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#include "widget.h"
#include "menu.h" /* menubar_visible */
#include "main-widgets.h"
#include "main.h" /* the_menubar */
#include "main.h" /* the_menubar, slow_terminal */
#include "unixcompat.h"
#include "mountlist.h" /* my_statfs */
#include "selcodepage.h" /* select_charset () */
Expand Down Expand Up @@ -566,13 +566,13 @@ format_file (char *dest, int limit, WPanel *panel, int file_index, int width, in
tty_setcolor (SELECTED_COLOR);
else
tty_setcolor (NORMAL_COLOR);
tty_print_one_vline ();
tty_print_one_vline (slow_terminal);
length++;
}
}

if (length < width)
hline (' ', width - length);
tty_draw_hline (-1, -1, ' ', width - length);
}

static void
Expand Down Expand Up @@ -616,7 +616,7 @@ repaint_file (WPanel *panel, int file_index, int mv, int attr, int isstatus)
tty_print_char (' ');
else {
tty_setcolor (NORMAL_COLOR);
tty_print_one_vline ();
tty_print_one_vline (slow_terminal);
}
}
}
Expand Down Expand Up @@ -737,15 +737,10 @@ mini_info_separator (WPanel *panel)
const int y = llines (panel) + 2;

tty_set_normal_attrs (); /* FIXME: unneeded? */
widget_move (&panel->widget, y, 1);
tty_setcolor (NORMAL_COLOR);
#ifdef HAVE_SLANG
hline (ACS_HLINE, panel->widget.cols - 2);
#else
hline ((slow_terminal ? '-' : ACS_HLINE) | NORMAL_COLOR,
panel->widget.cols - 2);
#endif /* !HAVE_SLANG */

tty_draw_hline (panel->widget.y + y, panel->widget.x + 1,
slow_terminal ? '-' : ACS_HLINE,
panel->widget.cols - 2);
/* Status displays total marked size.
* Centered in panel, full format. */
display_total_marked_size (panel, y, -1, FALSE);
Expand Down Expand Up @@ -798,7 +793,7 @@ show_dir (WPanel *panel)
panel->widget.y, panel->widget.x,
panel->widget.lines, panel->widget.cols);

if (show_mini_info) {
if (show_mini_info && !slow_terminal) {
widget_move (&panel->widget, llines (panel) + 2, 0);
tty_print_alt_char (ACS_LTEE);
widget_move (&panel->widget, llines (panel) + 2,
Expand Down Expand Up @@ -1218,7 +1213,7 @@ paint_frame (WPanel *panel)

if (side){
tty_setcolor (NORMAL_COLOR);
tty_print_one_vline ();
tty_print_one_vline (slow_terminal);
width = panel->widget.cols - panel->widget.cols/2 - 1;
} else if (panel->split)
width = panel->widget.cols/2 - 3;
Expand All @@ -1243,14 +1238,14 @@ paint_frame (WPanel *panel)
width -= format->field_len;
} else {
tty_setcolor (NORMAL_COLOR);
tty_print_one_vline ();
tty_print_one_vline (slow_terminal);
width--;
continue;
}
}

if (width > 0)
tty_printf ("%*s", width, "");
tty_draw_hline (-1, -1, ' ', width);
}
}

Expand Down
18 changes: 8 additions & 10 deletions src/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ static void tree_show_mini_info (WTree *tree, int tree_lines, int tree_cols)
} else
line = tree_lines+1;

widget_move (&tree->widget, line, 1);
hline (' ', tree_cols);
tty_draw_hline (tree->widget.y + line, tree->widget.x + 1, ' ', tree_cols);
widget_move (&tree->widget, line, 1);

if (tree->searching){
Expand Down Expand Up @@ -258,10 +257,8 @@ static void show_tree (WTree *tree)
/* Loop for every line */
for (i = 0; i < tree_lines; i++){
/* Move to the beginning of the line */
widget_move (&tree->widget, y+i, x);

hline (' ', tree_cols);
widget_move (&tree->widget, y+i, x);
tty_draw_hline (tree->widget.y + y + i, tree->widget.x + x,
' ', tree_cols);

if (!current)
continue;
Expand Down Expand Up @@ -968,13 +965,14 @@ tree_frame (Dlg_head *h, WTree *tree)
{
tty_setcolor (NORMAL_COLOR);
widget_erase ((Widget*) tree);
if (tree->is_panel)
if (tree->is_panel) {
draw_double_box (h, tree->widget.y, tree->widget.x, tree->widget.lines,
tree->widget.cols);

if (show_mini_info && tree->is_panel){
widget_move (tree, tlines (tree) + 1, 1);
hline (ACS_HLINE, tree->widget.cols - 2);
if (show_mini_info)
tty_draw_hline (tree->widget.y + tlines (tree) + 1,
tree->widget.x + 1,
ACS_HLINE, tree->widget.cols - 2);
}
}

Expand Down
18 changes: 18 additions & 0 deletions src/tty/tty-ncurses.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,24 @@ tty_getyx (int *py, int *px)
getyx (stdscr, *py, *px);
}

/* if x < 0 or y < 0, draw line starting from current position */
void
tty_draw_hline (int y, int x, int ch, int len)
{
if ((y >= 0) && (x >= 0))
move (y, x);
hline (ch, len);
}

/* if x < 0 or y < 0, draw line starting from current position */
void
tty_draw_vline (int y, int x, int ch, int len)
{
if ((y >= 0) && (x >= 0))
move (y, x);
vline (ch, len);
}

void
tty_draw_box (int y, int x, int rows, int cols)
{
Expand Down
94 changes: 50 additions & 44 deletions src/tty/tty-slang.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "../../src/tty/win.h"

#include "../../src/background.h" /* we_are_background */
#include "../../src/main.h" /* for slow_terminal */
#include "../../src/util.h" /* str_unconst */
#include "../../src/strutil.h" /* str_term_form */

Expand Down Expand Up @@ -361,49 +360,6 @@ tty_baudrate (void)
return SLang_TT_Baud_Rate;
}

void
hline (int ch, int len)
{
int last_x, last_y;

last_x = SLsmg_get_column ();
last_y = SLsmg_get_row ();

if (ch == 0)
ch = ACS_HLINE;

if (ch == ACS_HLINE)
SLsmg_draw_hline (len);
else
while (len--)
tty_print_char (ch);

SLsmg_gotorc (last_y, last_x);
}

void
vline (int character, int len)
{
(void) character;

if (!slow_terminal)
SLsmg_draw_vline (len);
else {
int last_x, last_y, pos = 0;

last_x = SLsmg_get_column ();
last_y = SLsmg_get_row ();

while (len--) {
SLsmg_gotorc (last_y + pos, last_x);
tty_print_char (' ');
pos++;
}

SLsmg_gotorc (last_x, last_y);
}
}

int
getch (void)
{
Expand Down Expand Up @@ -450,6 +406,56 @@ tty_getyx (int *py, int *px)
*px = SLsmg_get_column ();
}

/* if x < 0 or y < 0, draw line staring from current position */
void
tty_draw_hline (int y, int x, int ch, int len)
{
if ((y < 0) || (x < 0)) {
y = SLsmg_get_row ();
x = SLsmg_get_column ();
} else
SLsmg_gotorc (y, x);

if (ch == 0)
ch = ACS_HLINE;

if (ch == ACS_HLINE)
SLsmg_draw_hline (len);
else
while (len-- != 0)
tty_print_char (ch);

SLsmg_gotorc (y, x);
}

/* if x < 0 or y < 0, draw line staring from current position */
void
tty_draw_vline (int y, int x, int ch, int len)
{
if ((y < 0) || (x < 0)) {
y = SLsmg_get_row ();
x = SLsmg_get_column ();
} else
SLsmg_gotorc (y, x);

if (ch == 0)
ch = ACS_VLINE;

if (ch == ACS_VLINE)
SLsmg_draw_vline (len);
else {
int pos = 0;

while (len-- != 0) {
SLsmg_gotorc (y + pos, x);
tty_print_char (ch);
pos++;
}
}

SLsmg_gotorc (y, x);
}

void
tty_draw_box (int y, int x, int rows, int cols)
{
Expand Down
2 changes: 0 additions & 2 deletions src/tty/tty-slang.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ enum {

void init_slang (void);
void init_curses (void);
void hline (int ch, int len);
void vline (int ch, int len);
int getch (void);

#define printw SLsmg_printf
Expand Down
Loading

0 comments on commit 30fd7fc

Please sign in to comment.