{"id":21224077,"url":"https://github.com/kodie/ansiescapes","last_synced_at":"2025-07-10T14:31:16.105Z","repository":{"id":54765328,"uuid":"105313605","full_name":"kodie/ansiescapes","owner":"kodie","description":"ANSI escape codes for manipulating the terminal - A Python port of sindresorhus's ansi-escapes Node.js module","archived":false,"fork":false,"pushed_at":"2020-10-14T15:22:14.000Z","size":6,"stargazers_count":22,"open_issues_count":5,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-07T12:05:55.844Z","etag":null,"topics":["ansi","cli","code","command-line","console","control","cursor","escape","formatting","iterm","iterm2","log","sequence","shell","string","terminal","text","tty","vt100","xterm"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kodie.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-29T20:20:17.000Z","updated_at":"2024-09-26T08:34:59.000Z","dependencies_parsed_at":"2022-08-14T02:10:28.896Z","dependency_job_id":null,"html_url":"https://github.com/kodie/ansiescapes","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodie%2Fansiescapes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodie%2Fansiescapes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodie%2Fansiescapes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodie%2Fansiescapes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kodie","download_url":"https://codeload.github.com/kodie/ansiescapes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225640771,"owners_count":17501018,"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","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":["ansi","cli","code","command-line","console","control","cursor","escape","formatting","iterm","iterm2","log","sequence","shell","string","terminal","text","tty","vt100","xterm"],"created_at":"2024-11-20T22:54:56.791Z","updated_at":"2024-11-20T22:54:57.373Z","avatar_url":"https://github.com/kodie.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"***********\nansiescapes\n***********\n\n`ANSI escape codes \u003chttp://www.termsys.demon.co.uk/vtansi.htm\u003e`_ for manipulating the terminal - A Python port of `sindresorhus \u003chttps://github.com/sindresorhus\u003e`_'s `ansi-escapes \u003chttps://github.com/sindresorhus/ansi-escapes\u003e`_ Node.js module.\n\nInstallation\n============\n.. code-block:: bash\n\n  $ pip install ansiescapes\n\nUsage\n=====\n.. code-block:: python\n\n  import ansiescapes\n  import sys\n\n  # Moves the cursor two rows up and to the left\n  sys.stdout.write(ansiescapes.cursorUp(2) + ansiescapes.cursorLeft)\n  #=\u003e '\\u001B[2A\\u001B[1000D'\n\nAPI\n===\n\ncursorTo(x, [y])\n----------------\nSet the absolute position of the cursor. `x0` `y0` is the top left of the screen.\n\ncursorMove(x, [y])\n------------------\nSet the position of the cursor relative to its current position.\n\ncursorUp(count)\n---------------\nMove cursor up a specific amount of rows. Default is `1`.\n\ncursorDown(count)\n-----------------\nMove cursor down a specific amount of rows. Default is `1`.\n\ncursorForward(count)\n--------------------\nMove cursor forward a specific amount of rows. Default is `1`.\n\ncursorBackward(count)\n---------------------\nMove cursor backward a specific amount of rows. Default is `1`.\n\ncursorLeft\n----------\nMove cursor to the left side.\n\ncursorSavePosition\n------------------\nSave cursor position.\n\ncursorRestorePosition\n---------------------\nRestore saved cursor position.\n\ncursorGetPosition\n-----------------\nGet cursor position.\n\ncursorNextLine\n--------------\nMove cursor to the next line.\n\ncursorPrevLine\n--------------\nMove cursor to the previous line.\n\ncursorHide\n----------\nHide cursor.\n\ncursorShow\n----------\nShow cursor.\n\neraseLines(count)\n-----------------\nErase from the current cursor position up the specified amount of rows.\n\neraseEndLine\n------------\nErase from the current cursor position to the end of the current line.\n\neraseStartLine\n--------------\nErase from the current cursor position to the start of the current line.\n\neraseLine\n---------\nErase the entire current line.\n\neraseDown\n---------\nErase the screen from the current line down to the bottom of the screen.\n\neraseUp\n-------\nErase the screen from the current line up to the top of the screen.\n\neraseScreen\n-----------\nErase the screen and move the cursor the top left position.\n\nscrollUp\n--------\nScroll display up one line.\n\nscrollDown\n----------\nScroll display down one line.\n\nclearScreen\n-----------\nClear the terminal screen.\n\nbeep\n----\nOutput a beeping sound.\n\nimage(input, [options])\n-----------------------\nDisplay an image.\n\n*Currently only supported on iTerm2 \u003e=3*\n\nSee `termimg \u003chttps://github.com/kodie/termimg\u003e`_ for a higher-level module.\n\ninput\n~~~~~\n\nType: `Buffer`\n\nBuffer of an image. Usually read in with `open`.\n\nExample:\n\n.. code-block:: python\n\n  import ansiescapes\n  import sys\n  from codecs import open\n\n  with open('image.png', 'rb') as imageFile:\n    f = imageFile.read()\n    b = bytearray(f)\n\n  sys.stdout.write(ansiescapes.image(b))\n\noptions\n~~~~~~~\n\nwidth\n_____\nheight\n______\n\nType: `string` `number`\n\nThe width and height are given as a number followed by a unit, or the word \"auto\".\n\n- `N`: N character cells.\n- `Npx`: N pixels.\n- `N%`: N percent of the session's width or height.\n- `auto`: The image's inherent size will be used to determine an appropriate dimension.\n\npreserveAspectRatio\n___________________\n\nType: `boolean`\n\nDefault: `true`\n\nsetCwd([path])\n--------------\n\nType: `string`\n\nDefault: `os.getcwd()`\n\n`Inform iTerm2 \u003chttps://www.iterm2.com/documentation-escape-codes.html\u003e`_ of the current directory to help semantic history and enable `Cmd-clicking relative paths \u003chttps://coderwall.com/p/b7e82q/quickly-open-files-in-iterm-with-cmd-click\u003e`_.\n\nLicense\n=======\nMIT. See the `LICENSE file \u003cLICENSE.md\u003e`_ for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkodie%2Fansiescapes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkodie%2Fansiescapes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkodie%2Fansiescapes/lists"}