{"id":13755766,"url":"https://github.com/sintrb/c-terminal","last_synced_at":"2025-09-14T01:55:16.158Z","repository":{"id":25489793,"uuid":"28920813","full_name":"sintrb/c-terminal","owner":"sintrb","description":"一些标准终端命令的封装，用于单片机的调试输出和终端程序开发","archived":false,"fork":false,"pushed_at":"2015-01-08T06:48:47.000Z","size":332,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-10T02:41:03.337Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sintrb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-07T15:40:14.000Z","updated_at":"2020-10-14T07:34:21.000Z","dependencies_parsed_at":"2022-08-24T00:00:30.915Z","dependency_job_id":null,"html_url":"https://github.com/sintrb/c-terminal","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sintrb/c-terminal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sintrb%2Fc-terminal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sintrb%2Fc-terminal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sintrb%2Fc-terminal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sintrb%2Fc-terminal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sintrb","download_url":"https://codeload.github.com/sintrb/c-terminal/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sintrb%2Fc-terminal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275051634,"owners_count":25396977,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T11:00:28.604Z","updated_at":"2025-09-14T01:55:16.133Z","avatar_url":"https://github.com/sintrb.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# c-terminal\n一些终端命令（控制码）的C封装，用于单片机的调试输出和终端程序开发。\n\n已经对Windows上的超级终端测试过，同时也对CecureCRT上的终端测试过，对以下大部分终端命令（控制码）都支持：\n\n### 终端命令（控制码）说明\n```\n\\033[0m 关闭所有属性\n\\033[1m 设置高亮度\n\\033[4m 下划线\n\\033[5m 闪烁\n\\033[7m 反显\n\\033[8m 消隐\n\\033[fm 设置前景色为f，f取值见下文\n\\033[bm 设置背景色为b，b取值见下文\n\\033[b;fm 设置背景色为b，前景色为f\n\\033[nA 光标上移n行\n\\033[nB 光标下移n行\n\\033[nC 光标右移n行\n\\033[nD 光标左移n行\n\\033[r;cH 设置光标位置为r行c列\n\\033[2J 清屏\n\\033[K 清除从光标到行尾的内容\n\\033[s 保存光标位置(Linux终端不支持，貌似仅在ANSI终端有效)\n\\033[u 恢复光标位置(Linux中断不支持，貌似仅在ANSI终端有效)\n\\033[?25l 隐藏光标\n\\033[?25h 显示光标\n```\n\n### 颜色值说明\n#### 前景色（字体颜色）\n```\n30:黑\n31:红\n32:绿\n33:黄\n34:蓝色\n35:紫色\n36:深绿\n37:白色\n```\n#### 背景色说明：\n```\n40:黑\n41:深红\n42:绿\n43:黄色\n44:蓝色\n45:紫色\n46:深绿\n47:白色\n```\n\n下面是可以用于测试终端对这些命令支持清空的脚本（保存到文件里面执行）：\n```shell\necho -e \"\\033[2J\" # 清屏\necho -e \"\\033[1;1H\" # 光标移到左上角\necho -e \"\\033[0m\" # 关闭所有属性\necho -e \"\\033[1m高亮度\\033[0m\" # 设置高亮度\necho -e \"\\033[4m下划线\\033[0m\" # 下划线\necho -e \"\\033[5m闪烁\\033[0m\" # 闪烁\necho -e \"\\033[7m反显\\033[0m\" # 反显\necho -e \"\\033[8m消隐\\033[0m\" # 消隐\necho -e \"\\033[42;31m绿背景 红前景\\033[0m\" # 前景背景色设置\necho -e \"\\033[5B\" # 光标下移5行\necho -e \"\\033[3A\" # 光标上移3行\necho -e \"\\033[4C\" # 光标右移4行\necho -e \"\\033[2D\" # 光标左移2行\necho Hello\necho -e \"\\033[s\" # 保存光标位置\necho -e \"\\033[5B\"\necho Below 5 Rows\necho -e \"\\033[u\" # 恢复光标位置\necho World\necho -e \"\\033[10B\" # 下移10行\n```\n下面是在不同的中断下执行得到的结果截图：\n#### ANSI:\n\u003e ![image](https://raw.githubusercontent.com/sintrb/c-terminal/master/scr-shot/ansi.png)\n\n#### Linux:\n\u003e ![image](https://raw.githubusercontent.com/sintrb/c-terminal/master/scr-shot/linux.png)\n\n#### SCOANSI:\n\u003e ![image](https://raw.githubusercontent.com/sintrb/c-terminal/master/scr-shot/scoansi.png)\n\n通过以上截图大致能够看出来，ANSI终端对上述控制命令的支持程度最高，但需要提的是ANSI终端没法支持Linux的某些程序，比如nano（或者是本人设置上的问题。。）。\n\n\n\n=\n\n## 怎么获取这些代码？\n\n* 如果你只是想简单的使用这些代码的话你可以把它当作一个压缩包下载到你的电脑上，点击右边的“Download ZIP”:\n\n![image](https://raw.githubusercontent.com/sintrb/forgithub/master/img/screenshots/githubdownloadzip.png)\n\n\n* 如果你喜欢这些代码，那么你可以加星：\n\n![image](https://raw.githubusercontent.com/sintrb/forgithub/master/img/screenshots/githubstart.png)\n\n* 如果你觉得这些代码还有很多可以改善的地方，那么请先fork一下（欢迎fork）：\n\n![image](https://raw.githubusercontent.com/sintrb/forgithub/master/img/screenshots/githubfork.png)\n\n* fork之后这些代码就变成了你的了，你可以从自己的仓库中把它们clone到你的电脑上，之后的操作就和git一样了：\n\n![image](https://raw.githubusercontent.com/sintrb/forgithub/master/img/screenshots/githubsshclone.png)\n\n**享受开源带来的乐趣吧**\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsintrb%2Fc-terminal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsintrb%2Fc-terminal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsintrb%2Fc-terminal/lists"}