设置或更改光标的垂直位置 [英] Set or change vertical position of the cursor

查看:109
本文介绍了设置或更改光标的垂直位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,这是可以使用退格序列将光标移动到左侧的中的回声的。但是,是否有可能改变光标的垂直位置,使用的回声的?

As far as I know, it is possible to move the cursor to the left using the backspace sequence in an echo. But is there any possibility to change the vertical position of the cursor, using an echo?

推荐答案

本节介绍ANSI转义序列:

This section describes the ANSI escape sequences:

例如:

echo -en "\033[s\033[7B\033[1;34m 7 lines down violet \033[u\033[0m"
echo -en "\033[s\033[7A\033[1;32m 7 lines up green \033[u\033[0m"

和本节介绍tput的实用工具:

And this section describes the tput utility:

有关演示,看到的浮动时钟在终端的:

从<一个采取一个示例脚本href=\"http://www.cyberciti.biz/tips/spice-up-your-unix-linux-shell-scripts.html\">http://www.cyberciti.biz/tips/spice-up-your-unix-linux-shell-scripts.html:

#!/bin/bash

tput clear      # clear the screen

tput cup 3 15   # Move cursor to screen location X,Y (top left is 0,0)

tput setaf 3    # Set a foreground colour using ANSI escape
echo "XYX Corp LTD."
tput sgr0

tput cup 5 17
tput rev        # Set reverse video mode
echo "M A I N - M E N U"
tput sgr0

tput cup 7 15; echo "1. User Management"
tput cup 8 15; echo "2. Service Management"
tput cup 9 15; echo "3. Process Management"
tput cup 10 15; echo "4. Backup"

tput bold       # Set bold mode 
tput cup 12 15
read -p "Enter your choice [1-4] " choice

tput clear
tput sgr0
tput rc

这篇关于设置或更改光标的垂直位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆