Terminal interaction system, method and device of VSCode and electronic equipment
The data flow is captured and split in the VSCode terminal through the event driver, and asynchronous processing is implemented, which solves the input blocking problem caused by output exclusiveness, improves the system's data processing capability and interactivity, and provides efficient log backtracking function.
Patent Information
- Application Number
- CN202411024794.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-29
- Publication Date
- 2024-11-29
AI Technical Summary
In the case of intensive tasks or large amounts of output, the output exclusive problem of traditional VSCode terminals causes users to be unable to perform input and other operations, resulting in input blockage and affecting the system's data processing capabilities.
The event driver is used to capture the data flow at the process side, split it into an input stream and an output stream, and send the input stream to the process side through an asynchronous processing mechanism, allowing the user to continue to input new commands while outputting data generation, and at the same time the output stream is transferred. Send to the user output for visual display and output to the log file if the preset conditions are met.
It avoids input blocking problems, improves the system's data processing capabilities, enhances users' understanding and analysis of output results, and improves the interactivity and ease of use of the terminal, providing efficient log backtracking function.
Smart Images

Figure CN119045800A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and in particular, relates to a terminal interaction system, method, device and electronic device of VSCode. Background Art
[0002] The implementation principle of VSCode's terminal is to integrate the command line interface into the editor and use the internal communication mechanism to realize the interaction between the editor and the terminal. This integration and interaction enables developers to efficiently complete various development tasks in a unified interface.
[0003] However, this implementation method that relies on the system terminal for input and output has obvious defects. In terms of user interaction, when the output occupies the terminal exclusively, the user cannot input or perform other operations. In the scenario of running simulation systems or intensive tasks, this method must interrupt the current task if you want to operate again. Summary of the invention
[0004] The present application aims to solve at least one of the technical problems existing in the prior art. To this end, the present application proposes a terminal interaction system, method, device and electronic device of VSCode, so that users can use the terminal functions normally even in intensive tasks or large-scale output, thereby improving the data processing capability of the system.
[0005] In a first aspect, the present application provides a terminal interaction system of VSCode, including a terminal and an event driver;
[0006] The terminal includes a process terminal;
[0007] The event driver is used to capture the data stream of the process end, split the data stream into an input stream of the process end and an output stream of the process end, and send the input stream to the process end;
[0008] The process end is used to receive the input stream and execute operations corresponding to the input stream to generate output data.
[0009] According to the terminal interaction system of VSCode of the present application, the data stream of the process end is captured through an event driver; the data stream is split into an input stream of the process end and an output stream of the process end; the input stream is sent to the process end so that the process end performs the operation corresponding to the input stream to generate output data. The embodiment of the present application captures the data stream of the process end and splits the data stream into an input stream and an output stream, adopts an asynchronous processing mechanism, allows user input and process output to be processed in parallel, so that the user can continue to input new commands while the output data is generated, avoiding the input blocking problem caused by output exclusivity in traditional terminals, and users can use terminal functions normally even in intensive tasks or large outputs, thereby improving the data processing capabilities of the system.
[0010] According to one embodiment of the present application, the terminal further includes a user input terminal;
[0011] The input stream is obtained by the user input terminal receiving input data from the user.
[0012] In this embodiment, the user input terminal can receive data directly input by the user, and the data is then converted into an input stream, so that the user can interact with the terminal in real time. The input data captured by the user input terminal is processed by the event driver and accurately transmitted to the process end, thereby triggering corresponding operations and command execution.
[0013] According to one embodiment of the present application, the terminal further includes a user output terminal;
[0014] The event driver is further used to send the output stream to the user output terminal;
[0015] The user output terminal is used to visually display the output stream.
[0016] In this embodiment, the output data obtained by splitting the data stream is sent to the user output terminal through an event driver. After receiving these data, the user output terminal can convert the output data into a format that the user can intuitively understand, such as text, images or other multimedia forms, so as to perform visual display, which not only enhances the user's understanding and analysis capabilities of the output results, but also improves the interactivity and ease of use of the terminal.
[0017] According to one embodiment of the present application, the event driver is further used for:
[0018] When the output stream meets the first preset condition, the output stream is output to a log file.
[0019] In this embodiment, when the output stream meets the first preset condition, the output stream contents are automatically output to the log file to back up the output stream. This eliminates the need to manually search for relevant information in the terminal output, helps record the program's running status and historical information, provides valuable data support for subsequent analysis and debugging, and improves the terminal's interaction efficiency.
[0020] According to one embodiment of the present application, the system further includes a trigger;
[0021] The trigger is used to form the log file into an output stream and send it to a user output terminal when a second preset condition is met.
[0022] In this embodiment, by meeting the second preset condition, the log file will be read into an output stream and displayed through the user output terminal. The user can quickly locate the time point when the problem occurred and the related operations, thereby performing effective fault diagnosis and problem solving, and realizing an efficient log backtracking function.
[0023] In a second aspect, the present application provides a terminal interaction method of VSCode, wherein the terminal includes a process end, and the method includes:
[0024] Capturing data streams at the process end;
[0025] Splitting the data stream into an input stream of the process end and an output stream of the process end;
[0026] The input stream is sent to the process end so that the process end performs an operation corresponding to the input stream to generate output data.
[0027] According to the terminal interaction method of VSCode of the present application, by capturing the data stream of the process end; splitting the data stream into the input stream of the process end and the output stream of the process end; sending the input stream to the process end, so that the process end performs the operation corresponding to the input stream to generate output data. The embodiment of the present application captures the data stream of the process end and splits the data stream into an input stream and an output stream, adopts an asynchronous processing mechanism, allows user input and process output to be processed in parallel, so that the user can continue to input new commands while the output data is generated, avoiding the input blocking problem caused by output exclusivity in traditional terminals, and users can use terminal functions normally even in intensive tasks or large outputs, thereby improving the data processing capabilities of the system.
[0028] According to one embodiment of the present application, the method further includes:
[0029] The output stream is sent to a user output terminal of the terminal so that the user output terminal can visually display the output stream.
[0030] In this embodiment, the output data obtained by splitting the data stream is sent to the user output terminal. After receiving the data, the user output terminal can convert the output data into a format that the user can intuitively understand, such as text, images or other multimedia forms, so as to perform visual display, which not only enhances the user's understanding and analysis capabilities of the output results, but also improves the interactivity and ease of use of the terminal.
[0031] According to one embodiment of the present application, the method further includes:
[0032] When the output stream meets the first preset condition, the output stream is output to a log file.
[0033] In this embodiment, when the output stream meets the first preset condition, the output stream contents are automatically output to the log file to back up the output stream. This eliminates the need to manually search for relevant information in the terminal output, helps record the program's running status and historical information, provides valuable data support for subsequent analysis and debugging, and improves the terminal's interaction efficiency.
[0034] In a third aspect, the present application provides a terminal interaction device for VSCode, wherein the terminal includes a process end, and the device includes:
[0035] A capture module, used for capturing the data stream of the process end;
[0036] A splitting module, used for splitting the data stream into an input stream of the process end and an output stream of the process end;
[0037] The sending module is used to send the input stream to the process end so that the process end performs the operation corresponding to the input stream to generate output data.
[0038] According to the terminal interaction device of VSCode of the present application, by capturing the data stream of the process end; splitting the data stream into the input stream of the process end and the output stream of the process end; sending the input stream to the process end, so that the process end performs the operation corresponding to the input stream to generate output data. The embodiment of the present application captures the data stream of the process end and splits the data stream into input stream and output stream, adopts an asynchronous processing mechanism, allows user input and process output to be processed in parallel, so that the user can continue to input new commands while the output data is generated, avoiding the input blocking problem caused by output monopoly in traditional terminals, and users can use terminal functions normally even in intensive tasks or large-scale output, thereby improving the data processing capability of the system.
[0039] In a fourth aspect, the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the terminal interaction method of VSCode as described in the second aspect above is implemented.
[0040] In a fifth aspect, the present application provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the terminal interaction method of VSCode as described in the second aspect above.
[0041] In a sixth aspect, the present application provides a chip, comprising a processor and a communication interface, the communication interface being coupled to the processor, and the processor being used to run a program or instruction to implement the terminal interaction method of VSCode as described in the second aspect above.
[0042] In a seventh aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the terminal interaction method of VSCode as described in the second aspect above.
[0043] The above one or more technical solutions in the embodiments of the present application have at least one of the following technical effects:
[0044] According to the terminal interaction system of VSCode of the present application, the data stream of the process end is captured through an event driver; the data stream is split into an input stream of the process end and an output stream of the process end; the input stream is sent to the process end so that the process end performs the operation corresponding to the input stream to generate output data. The embodiment of the present application captures the data stream of the process end and splits the data stream into an input stream and an output stream, adopts an asynchronous processing mechanism, allows user input and process output to be processed in parallel, so that the user can continue to input new commands while the output data is generated, avoiding the input blocking problem caused by output exclusivity in traditional terminals, and users can use terminal functions normally even in intensive tasks or large outputs, thereby improving the data processing capabilities of the system.
[0045] Furthermore, in some embodiments, the user input terminal can receive data directly input by the user, and the data is then converted into an input stream, so that the user can interact with the terminal in real time. The input data captured by the user input terminal is processed by the event driver and accurately transmitted to the process end, thereby triggering the corresponding operations and command execution.
[0046] Furthermore, in some embodiments, the output data obtained by splitting the data stream is sent to the user output terminal through an event driver. After receiving these data, the user output terminal can convert the output data into a format that the user can intuitively understand, such as text, images or other multimedia forms, so as to perform visual display, which not only enhances the user's understanding and analysis capabilities of the output results, but also improves the interactivity and ease of use of the terminal.
[0047] Furthermore, in some embodiments, when the output stream meets the first preset condition, the output stream contents are automatically output to a log file to back up the output stream. This eliminates the need to manually search for relevant information in the terminal output, helps record the program's running status and historical information, provides valuable data support for subsequent analysis and debugging, and improves the terminal's interaction efficiency.
[0048] Furthermore, in some embodiments, by meeting the second preset condition, the log file will be read into an output stream and displayed through the user output terminal. The user can quickly locate the time point when the problem occurred and the related operations, thereby performing effective fault diagnosis and problem solving, and realizing an efficient log backtracking function.
[0049] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0051] Figure 1 It is a schematic diagram of data flow of a pseudo terminal in the related technology;
[0052] Figure 2 It is a schematic diagram of the architecture of the terminal interaction system of VSCode provided in an embodiment of the present application;
[0053] Figure 3 is a schematic diagram of a user input interface provided in an embodiment of the present application;
[0054] Figure 4 It is a flowchart of the terminal interaction method of VSCode provided in an embodiment of the present application;
[0055] Figure 5 It is a structural diagram of a terminal interaction device of VSCode provided in an embodiment of the present application;
[0056] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0057] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0058] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0059] The terminal implementation principle of VSCode is mainly based on the deep coupling of the integrated development environment (IDE) and the system terminal. As a powerful code editor, VSCode provides a wealth of functions and plug-ins, among which the terminal is one of the important components. The terminal implementation of VSCode mainly relies on the following key parts:
[0060] Integrated terminal: VSCode's terminal is built-in, which means it is directly integrated into the editor's interface without opening additional command line tools. This integration allows developers to perform various command line tasks without leaving the editing environment, such as compiling code, running programs, installing dependencies, etc. This mainly relies on Xterm.js, a front-end terminal component written in TypeScript that can implement a command line terminal application directly in the browser. Xterm.js is suitable for most terminal applications such as bash, vim, and tmux, including support for curses-based applications and mouse events. Xterm.js has the characteristics of fast response and also includes a GPU-accelerated renderer.
[0061] Shell support: VSCode's terminal supports multiple shell environments, such as bash, zsh, PowerShell, etc. When a user opens a terminal in VSCode, it uses the default shell configured by the system. This means that users can use their familiar shell commands and scripts directly in the VSCode terminal.
[0062] Communication mechanism: The terminal and editor of VSCode interact through an internal communication mechanism. When the user enters commands in the terminal, these commands are sent to the corresponding shell environment for execution. At the same time, the output of the terminal is captured in real time and displayed in the VSCode interface. This communication mechanism ensures seamless integration between the terminal and the editor. In terms of communication mechanism, it is mainly implemented through pty.node, which provides an interface to create and associate a pseudo-terminal (PTY), which is a technology that interacts with the underlying operating system, allowing applications to run in a virtual terminal without directly communicating with the standard input / output streams.
[0063] like Figure 1 As shown, the data flow of PTY is simulated through a duplex channel. This implementation creates two terminals between the user and the process, the user side and the process side, respectively, and simulates through the channel, that is, the slave and master are synchronized in both directions, the process side synchronizes the flow to the user side, and the user side synchronizes the flow to the process side. The advantage is that what you see is what you get. Because it is simulated synchronization, all event button prompts are consistent and do not need to be implemented additionally. The disadvantage is that when the output of the process side occupies the terminal exclusively, the output of the user side will also be exclusive, resulting in the user being unable to use the terminal function normally.
[0064] In general, the terminal implementation principle of VSCode is to integrate the command line interface into the editor and use the internal communication mechanism to realize the interaction between the editor and the terminal. This integration and interaction enables developers to efficiently complete various development tasks in a unified interface, but this implementation method that relies on the system terminal for input and output has obvious defects; in terms of user interaction, when the output occupies the terminal exclusively, the user cannot input or perform other operations. This method is not suitable for scenarios where simulation systems or intensive tasks are running. If you want to operate again, you must interrupt the current task. In the current mainstream integrated development systems, they all interact with the system by directly integrating the system terminal, and they usually inherit this defect.
[0065] The present application considers that if an event driver can be integrated, the data stream on the process side can be captured through the event driver; the data stream can be split into an input stream on the process side and an output stream on the process side; the input stream can be sent to the process side so that the process side can perform operations corresponding to the input stream to generate output data. This is expected to solve the problem in the prior art that when the output monopolizes the terminal, the user cannot input or perform other operations.
[0066] In the following, in conjunction with the accompanying drawings, the terminal interaction system, method, device and electronic device of VSCode provided in the embodiments of the present application are described in detail through specific embodiments and their application scenarios.
[0067] like Figure 2 As shown, the terminal interaction system 200 of VSCode includes: a terminal and an event driver 201, and the terminal includes a process end 202.
[0068] The event driver 201 is used to capture the data stream of the process end 202, split the data stream into an input stream of the process end 202 and an output stream of the process end 202, and send the input stream to the process end 202;
[0069] The process end 202 is used to receive an input stream and execute operations corresponding to the input stream to generate output data.
[0070] In an embodiment of the present application, the terminal can be a command line interface integrated in the VSCode editor, which allows developers to run command line tools and scripts directly inside the editor. The terminal simulates a standard Unix / Linux or Windows command line environment, providing a convenient interface to execute various commands and operations without leaving VSCode.
[0071] The terminal may include a process end 202, which may be a process running on the back end of the terminal, and is a component that actually executes commands input by the user. The process end 202 may be responsible for starting and maintaining one or more shell instances, processing commands input by the user, and returning execution results and generating output data. The process end 202 is tightly integrated with the editor environment of VSCode, allowing access to files and directories in the editor when executing commands.
[0072] In the embodiment of the present application, the data stream of the process end 202 is a sequence of data transmitted between the process end and other components or systems. The data stream of the process end 202 may include data sent to the process end 202 by other systems or components, that is, the input stream of the process end 202. The input stream may come from commands entered by the user through the keyboard or instructions automatically sent by a script. For example, when a user types a command in a terminal and presses the Enter key, these commands are sent to the process end 202 as an input stream. The input stream may also include data sent to the process end 202 from a redirected file, a pipe, or other processes.
[0073] The data stream of the process end 202 may also include data sent by the process end to other systems or components, that is, the output stream of the process end 202. The output stream may include the results of the execution of the input command, error messages, program output, etc. For example, after the process end 202 executes the command input by the user, the process end 202 will send the output data back to the terminal interface through the output stream for the user to view. The data of the output stream may be text, binary data, or other formats, depending on the executed commands and programs.
[0074] In an embodiment of the present application, the event driver 201 can be a software component based on an event-driven architecture, and the event driver 201 can control the execution process of the program based on the generation and response of events. In the terminal interaction system 200 of VSCode, the event driver 201 can monitor, capture, split, distribute and synchronize the data stream of the process end 202.
[0075] Specifically, the event driver 201 captures the data stream of the process end by monitoring the data output and input of the process end 202. For example, the event driver 201 can monitor the standard input (stdin), standard output (stdout) and standard error output (stderr) of the process end 202 to capture the data stream. After capturing the data stream, it can be split into an input stream and an output stream according to the type of the data stream. For example, the input stream usually refers to the data sent by the user to the process end through the terminal interface, and the output stream is the data sent back to the terminal interface by the process end. The event driver 201 can correctly route the data to the input stream or the output stream according to the source and purpose of the data. Of course, the event driver 201 can also parse the data stream, identify the type of data, such as command output, error information, etc., and split it into an input stream and an output stream according to the type of the data stream.
[0076] The event driver 201 can use non-blocking I / O operations to support high concurrency and asynchronous data processing. By splitting the data stream of the process end 202 into an input stream and an output stream, and processing the input stream and the output stream separately, through this asynchronous processing mechanism, user input and process output are allowed to be processed in parallel, even in the case of high output load, user input can be responded to in a timely manner, thereby improving efficiency.
[0077] According to the terminal interaction system of VSCode of the present application, the data stream of the process end is captured through the event driver; the data stream is split into the input stream of the process end and the output stream of the process end; the input stream is sent to the process end so that the process end performs the operation corresponding to the input stream to generate output data. The embodiment of the present application captures the data stream of the process end and splits the data stream into input stream and output stream, adopts an asynchronous processing mechanism, allows user input and process output to be processed in parallel, so that the user can continue to enter new commands while the output data is generated, avoiding the input blocking problem caused by output exclusivity in traditional terminals, and users can use the terminal function normally even in intensive tasks or large-scale output, thereby improving the data processing capability of the system.
[0078] In some embodiments, the terminal further includes a user input terminal 203;
[0079] The input stream is obtained by receiving the user's input data from the user input terminal.
[0080] In this embodiment, the user input terminal 203 may be a part of the terminal, and may interact with the user and receive the user's input. Figure 3 As shown, the user input end can be a user interface of any device such as a mobile phone, tablet computer, laptop computer, PDA, etc. The user can input commands or data to the user input end 203 through a keyboard, mouse or other input device. The commands or data input by the user will form an input stream of the process end 202, which will be captured by the event driver 201.
[0081] In this embodiment, the user input terminal can receive data directly input by the user, and the data is then converted into an input stream, so that the user can interact with the terminal in real time. The input data captured by the user input terminal is processed by the event driver and accurately transmitted to the process end, thereby triggering corresponding operations and command execution.
[0082] In some embodiments, the terminal further includes a user output 204;
[0083] The event driver 201 is also used to send the output stream to the user output terminal 204;
[0084] The user output terminal 203 is used to visually display the output stream.
[0085] In this embodiment, the user output terminal 204 may be a part of the terminal, responsible for displaying the output stream of the process terminal to the user in a visual manner. The user output terminal 204 may be a display interface, and the display mode of the output stream may be text, graphics or other multimedia forms, depending on the type of the output stream and the needs of the user.
[0086] For example, a user enters a command in the terminal, such as entering git status to view the status of the Git repository. The event driver 201 captures the input stream and sends the input stream to the process end 202. The process end 202 executes the command and generates an output stream, including the change status of the current Git repository, branch information, etc. The event driver 201 captures the output stream and sends the output stream to the user output end through a network socket, a pipe or other IPC mechanism. The user output end 204 receives the output stream and converts it into text form and displays it in the terminal window. The user can view the result of the command execution in the terminal window and perform the next operation according to the displayed information.
[0087] In this embodiment, the output data obtained by splitting the data stream is sent to the user output terminal through an event driver. After receiving these data, the user output terminal can convert the output data into a format that the user can intuitively understand, such as text, images or other multimedia forms, so as to perform visual display, which not only enhances the user's understanding and analysis capabilities of the output results, but also improves the interactivity and ease of use of the terminal.
[0088] In some embodiments, the event driver 201 is further configured to:
[0089] When the output stream meets the first preset condition, the output stream is output to the log file.
[0090] In this embodiment, the first preset condition is a rule or standard used by the event driver 201 to decide whether to record the output stream to the log file. The first preset condition can be determined based on the content, level, size, frequency and other attributes of the output stream.
[0091] In this embodiment, the first preset condition may be that the output stream contains error information. If there is an error log or information above the error level in the output stream, the event driver 201 may record it in a log file. The first preset condition may also be that the output stream contains specific keywords or commands, such as the output of key operations such as database backup and system restart. The first preset condition may also be that the size of the output stream exceeds a certain threshold, indicating that a large amount of data may be generated, and the event driver 201 will record these data in a log file. Of course, the first preset condition may also be other conditions, and those skilled in the art may set them according to actual needs, and the embodiments of the present application are not limited to this.
[0092] In this embodiment, when the output stream meets the first preset condition, the output stream contents are automatically output to the log file to back up the output stream. This eliminates the need to manually search for relevant information in the terminal output, helps record the program's running status and historical information, provides valuable data support for subsequent analysis and debugging, and improves the terminal's interaction efficiency.
[0093] In some embodiments, the system further includes a trigger 205;
[0094] The trigger 205 is used to form the log file into an output stream and send it to the user output terminal when the second preset condition is met.
[0095] In this embodiment, trigger 205 is a component in the system, which is used to monitor the log file and activate the corresponding action according to the specific event or condition. When certain content or pattern in the log file matches the second preset condition, or when the user actively triggers it, trigger 205 will execute the defined action, such as sending a notification or generating a new output stream.
[0096] In this embodiment, the second preset condition may be a specific error code in the log file, such as HTTP status code 500, indicating an internal server error. The second preset condition may also be an abnormal pattern in the log file, such as multiple consecutive identical warnings or errors, or a system warning, such as insufficient resources or configuration errors, contained in the log file. Of course, the second preset condition may also be other conditions, which may be set by those skilled in the art according to actual needs, and the embodiments of the present application do not limit this.
[0097] In this embodiment, by meeting the second preset condition, the log file will be read into an output stream and displayed through the user output terminal. The user can quickly locate the time point when the problem occurred and the related operations, thereby performing effective fault diagnosis and problem solving, and realizing an efficient log backtracking function.
[0098] The embodiment of the present application also provides a terminal interaction method of VSCode. The execution subject of the terminal interaction method of VSCode can be an electronic device or a functional module or functional entity in the electronic device that can implement the terminal interaction method of VSCode, such as the above-mentioned event driver. The electronic devices mentioned in the embodiment of the present application include but are not limited to mobile phones, tablet computers, computers, cameras and wearable devices, etc. The terminal interaction method of VSCode provided in the embodiment of the present application is explained below by taking the electronic device as the execution subject as an example.
[0099] like Figure 4 As shown, the terminal interaction method of VSCode includes: step 410, step 420 and step 430.
[0100] Step 410: Capture the data stream of the process end;
[0101] Step 420: split the data stream into an input stream of the process end and an output stream of the process end;
[0102] Step 430: Send the input stream to the process end so that the process end performs operations corresponding to the input stream to generate output data.
[0103] In an embodiment of the present application, the terminal may include a process end, which may be a process running on the back end of the terminal, and the process end is a component that actually executes user input commands. The process end may be responsible for starting and maintaining one or more shell instances, processing user input commands, and returning execution results to generate output data. Among them, the process end is tightly integrated with the editor environment of VSCode, allowing access to files and directories in the editor when executing commands.
[0104] The data stream of the process end can also include data sent by the process end to other systems or components, that is, the output stream of the process end. The output stream can include the results of command execution based on the input, error messages, program output, etc. For example, when the process end executes the command entered by the user, the process end will send the output data back to the terminal interface through the output stream for the user to view. The data of the output stream can be text, binary data, or other formats, depending on the executed commands and programs.
[0105] In an embodiment of the present application, the data stream of the process end can be captured by monitoring the data output and input of the process end. For example, the standard input (stdin), standard output (stdout) and standard error output (stderr) of the process end can be monitored to capture the data stream. After capturing the data stream, it can be split into an input stream and an output stream according to the type of the data stream. For example, the input stream generally refers to the data sent by the user to the process end through the terminal interface, and the output stream is the data sent back to the terminal interface by the process end. According to the source and purpose of the data, the data can be correctly routed to the input stream or the output stream. Of course, the data stream can also be parsed to identify the type of data, such as command output, error information, etc., and split into an input stream and an output stream according to the type of the data stream.
[0106] In some embodiments, non-blocking I / O operations can be used to support high concurrency and asynchronous data processing. By splitting the data stream on the process side into input stream and output stream, and processing the input stream and output stream separately, this asynchronous processing mechanism allows user input and process output to be processed in parallel, so that user input can be responded to in a timely manner even in the case of high output load, thereby improving efficiency.
[0107] According to the terminal interaction method of VSCode of the present application, by capturing the data stream of the process end; splitting the data stream into the input stream of the process end and the output stream of the process end; sending the input stream to the process end, so that the process end performs the operation corresponding to the input stream to generate output data. The embodiment of the present application captures the data stream of the process end and splits the data stream into input stream and output stream, adopts an asynchronous processing mechanism, allows user input and process output to be processed in parallel, so that the user can continue to input new commands while the output data is generated, avoiding the input blocking problem caused by output exclusivity in traditional terminals, and users can use terminal functions normally even in intensive tasks or large-scale output, thereby improving the data processing capability of the system.
[0108] In some embodiments, the method further comprises:
[0109] The output stream is sent to the user output terminal of the terminal so that the user output terminal can visually display the output stream.
[0110] In this embodiment, the user output terminal may be a part of the terminal, which is responsible for displaying the output stream of the process terminal to the user in a visual manner. The user output terminal may be a display interface, and the display mode of the output stream may be text, graphics or other multimedia forms, depending on the type of the output stream and the needs of the user.
[0111] For example, when a user enters a command in the terminal, such as git status to view the status of a Git repository, the input stream can be captured and sent to the process end, which executes the command and generates an output stream, including the change status of the current Git repository, branch information, etc. The output stream can be captured and sent to the user output end through a network socket, pipe, or other IPC mechanism. The user output end receives the output stream and converts it into text format, which is displayed in the terminal window. The user can view the results of the command execution in the terminal window and perform the next operation based on the displayed information.
[0112] In this embodiment, the output data obtained by splitting the data stream is sent to the user output terminal. After receiving the data, the user output terminal can convert the output data into a format that the user can intuitively understand, such as text, images or other multimedia forms, so as to perform visual display, which not only enhances the user's understanding and analysis capabilities of the output results, but also improves the interactivity and ease of use of the terminal.
[0113] In some embodiments, the method further comprises:
[0114] When the output stream meets the first preset condition, the output stream is output to the log file.
[0115] In this embodiment, the first preset condition is a rule or standard used by the event driver to decide whether to record the output stream to the log file. The first preset condition can be determined based on the content, level, size, frequency and other attributes of the output stream.
[0116] In this embodiment, the first preset condition can be that the output stream contains error information, and if there is an error log or information above the error level in the output stream, it can be recorded in a log file. The first preset condition can also be that the output stream contains specific keywords or commands, such as the output of key operations such as database backup and system restart. The first preset condition can also be that the size of the output stream exceeds a certain threshold, indicating that a large amount of data may be generated, and these data can be recorded in a log file. Of course, the first preset condition can also be other conditions, and those skilled in the art can set it according to actual needs, and the embodiments of the present application are not limited to this.
[0117] In this embodiment, when the output stream meets the first preset condition, the output stream contents are automatically output to the log file to back up the output stream. This eliminates the need to manually search for relevant information in the terminal output, helps record the program's running status and historical information, provides valuable data support for subsequent analysis and debugging, and improves the terminal's interaction efficiency.
[0118] The terminal interaction method of VSCode provided in the embodiment of the present application can be executed by a terminal interaction device of VSCode. In the embodiment of the present application, the terminal interaction device of VSCode is used as an example to illustrate the terminal interaction method of VSCode provided in the embodiment of the present application.
[0119] The embodiment of the present application also provides a terminal interaction device of VSCode.
[0120] like Figure 5 As shown, the terminal interaction device of VSCode includes:
[0121] Capture module 510, used to capture data stream of process end;
[0122] A splitting module 520, used for splitting the data stream into an input stream of the process end and an output stream of the process end;
[0123] The sending module 530 is used to send the input stream to the process end so that the process end performs the operation corresponding to the input stream to generate output data.
[0124] According to the terminal interaction device of VSCode of the present application, by capturing the data stream of the process end; splitting the data stream into the input stream of the process end and the output stream of the process end; sending the input stream to the process end, so that the process end performs the operation corresponding to the input stream to generate output data. The embodiment of the present application captures the data stream of the process end and splits the data stream into input stream and output stream, adopts an asynchronous processing mechanism, allows user input and process output to be processed in parallel, so that the user can continue to input new commands while the output data is generated, avoiding the input blocking problem caused by output monopoly in traditional terminals, and users can use the terminal function normally even in intensive tasks or large-scale output, thereby improving the data processing capability of the system.
[0125] In some embodiments, the sending module 530 is further configured to:
[0126] The output stream is sent to the user output terminal of the terminal so that the user output terminal can visually display the output stream.
[0127] In some embodiments, the sending module 530 is further configured to:
[0128] When the output stream meets the first preset condition, the output stream is output to the log file.
[0129] The terminal interaction device of VSCode in the embodiment of the present application can be an electronic device, or a component in an electronic device, such as an integrated circuit or a chip. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present application is not specifically limited.
[0130] The terminal interaction device of VSCode in the embodiment of the present application may be a device having an operating system. The operating system may be a Microsoft (Windows) operating system, an Android (Android) operating system, an IOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0131] In some embodiments, Figure 6 As shown, the embodiment of the present application also provides an electronic device 600, including a processor 601, a memory 602, and a computer program stored in the memory 602 and executable on the processor 601. When the program is executed by the processor 601, each process of the terminal interaction method embodiment of the above-mentioned VSCode is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0132] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.
[0133] The embodiment of the present application also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the terminal interaction method embodiment of the above-mentioned VSCode are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0134] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0135] An embodiment of the present application also provides a computer program product, including a computer program, which implements the above-mentioned VSCode terminal interaction method when executed by a processor.
[0136] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0137] The embodiment of the present application further provides a chip, which includes a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned terminal interaction method embodiment based on VSCode, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0138] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0139] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0140] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0141] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
[0142] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0143] Although the embodiments of the present application have been shown and described, those skilled in the art will appreciate that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present application, and that the scope of the present application is defined by the claims and their equivalents.
Claims
1. A terminal interaction system for VSCode, characterized in that: Includes terminal and event drivers; The terminal includes a process terminal; The event driver is used to capture the data stream of the process end, split the data stream into an input stream of the process end and an output stream of the process end, and send the input stream to the process end; The process end is used to receive the input stream and execute operations corresponding to the input stream to generate output data.
2. The system according to claim 1, characterized in that The terminal also includes a user input terminal; The input stream is obtained by the user input terminal receiving input data from the user.
3. The system according to claim 1, characterized in that The terminal also includes a user output terminal; The event driver is further used to send the output stream to the user output terminal; The user output terminal is used to visually display the output stream.
4. The system according to claim 1, characterized in that The event driver is also used to: When the output stream meets the first preset condition, the output stream is output to a log file.
5. The system according to claim 4, characterized in that The system also includes a trigger; The trigger is used to form the log file into an output stream and send it to a user output terminal when a second preset condition is met.
6. A terminal interaction method of VSCode, characterized in that: The terminal includes a process end, and the method includes: Capturing data streams at the process end; Splitting the data stream into an input stream of the process end and an output stream of the process end; The input stream is sent to the process end so that the process end performs an operation corresponding to the input stream to generate output data.
7. The method according to claim 6, characterized in that The method further comprises: The output stream is sent to a user output terminal of the terminal so that the user output terminal can visually display the output stream.
8. The method according to claim 6, characterized in that The method further comprises: When the output stream meets the first preset condition, the output stream is output to a log file.
9. A terminal interaction device for VSCode, characterized in that: The terminal includes a process end, and the device includes: A capture module, used for capturing the data stream of the process end; A splitting module, used for splitting the data stream into an input stream of the process end and an output stream of the process end; The sending module is used to send the input stream to the process end so that the process end performs the operation corresponding to the input stream to generate output data.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 6 to 8 is implemented.
