From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by sourceware.org (Postfix) with ESMTPS id 3150C3858D37 for ; Thu, 3 Feb 2022 10:02:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3150C3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-il1-x136.google.com with SMTP id i1so1679455ils.5 for ; Thu, 03 Feb 2022 02:02:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=4Dj2owPNSxd0s8Bow5WurNX0peBs5U3HjmuoWt7yO2g=; b=YkXrOmhv5Rwt3tGOD+tW/3MivhyzBMA7EB1SJ5bmkLg/IP15H4oy/zxK7KYIQyBugr lOL51GZDuoT9TyRj/UTiz5ks3brf2EeAlPTUqUd9CPZ3tO4jdyHKYkzGJWl/shIkN0V6 j6buZX3paSgHl3MWxivEDr1ANH3RpvI/Yfhzz0HXvQU9fcNjnPGD7xHEvrojDWlhGg/m wTYAfbk91vE0ZCxNJ3r1v2uxmKo6xUUkzYyiv05rxzw8R85WJt4dURfnNhfEnq71zzPT P23GQji02OyFOUlOdlX2tx40G8xVASF12cnmph6qH2LxEyiqBx1cAgoYfhB5sdJT+7Bh SiXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=4Dj2owPNSxd0s8Bow5WurNX0peBs5U3HjmuoWt7yO2g=; b=Ffch0HCYZ5aVYdPSkFkExdoPmCNgTt6VeqmMVjTOO4yH1cGv57F2z3H4J7J5t2O6rK roQDfTQCiaLHB4+DSkEI/jQI9KKsGjjHbkXqmoXwly7KiZACx+MDxRMeHc4KA0ML7Rxu Zx4w90PpMEryAuXr5uoiSatpE3S520H0c6TKG3cfU7BQDFEODxH2sZb1TkqVmJeJsRJi 0RTkyeYOMuXfdaCidL6MeNJqg/Tq9yOR1+YiS3QrAle2VkvslwtkTGyPrCaFswlZufUq gEUwP4E5ZbX0PskJndLz+FoGhthtWtP6hg3pOoRsWZU+BXblj7QCJ0xji12v0vrJpTNx 5G+A== X-Gm-Message-State: AOAM5325Ghy8CAiMINSyRta0uBF6YyZBAUBj3Pu8I+1R+lYrMiELOXzP q70/tFnLTiwVcpbRnSDArcbFnSOdB6n+JEh+wwG0LRbf+mA= X-Google-Smtp-Source: ABdhPJxJPzTbwk9U7asHTbPSq4dd/1ulroXirWckJ+5TtgKC1mnlk8vwi75sNXPeRxG39Juf0lKvDntAZj+FstOJ4+M= X-Received: by 2002:a05:6e02:10c2:: with SMTP id s2mr19865115ilj.3.1643882571137; Thu, 03 Feb 2022 02:02:51 -0800 (PST) MIME-Version: 1.0 From: Koichi Murase Date: Thu, 3 Feb 2022 19:02:14 +0900 Message-ID: Subject: In Cygwin console (not Mintty), escape sequences DL/IL at the last line misbehave To: cygwin@cygwin.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Feb 2022 10:02:53 -0000 I'm not sure what this exactly is related to, but I guess pcon is closely related. Cygwin version: I can reproduce it in Cygwin 3.2.0 and the latest 3.3.4 for both 64-bit and 32-bit versions. I usually set CYGWIN=disable_pcon, but this reproduces for both cases with and without disable_pcon. I think I observed this behavior even earlier but don't exactly remember in which Cygwin version I first noticed this broken behavior. At least, this behavior has existed for a very long time. I have been thinking that there are a few people using the Cygwin console directly, but I recently noticed that it matters when I connect to Cygwin from Windows Terminal. This puts very hard limitations on implementing a line editor where the line editor does not know the absolute vertical position in the terminal screen so cannot predict the consequences of using DL/IL. Repeat-by: 1. First open a Cygwin console (not to be confused with Mintty) by double-clicking bash.exe in C:\cygwin64\bin or by executing "cygstart bash". 2a. run the following command at the last line of the terminal: $ printf '\e[5M' 2b. run the following command at the last line of the terminal $ printf '\e[5L' The control sequence \e[M (CSI M) is the ANSI escape sequence DL (DELETE LINE), which is supposed to delete the current line and the following -1 lines and scrolls up the subsequence lines. This control function functions correctly when it is not at the last line in the Cygwin console. However, if the current cursor position is located at the last line, DL() of the Cygwin console wrongly scrolls up the entire screen by lines (instead of the subsequent lines after the delete lines). Likely, \e[L is the ANSI escape sequence IL (INSERT LINE), which is supposed to insert new lines at the current line and to scroll down the subsequent lines. However, when the cursor is at the last line, IL of the Cygwin console again scrolls down the entire screen. This behavior is also reproduced in Windows Terminal with a profile of Cygwin executing bash.exe --login -i. This doesn't happen when we use Mintty or other terminal emulators relying on the genuine Cygwin PTY. Fix: Any other terminals do not behave in this unintuitive way. When the cursor is located at the last line, DL/IL should not scroll any lines but should just clear only the last line. -- Koichi