From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id E93EB3947C31 for ; Fri, 28 Jan 2022 15:55:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E93EB3947C31 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-224-NzOCgPY4OHm4pZNMEIImiw-1; Fri, 28 Jan 2022 10:55:26 -0500 X-MC-Unique: NzOCgPY4OHm4pZNMEIImiw-1 Received: by mail-wm1-f69.google.com with SMTP id o3-20020a1ca503000000b0035056b042deso3159972wme.0 for ; Fri, 28 Jan 2022 07:55:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5suiYqyCZsyjQxR1cZSM9PVPLS8F7q+Ifk5Mfx8nRNU=; b=SdHGntmyDTggQVxcWIqlpdKmRon99jNg6AZNdkfEIqmodJrWKiTJD4FsZNtOxicSW7 TV/cxRy17Xtsj6YsPGosSyuj1ICkVEkYJ8dHYk2WHqIOydLWBhtKDfNoKKybVYzsqst6 2iJjTYUU5W+1rodg/WPvhEaKUj4eL1eddaJoGS9OIQSxWlIuUvlRHvnalcAg/nXf9GDF 3Iy54pJkBdD+v/zR/GCvfWbRAsNdGFBDacRfnLf31bJvEHVyhDjK7jiWMWwdgE28/o9X KefmMHPBfL/SSG5kp3amepgahOQM9STlG+NDfAyULaDLfHr2u1ONXwrvGuWFr0spqSv6 CCpg== X-Gm-Message-State: AOAM533MgfT0yYDmF3AKdKNLpt7WUBA3vMmbkikeKSSkf5q+6U6Mmc1z ru/jWmP+aWl1Jdj4cdHKY3e/Sf5OdpWQLwJz8ObcbXEvX5QNfIg2pFM0S0Iqcp1QbnbM3Ago6fb TNWY7e2HPsGqa0YM8oI8wkYSa+LpHc0DWiBYy8ST+kueq5exX5MQwkS+onLGiBgtadfwkZPaYVg == X-Received: by 2002:a05:6000:1884:: with SMTP id a4mr7744084wri.632.1643385324552; Fri, 28 Jan 2022 07:55:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJyD+lP06np4IOtUHk9KxDBm7p20SFVnHSF0JR9c+6B/4VILh3MfNISPWsEZA0vzLekHprtK8w== X-Received: by 2002:a05:6000:1884:: with SMTP id a4mr7744054wri.632.1643385324040; Fri, 28 Jan 2022 07:55:24 -0800 (PST) Received: from localhost (host86-140-92-93.range86-140.btcentralplus.com. [86.140.92.93]) by smtp.gmail.com with ESMTPSA id a26sm2560523wmj.18.2022.01.28.07.55.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 07:55:23 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 6/7] gdb/testing/tui: add new functionality to tuiterm.exp Date: Fri, 28 Jan 2022 15:55:07 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jan 2022 15:55:35 -0000 While working on the next patch in this series, I was sending additional commands to the terminal with Term::command. There was nothing special about these commands, just normal "print EXPRESSION" type things, but I clearly poked ncurses in just the right way so that it started sending two previously unseen control sequences, 'Insert Line' and 'Delete Characters'. Now, the Term::command calls I added above were only done to help be debug the test, without them, these two control sequences are not triggered. But, given I've gone to the effort of adding these features to tuiterm.exp, I figure I might as well share this work. Additionally, I noticed a bug in 'Erase in Line' that this commit fixes; in mode 1 the erase should be from the start of the line through to the cursor, not to the character before the cursor. This bug would mean that random characters would sometimes be left in the terminal output. --- gdb/testsuite/lib/tuiterm.exp | 54 ++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index 38948015e96..f2be3394db0 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -317,13 +317,40 @@ namespace eval Term { # From cursor to end. _clear_in_line $_cur_col $_cols $_cur_row } elseif {$arg == 1} { - _clear_in_line 0 $_cur_col $_cur_row + _clear_in_line 0 [expr $_cur_col + 1] $_cur_row } elseif {$arg == 2} { _clear_in_line 0 $_cols $_cur_row } } } + # Insert Line + # + # https://vt100.net/docs/vt510-rm/IL.html + proc _csi_L {args} { + set arg [_default [lindex $args 0] 1] + + _log_cur "Insert Line ($arg)" { + variable _cur_col + variable _cur_row + variable _rows + variable _cols + variable _chars + + set y [expr $_rows - 2] + set next_y [expr $y + 1] + while {$y >= $_cur_row} { + for {set x 0} {$x < $_cols} {incr x} { + set _chars($x,$next_y) $_chars($x,$y) + } + incr y -1 + incr next_y -1 + } + + _clear_lines $_cur_row $_rows + } + } + # Delete line. # # https://vt100.net/docs/vt510-rm/DL.html @@ -349,6 +376,31 @@ namespace eval Term { } } + # Delete Characters + # + # https://vt100.net/docs/vt510-rm/DCH.html + proc _csi_P {args} { + set count [_default [lindex $args 0] 1] + + _log_cur "Delete Character ($count)" { + variable _cur_col + variable _cur_row + variable _cols + variable _chars + + set dx [expr $_cur_col + 1] + set sx [expr $_cur_col + 1 + $count] + set y $_cur_row + + while {$sx < $_cols} { + set _chars($dx,$y) $_chars($sx,$y) + incr sx + incr dx + } + _clear_in_line $dx $sx $y + } + } + # Erase chars. # # https://vt100.net/docs/vt510-rm/ECH.html -- 2.25.4