/************************************************************************ * "Epsilon", "EEL" and "Lugaru" are trademarks of Lugaru Software, Ltd. * * * * Copyright (C) 1985, 1990 Lugaru Software Ltd. All rights reserved. * * * * Limited permission is hereby granted to reproduce and modify this * * copyrighted material provided that the resulting code is used only in * * conjunction with Lugaru products and that this notice is retained in * * any such reproduction or modification. * ************************************************************************* * File.......: CURSPOS.E * * Ver........: 1.00 * * Date.......: 1990-08-14 * * By.........: Jonas Hedberg * * Software Engineer * * TEAMSTER AB * * P.O. Box 8321 * * S-402 79 G™TEBORG * * SWEDEN * * Tel: +46-31-22 22 65 (GMT + 1h) * * Fax: +46-31-22 75 46 * * Description: Show's current row and column at right bottom of the * * screen, undepending if the screen is 25, 43 or 50 rows. * * The function check if the screen is in color * * or mono mode, and it's use the echo-line color. * * The function is controled by the variable: * * show-cursor-position. When it's "1" the current row * * and column appears on the screen, and if it's "0", * * nothing happends. The cursor-position-mode command can * * be used to toggle between showing and not. * * Algorithm..: Remember where you were last time, start from there and * * count your way forward or backword depending were you * * move to. * * Log........: * * Date | Sign | Description * * -----------+------+-------------------------------------------------- * * 1990-08-15 | JHg | Added the "bazurk" test. * * 1990-08-15 | JHg | Command cursor-position-mode. * * | | * ************************************************************************/ #include "eel.h" #include "lowlevel.h" char show_cursor_position = 1; buffer int _prev_point = 0; buffer int _prev_row = 1; command cursor_position_mode() { if (show_cursor_position == 0) { show_cursor_position = 1; } else { show_cursor_position = 0; } } do_show_cursor_position() { if (show_cursor_position == 1) { char cursor_position[25]; sprintf(cursor_position, " r%d c%d ", current_row(), current_column() + 1); /* Check if screen is mono or color */ if (screen_mode == 0 || screen_mode == 2 || screen_mode == 7) /* The screen is in monochrom mode */ term_write(screen_cols-15, screen_lines-1,cursor_position,15,mcolors[1],1); else /* Screen is in color mode */ term_write(screen_cols-15, screen_lines-1,cursor_position,15,colors[1],1); } } current_column() { int start, column; start=point; if (nl_reverse()) point++; column = horizontal(start); point = start; return column; } current_row() { /* If current row has gone bazurk, fix it */ if ((_prev_point > size()) || (_prev_row <= 0) || ((_prev_point == 0) && (_prev_row != 1))) { int row = 1, start = point; point = 0; while (nl_forward() && !user_abort && (point <= start)) { row++; } point = start; check_abort(); if (!row) row = row + 1; /* Remember where we are */ _prev_point = point; _prev_row = row; return row; } else { int row = _prev_row, start = point; point = _prev_point; /* The move has been forward seens last */ if (start > _prev_point) { while (nl_forward() && !user_abort && (point <= start)) { row++; } /* Whe have moved backward in the buffer */ } else if (start < _prev_point) { while (nl_reverse() && !user_abort && (point >= start)) { row--; } } point = start; check_abort(); if (!row) row = row + 1; /* Remember where we are */ _prev_point = point; _prev_row = row; return row; } } #define COMMAND_MAX 100 /* longest remembered cmd */ short command_keys[COMMAND_MAX]; /* remember all chars in cmd */ /* set key to next key, from macro or keyboard */ getkey() { /* This row is the only change in function getkey() */ do_show_cursor_position(); /* Print row and col */ if (ungot_key != -1) { /* check before calling */ wait_for_key(); return key; } else if (pushed_special_key != -1) { key = pushed_special_key; pushed_special_key = -1; } else { if (want_auto_save && !cmd_len && _auto_save_counter++ > auto_save_count) { _auto_save_counter = 0; auto_save_buffers(); } wait_for_key(); if ((key_type == 3 || key_type == 2) && !now_quoting) { pushed_special_key = key; key = CTRL('Q'); } } if (cmd_len < COMMAND_MAX) command_keys[cmd_len] = key; if (len_def_mac > 0) { def_text[len_def_mac++] = key; if (len_def_mac >= MAX_MACRO) { end_kbd_macro(); error( "Macro definition buffer full: keyboard macro defined"); } } return key; }