CN112764734A - Code editing assisting method and device and electronic equipment - Google Patents

Code editing assisting method and device and electronic equipment Download PDF

Info

Publication number
CN112764734A
CN112764734A CN202110106653.8A CN202110106653A CN112764734A CN 112764734 A CN112764734 A CN 112764734A CN 202110106653 A CN202110106653 A CN 202110106653A CN 112764734 A CN112764734 A CN 112764734A
Authority
CN
China
Prior art keywords
code
character string
input
user
character
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110106653.8A
Other languages
Chinese (zh)
Other versions
CN112764734B (en
Inventor
金碧辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Vivo Mobile Communication Co Ltd
Original Assignee
Vivo Mobile Communication Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Vivo Mobile Communication Co Ltd filed Critical Vivo Mobile Communication Co Ltd
Priority to CN202110106653.8A priority Critical patent/CN112764734B/en
Publication of CN112764734A publication Critical patent/CN112764734A/en
Application granted granted Critical
Publication of CN112764734B publication Critical patent/CN112764734B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/33Intelligent editors
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/34Graphical or visual programming
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The application discloses a code editing assisting method and device and electronic equipment, and belongs to the technical field of communication. The problem that the operation of editing the code is not convenient enough is solved. The method comprises the following steps: under the condition that a code text input by a user on an input method interface is received, detecting whether the code text comprises preset characters or not, wherein the code text comprises at least one code statement; executing target operation on the at least one code statement under the condition that the code text comprises preset characters; wherein the target operation is at least one of: automatic indentation, automatic line feed, and target character deletion.

Description

Code editing assisting method and device and electronic equipment
Technical Field
The application belongs to the technical field of communication, and particularly relates to a code editing assisting method and device and electronic equipment.
Background
With the advent of programming education, more and more users write code using electronic devices (e.g., cell phones, tablet computers, etc.).
If a user needs to perform technical communication with other users in a technical communication forum or social software, generally, one way is that the user writes a code on an electronic device, and needs to check the correctness of the code by himself or herself, manually adjust the readability of the code, and write the code with low efficiency. Another way is that a professional programming software is required to be installed, and a user writes codes in the professional programming software and then copies the codes to a technical communication forum or social software, so that the operation steps are complicated. Thus, the operation of editing the code is not convenient enough.
Disclosure of Invention
The embodiment of the application aims to provide an auxiliary method for code editing, which can solve the problem that the operation of editing codes is not convenient enough.
In order to solve the technical problem, the present application is implemented as follows:
in a first aspect, an embodiment of the present application provides a method for assisting code editing, where the method includes: under the condition that a user inputs a first code text based on an input method interface, detecting whether the first code text comprises preset characters or not, wherein the first code text comprises at least one code sentence; executing target operation on the at least one code statement under the condition that the first code text comprises preset characters; wherein the target operation is at least one of: automatic indentation, automatic line feed, and target character deletion.
In a second aspect, an embodiment of the present application provides an auxiliary device for code editing, including: a detection module and an execution module; the detection module is used for detecting whether a first code text is included in the first code text or not under the condition that the first code text is input by a user based on an input method interface, wherein the first code text includes at least one code sentence; the execution module is used for executing target operation on the at least one code statement under the condition that the detection module detects that the first code text comprises preset characters; wherein the target operation is any one of: automatic indentation, automatic line feed, and target character deletion.
In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instructions stored on the memory and executable on the processor, and when executed by the processor, the program or instructions implement the steps of the method according to the first aspect.
In a fourth aspect, embodiments of the present application provide a readable storage medium, on which a program or instructions are stored, which when executed by a processor implement the steps of the method according to the first aspect.
In a fifth aspect, an embodiment of the present application provides a chip, where the chip includes a processor and a communication interface, where the communication interface is coupled to the processor, and the processor is configured to execute a program or instructions to implement the method according to the first aspect.
In the embodiment of the application, under the condition that a first code text input by a user based on an input method interface is received, the electronic equipment detects whether the first code text comprises preset characters or not, wherein the first code text comprises at least one code sentence; the electronic device may perform a target operation on the at least one code sentence in a case where it is detected that the preset character is included in the first code text. Wherein the target operation is at least one of: automatic indentation, automatic line feed, and target character deletion. That is to say, under the condition that a user inputs a code text on an input method interface, if the code text including at least one code sentence input by the user includes preset characters, the electronic device can automatically retract the code sentence, automatically feed back the code sentence and delete redundant characters, manual retraction and manual feeding of the code sentence and manual deletion of redundant characters are not needed to be manually adjusted by the user, a code block can be quickly aligned, the operation of editing the code can be more convenient, the operation steps of editing the code by the user using the electronic device are simplified, and the efficiency of editing the code by the user is improved.
Drawings
Fig. 1 is a schematic flowchart of an auxiliary method for code editing according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a display interface provided in an embodiment of the present application;
fig. 3 is a second schematic view of a display interface provided in the embodiment of the present application;
fig. 4 is a third schematic view of a display interface provided in the embodiment of the present application;
FIG. 5 is a fourth schematic view of a display interface provided in the present embodiment;
FIG. 6 is a fifth schematic view of a display interface provided in the present embodiment;
fig. 7 is a schematic structural diagram of an auxiliary device for code editing according to an embodiment of the present disclosure;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure;
fig. 9 is a hardware schematic diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terms first, second and the like in the description and in the claims of the present application are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that embodiments of the application may be practiced in sequences other than those illustrated or described herein, and that the terms "first," "second," and the like are generally used herein in a generic sense and do not limit the number of terms, e.g., the first term can be one or more than one. In addition, "and/or" in the specification and claims means at least one of connected objects, a character "/" generally means that a preceding and succeeding related objects are in an "or" relationship.
The following describes in detail the auxiliary method for code editing provided by the embodiments of the present application through specific embodiments and application scenarios thereof with reference to the accompanying drawings.
Fig. 1 is a flowchart illustrating an auxiliary method for code editing according to an embodiment of the present application. As shown in fig. 1, the method comprises the following steps 101 and 102:
step 101, when receiving a first code text input by a user based on an input method interface, the electronic device detects whether the first code text comprises preset characters.
Wherein the first code text comprises at least one code sentence. The first code text is any code text input by a user.
Illustratively, one code text is:
a first code statement; a second code statement; a third code statement;
for example, a user may select a code editing mode at an input method interface and then enter code text based on the input method interface.
It should be noted that, a user may trigger the electronic device to switch to the code editing mode in any interface that can call an input method.
Specifically, the user may edit the code in the code display area based on the input method interface.
Alternatively, after the user inputs the first code text in the code display area, the electronic device may detect whether the first code text input by the user in the code display area includes a preset character.
Illustratively, the preset characters may include: statement start symbol, statement end symbol, code start symbol, and code block end symbol.
For example, a statement terminator is "; ", a code block start symbol is" { ", and a code block end symbol is" } ".
Optionally, the electronic device may receive a first input of the user when receiving that the user inputs the first code text based on the input method interface, and then execute the step 101 in response to the first input, where the first input may be a preset gesture input or a selection input of the user on the control in the input method interface.
Fig. 2 is a schematic view of an input method interface provided in an embodiment of the present application, as shown in fig. 2 (a), the input method interface displays a "code editing" control 21, and a user can trigger the electronic device to switch to a code editing mode by clicking the "code editing" control 21. After switching to the code editing mode, as shown in fig. 2 (b), the electronic device displays an "exit" control 21a, a "language" control 21b, a "style" control 21c, and a "finish" control 21d on the input method interface. The user can click on the programming language selected by the "language" control 21b, as shown in fig. 3 (a), the electronic device can display the language options such as JAVA, Python, C/C + +, etc. for the user to select. Clicking the "style" control 21c by the user can select a code style, as shown in fig. 3 (b), in which the user can select a default code style or can select a manual setting code style.
The code style is a style edited by the user when editing the code, and the code style may be a normal code style or a code style set by the user according to the encoding habit of the user.
By way of example, conventional code styles may include: hump naming styles and serpentine naming styles.
And 102, under the condition that the first code text comprises preset characters, the electronic equipment executes target operation on the at least one code statement.
Wherein the target operation is at least one of: automatic indentation, automatic line feed, and target character deletion.
Illustratively, the target character may include: line feed character, space character.
Specifically, the electronic device may perform recognition through regular matching, and when recognizing that a plurality of sentences are included in the same row, may automatically terminate the character "in each row of sentences; inserting line-feed character, and indenting next line head to make the same code block line head indenting and aligning. The electronic device identifies a start character "{" of the code block through regular matching, deletes a line break between the previous sentence and the start character "{" and retains only 1 space character so that "{" is located at the end of the line. The electronic equipment is enabled to occupy one line independently through the end character "}" of the regular matching code block and keeps consistent with the code block indentation to which the electronic equipment belongs (the code block to which the start/end character "{ }" of the code block belongs is the code block described by the start character "{" previous statement). The electronic equipment identifies the code block and the beginning of the code sentence through regular matching, and enables each line of the sentence of the same code block to be indented and aligned.
For example, the electronic device detects that a sentence terminator is included after each code sentence of the same line of code text, the electronic device may insert a line break after the terminator of each code sentence, so that adjacent code sentences may be automatically lined; and the line head of the next code statement is indented, so that the line heads of a plurality of code statements of the same code block can be automatically aligned.
Fig. 4 is a schematic interface diagram provided in an embodiment of the present application. As shown in fig. 4 (a), in the area 20a, the code text "testarray.add (1); ad (3); "shown in the first row," testarray.add (5); "is shown in the second row. If the electronic device receives a first input, for example, clicking a "style matching" control in the interface (i.e., the first input), the electronic device is in the code statement "testarray.add (1); "enter line break after" so that the code statement "testarray. "displayed in code statement" testarray. "next line to line and indented code statement" testarray.add (3); "line head of line, so that the code statement" testarray. And code statement testarray.add (1); "is the same, and after the processing, as shown in fig. 4 (b), in the area 20b, the code sentence" testarray.add (1) is displayed in the first line; "the code statement" testarray. ", the code statement" testarray.add (5) is shown in the third row; ", and the indentation of the 3-line code statement is the same.
According to the auxiliary method for editing the code, under the condition that the code text input by a user on an input method interface is received, the electronic equipment can detect whether the code text comprises preset characters or not, and the code text comprises at least one code statement; the electronic device may perform a target operation on the at least one code statement upon detecting that a preset character is included in the code text. Wherein the target operation is at least one of: automatic indentation, automatic line feed, and target character deletion. That is to say, under the condition that a user inputs a code text on an input method interface, if the code text including at least one code sentence input by the user includes preset characters, the electronic device can automatically retract the code sentence, automatically feed back the code sentence and delete redundant characters, manual retraction and manual feeding of the code sentence and manual deletion of redundant characters are not needed to be manually adjusted by the user, a code block can be quickly aligned, the operation of editing the code can be more convenient, the operation steps of editing the code by the user using the electronic device are simplified, and the efficiency of editing the code by the user is improved.
Optionally, the method for assisting code editing provided in this embodiment of the present application may further include the following step 103:
step 103, if the first code text comprises the first target character string, the electronic equipment displays the first target character string in a target color.
Wherein the first target character string is any one of the following: built-in keywords, function names, variable names and character strings with misspellings.
Specifically, the electronic device can recognize whether the character string in the code is a built-in keyword, function name, variable name, and misspelled character string by regular matching.
Illustratively, the color of the built-in keyword is orange; the function name is yellow in color; the string with misspellings is red in color, and the other strings are gray in color.
Exemplarily, if the character string is recognized as the built-in keyword, the electronic device displays the character string in an orange font; if the character string is identified as the function name, the electronic equipment displays the character string in a yellow font; if the character string is recognized as a misspelled character string, the electronic device displays the character string in a red font.
It should be noted that, at the position of grammar error, the font is filled with red, after the user corrects the grammar, the electronic device restores the font color, and the electronic device can automatically code the font color according to the above color filling manner (i.e. red is only reserved for use when grammar error occurs).
Specifically, the electronic device displays a first target character string in a target color in a code display area.
Based on the scheme, in the case that the user edits the code text based on the input method, the electronic device may display the first target character string in a target color in the case that it is determined that the first target character string is included in the first code text, and may make readability of the code by the user when editing the code text based on the input method stronger.
Optionally, the method for assisting code editing provided in the embodiment of the present application may further include the following step 104:
and 104, if the first character string input by the user meets a preset condition, displaying the recommended output character at the input method recommended position by the electronic equipment.
Wherein the first character string is a character string input in the process of inputting the first code text.
It will be appreciated that the first string may be the string most recently entered by the user in the code display area.
Specifically, the electronic device may identify a keyword of a sentence where the first character string is located through regular matching, and determine whether the currently input character string is a constant name, a function name, a variable name, or the like.
Illustratively, the electronic device may make keyword recommendations in conjunction with the grammar. For example, if the user inputs p at the head of a row, the electronic device may recommend a public word at the recommended position of the input method, and input s and recommend static after the public word. The electronic device may recommend a frequently used out word based on the first few letters entered when the user defines the variable name (i.e., enters the variable name). For example, if the user inputs an id, the electronic device may recommend words at the recommended position in turn as: id, idx, index; if the user inputs time, the electronic device may recommend the word time, at the recommended location. The electronic device may make recommendations based on the context code when the user uses the variable. As before the code behavior int number ═ 0; when the next line enters the number, the electronic device may display the recommended word number at the recommended position.
For example, if the first character string is a function name, the recommended output character may be a character string that appears in conjunction with the first character string, for example, if the user inputs public, the recommended output character may be class, static, or the like, and if the user selects static, the recommended character may continue to be displayed as int, void, or the like.
Based on the scheme, the electronic equipment can determine the recommended output character according to the character string input by the user, and if the recommended output character is the character which needs to be manually input by the user, the user can directly select the output character at the recommended position, so that the efficiency of inputting the code by the user is higher.
Optionally, in the method for assisting code editing provided in this embodiment of the present application, the step 104 may be specifically executed by the following step 104 a:
and 104a, if the first character string input by the user meets a preset condition, displaying the recommended output character at the input method recommended position by the electronic equipment based on the code style.
Note that the input code text of different code styles has different forms.
Illustratively, common code styles include the following naming styles:
(1) each string is capitalized and underlined to separate the strings.
For example: ALL _ UPPER.
(2) The first string is lower case, the second string is first initial upper case, and there is no delimiter.
For example: lowerCamelCase.
(3) The first character string is capital in and the other string is lowercase, underlined.
For example: first _ upper.
(4) Each string is capitalized on the first letter without separators.
For example: UpperCamelCase.
(5) The letters of each string are lower case and the underlines separate the strings.
For example: all _ lower.
The electronic device may first determine a recommended output character based on the naming style of the different code text, and then display the output character determined based on the code style and the first character string at the recommended location of the input method.
Based on the scheme, the electronic equipment can determine the recommended output character according to the character string input by the user and the style of the code to be coded selected by the user, so that the recommended output character can accord with the code style selected by the user, and the recommended output character is closer to the requirement of the user.
Optionally, in the method for assisting code editing provided in the embodiment of the present application, the step 104 may be specifically executed by the following step 104a1 or step 104a 2:
and 104a1, if the first character input by the user is the second target character string and the code style is the first code style, displaying the second character string in the first spelling format at the input method recommended position when the second character string is input by the receiving user in the input method interface.
Wherein the second target character string is any one of the following: built-in keywords, function names and variable names.
Alternatively, the second character string may be a keyword in a sentence in which the input is made, or the second character string may be a character string input at a display position adjacent to the first character string.
Optionally, the first spelling format may be any one of: the capital letters of the second character string, all the capital letters of the second character string, and all the lowercase letters of the second character string.
Specifically, the electronic device may first determine the naming style and then determine the case of the recommended input method output character.
For example, the electronic device may identify the keyword (i.e., the first character string) of the sentence in which the current input (the second character string) is located by regular matching according to the programming language selected by the user and the set naming style, so as to determine whether the current input (the second character string) is a definition of a constant name, and then determine the first spelling format of the second character string.
It should be noted that, if the programming language selected by the user is Java, C, or C + +, the naming style of the function/variable may be: hump type naming and snake type naming; function and variable names are named by hump by default, and constants are named by snakes. If the programming language selected by the user is PYTHON, the naming style of functions and variables is by default serpentine naming.
For example, when the user selects the default style, if the programming language selected by the user is JAVA/C + + and the current input is a defined constant name, or the programming language selected by the user is PYTHON, it may be determined that the code style is a snake-shaped name, and when the electronic device outputs an english character by the input method, the electronic device first recommends an uppercase character of the english character as the preferred character. If the programming language is JAVA/C/C + + and the current input is not the definition of a constant name, the code style is judged to be hump-type naming, and the output characters can not be recommended in the scene.
It should be noted that, various languages generally have default recommended naming styles, and a user can also self-define and set a naming style. For example, the user may set the variable name and function name to use the lowerCamelCase style, the constant to use the ALL _ UPPER style, and the class name to use the UpperCamelCase style.
Example 1:
supposing that a user wants to input a variable name testName, firstly, the user inputs a character string Test, and the input method word output recommendation is Test, Test and Test in sequence; when the user selects test to output words, the electronic equipment can determine that the user currently needs the lowerCamelCase code style, and after the user inputs the Name, the input method recommends that the words are the Name and the Name.
Based on the scheme, the electronic equipment can presume the code style which the user wants to use according to the character string selected by the user and the selection of the first 1 or more words of the user when inputting the character string, and recommends the words in the first spelling format preferentially according to the code style, and the recommended output characters are closer to the requirements of the user.
And 104a2, if the first character string input by the user is the third target character string and the code style is the second code style, displaying a preset separator at the input method recommended position after the first character string is input by the user.
Wherein the third target character string is any one of the following: function name, variable name.
The electronic device may recommend the separator to the user according to the code style, and the code style is different and the separator is different.
Alternatively, the character strings may be divided between them by additional characters, such as "_", or may be divided by capitalization of the first letter of an adjacent word.
Specifically, the electronic device may first determine the naming style of the currently input function/variable, and may determine whether the current input is a first character of a word (non-first word) constituting the function/variable using dictionary matching. If the first character of the word (non-first word) constituting the function/variable is named in a serpentine shape, after the user has input one character string, the next word can be recommended as a separator "_"; and when the code style is hump naming, automatically recommending the capital character of the character as a preferred character when the user inputs the next character.
In the embodiment of the present application, the method for determining whether the current input is a word initial character through dictionary matching includes: the electronic equipment divides the input words of the currently input function/variable name, matches the previous word closest to the input position with a word bank, and recommends the next word if the words can be completely matched; and if the previous word cannot be completely matched, the electronic equipment does not recommend the next word.
In the embodiment of the present application, the word stock may be constructed in advance according to the following construction method: selecting codes of a plurality of conventional open source items to recognize function/variable names in a regular matching mode, dividing words according to a separator (a character) and capital characters, filtering the words with the number of characters less than 2 characters, and keeping the rest words to a word bank.
Example 2:
assuming that a user wants to output a constant name NUMBER _ OF _ ARRAY, firstly, the user inputs a character string NUMBER, and the input method word output recommendation sequentially comprises the following steps: number, NUMBER; when the user selects a NUMBER out, the electronic device may determine that the user currently needs an ALL _ UPPER style, i.e., will continue to recommend the word "_", the user selects "_", and when continuing to enter OF, recommend the words OF, OF.
Based on the scheme, the electronic equipment can be the third target character string according to the first character string in the code input by the user, and the electronic equipment can display the preset separator at the input method recommended position according to the code style after the user inputs the first character string, so that the user can input the separator quickly, and the efficiency of editing the code can be improved.
In the embodiment of the present application, the execution order of the steps 103 and 104 and the execution order of the steps 101 and 102 are not limited, and the steps may be executed at any time when the execution condition is satisfied in the process of inputting the code by the user based on the input method interface.
Optionally, the input method interface displays a first control for compiling code in the run code display area. Furthermore, the method for assisting code editing provided by the embodiment of the present application may further include the following steps 105 and 106:
and 105, the electronic equipment receives a second input of the user.
And the second input is input to the first control by the user.
And 106, responding to the second input, compiling and running the codes in the code display area by the electronic equipment, and displaying the result of compiling and running in the first area.
The electronic device may display the result of the code operation in the first area, and if the code has no problem, may display the output result of the code segment and indicate that there is no problem, and if the code has a problem, may indicate that there are several errors, the location where the errors are located, and the like.
Fig. 6 is an interface schematic diagram provided in the embodiment of the present application, as shown in fig. 6 (a), a "compile and run" control 22b is displayed on an interface for editing a code based on an input method, a user may click the "compile and run" control 22b after completing input, an electronic device may compile and run the code in a code display area, and after compiling and running, a result of compiling and running is displayed in an area 25, where fig. 6 illustrates that the code has no problem and an output result is "3".
Based on the scheme, the electronic equipment can display the first control under the condition that the user edits the code based on the input method, so that the user can compile and run the code after editing the code based on the input method, whether the code is in expectation can be checked, and whether the code input by the user has errors can be prompted.
Optionally, the method for assisting code editing provided in this embodiment of the present application may further include the following steps 107 to 108:
and step 107, the electronic equipment receives a third input of the user.
The third input is input for the user to determine that the code editing is completed, and also can be input for the user to determine the sharing code.
And step 108, the electronic equipment responds to the third input and generates codes in a text form according to the format of the code input area.
It should be noted that, the step 107 and the step 108 may be executed after the step 106, or may be executed before the step 106, and this is not specifically limited in this embodiment of the application.
In conjunction with fig. 6 (a), when the user clicks the "complete" control 21d, the electronic device may generate a code in the form of text, as shown in fig. 6 (b), the electronic device maintains the code text in the form of an indentation, a space, and the like, and the color of the code is recognized as black by default, that is, the color of the function name, the constant name, the variable name, and the like is changed to black.
Based on the scheme, the electronic equipment can generate the codes in the text form according to the input of the user after the user edits the codes based on the input method interface, the code format in the text form is the format during editing, the user can conveniently store or share the codes, and other users can view the codes according to the format during editing by the user.
It should be noted that, in the code editing assisting method provided in the embodiment of the present application, the execution subject may be a code editing assisting apparatus, or a control module in the code editing assisting apparatus for executing the code editing assisting method. In the embodiment of the present application, an auxiliary method for a code editing auxiliary device to execute code editing is taken as an example, and the code editing auxiliary device provided in the embodiment of the present application is described.
Fig. 7 is a schematic diagram of a possible structure of an auxiliary device for code editing according to an embodiment of the present application, and as shown in fig. 7, an auxiliary device 700 for code editing includes: a detection module 701 and an execution module 702; the receiving module 701 is configured to detect whether a first code text includes preset characters or not under the condition that a user inputs the first code text based on an input method interface is received, where the first code text includes at least one code sentence; an executing module 702, configured to execute a target operation on the at least one code statement when the detecting module detects that the first code text includes a preset character; wherein the target operation is any one of the following: automatic indentation, automatic line feed, and target character deletion.
Optionally, the auxiliary device for code editing further comprises: a display module; the display module is used for displaying the first target character string in a target color if the first code text comprises the first target character string; wherein the first target character string comprises any one of: built-in keywords, function names, variable names and character strings with misspellings.
Optionally, the auxiliary device for code editing further comprises: a display module; and the display module is used for displaying the recommended output character at the recommended position of the input method if the first character string input by the user meets the preset condition, wherein the first character string is the character string input in the process of inputting the first code text.
Optionally, the display module is specifically configured to: and if the first character string input by the user meets the preset condition, displaying the recommended output character at the input method recommended position based on the code style.
Optionally, the display module is specifically configured to: if the first character string input by the user is a second target character string and the code style is a first code style, displaying the second character string in the first spelling format at the recommended position of the input method under the condition that the second character string is input by the user on the input method interface; or, if the first character string input by the user is the third target character string and the code style is the second code style, displaying a preset separator at the input method recommended position after the first character is input by the user.
According to the auxiliary device for code editing, under the condition that a code text input by a user based on an input method interface is received, the auxiliary device for code editing detects whether the first code text comprises preset characters or not, and the code text comprises at least one code statement; the code editing assisting means may perform a target operation on the at least one code sentence in a case where it is detected that the preset character is included in the code text. Wherein the target operation is at least one of: automatic indentation, automatic line feed, and target character deletion. That is to say, under the condition that a user inputs a code text on an input method interface, if the code text including at least one code sentence input by the user includes preset characters, the auxiliary device for code editing can automatically retract the code sentence, automatically change the line of the code sentence and delete redundant characters, the retraction and the line change are not required to be manually adjusted by the user, the redundant characters are manually deleted, code blocks can be quickly aligned, the operation of editing codes can be more convenient, the operation steps of editing the codes by the user are simplified, and the efficiency of editing the codes by the user is improved.
The auxiliary device for code editing in the embodiment of the present application may be a device, or may be a component, an integrated circuit, or a chip in a terminal. The device can be mobile electronic equipment or non-mobile electronic equipment. By way of example, the mobile electronic device may be a mobile phone, a tablet computer, a notebook computer, a palm top computer, a vehicle-mounted electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a Personal Digital Assistant (PDA), and the like, and the non-mobile electronic device may be a server, a Network Attached Storage (NAS), a Personal Computer (PC), a Television (TV), a teller machine or a self-service machine, and the like, and the embodiments of the present application are not particularly limited.
The auxiliary device for code editing in the embodiment of the present application may be a device having an operating system. The operating system may be an Android (Android) operating system, an ios operating system, or other possible operating systems, and embodiments of the present application are not limited specifically.
The auxiliary device for code editing provided in the embodiment of the present application can implement each process implemented by the auxiliary device for code editing in the method embodiments of fig. 1 to fig. 6, and is not described herein again to avoid repetition.
Optionally, as shown in fig. 8, an electronic device 800 is further provided in this embodiment of the present application, and includes a processor 801, a memory 802, and a program or an instruction stored in the memory 802 and executable on the processor 801, where the program or the instruction is executed by the processor 801 to implement each process of the auxiliary method embodiment for editing a code, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here.
It should be noted that the electronic device in the embodiment of the present application includes the mobile electronic device and the non-mobile electronic device described above.
Fig. 9 is a schematic diagram of a hardware structure of an electronic device implementing an embodiment of the present application.
The electronic device 1000 includes, but is not limited to: a radio frequency unit 1001, a network module 1002, an audio output unit 1003, an input unit 1004, a sensor 1005, a display unit 1006, a user input unit 1007, an interface unit 1008, a memory 1009, and a processor 1010.
Those skilled in the art will appreciate that the electronic device 1000 may further comprise a power source (e.g., a battery) for supplying power to various components, and the power source may be logically connected to the processor 1010 through a power management system, so as to implement functions of managing charging, discharging, and power consumption through the power management system. The electronic device structure shown in fig. 9 does not constitute a limitation of the electronic device, and the electronic device may include more or less components than those shown, or combine some components, or arrange different components, and thus, the description is not repeated here.
The processor 1010 is configured to detect whether a first code text includes preset characters or not when a condition that a user inputs the first code text on an input method interface is received, where the first code text includes at least one code sentence; executing target operation on at least one code statement under the condition that the first code text is detected to comprise preset characters; wherein the target operation is at least one of: automatic indentation, automatic line feed, and target character deletion.
Optionally, the display unit 1006 is configured to display the first target character string in a target color if the first code text includes the first target character string; wherein the first target character string is any one of the following: built-in keywords, function names, variable names and character strings with misspellings.
Optionally, the display unit 1006 is configured to display a recommended output character at the input method recommended position if the first character string input by the user satisfies a preset condition.
Optionally, the display unit 1006 is further configured to display a recommended output character at the input method recommended position based on the code style if a first character string that is input during the process of inputting the first code text satisfies a preset condition.
Optionally, the display unit 1006 is specifically configured to, if the first character string input by the user is the second target character string and the code style is the first code style, display the second character string in the first spelling format at the input method recommended position in a case that the second character string is input by the receiving user on the input method interface; or, if the first character string input by the user is the third target character string and the code style is the second code style, displaying a preset separator at the input method recommended position after the first character is input by the user.
According to the auxiliary method for code editing, under the condition that a code text input by a user on an input method interface is received, the electronic equipment detects whether the first code text comprises preset characters or not, and the code text comprises at least one code statement; the electronic device may perform a target operation on the at least one code statement upon detecting that a preset character is included in the code text. Wherein the target operation is at least one of: automatic indentation, automatic line feed, and target character deletion. That is to say, under the condition that a user inputs a code text on an input method interface, if the code text including at least one code sentence input by the user includes preset characters, the electronic device can automatically retract the code sentence, automatically feed back the code sentence and delete redundant characters, manual retraction and manual feeding of the code sentence and manual deletion of redundant characters are not needed to be manually adjusted by the user, a code block can be quickly aligned, the operation of editing the code can be more convenient, the operation steps of editing the code by the user using the electronic device are simplified, and the efficiency of editing the code by the user is improved.
It should be understood that in the embodiment of the present application, the input Unit 1004 may include a Graphics Processing Unit (GPU) 1041 and a microphone 1042, and the Graphics Processing Unit 1041 processes image data of a still picture or a video obtained by an image capturing device (such as a camera) in a video capturing mode or an image capturing mode. The display unit 1006 may include a display panel 1061, and the display panel 1061 may be configured in the form of a liquid crystal display, an organic light emitting diode, or the like. The user input unit 1007 includes a touch panel 1071 and other input devices 1072. The touch panel 1071 is also referred to as a touch screen. The touch panel 1071 may include two parts of a touch detection device and a touch controller. Other input devices 1072 may include, but are not limited to, a physical keyboard, function keys (e.g., volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which are not described in detail herein. The memory 1009 may be used to store software programs as well as various data, including but not limited to application programs and operating systems. Processor 1010 may integrate an application processor that handles primarily operating systems, user interfaces, applications, etc. and a modem processor that handles primarily wireless communications. It will be appreciated that the modem processor described above may not be integrated into processor 1010.
The embodiments of the present application further provide a readable storage medium, where a program or an instruction is stored on the readable storage medium, and when the program or the instruction is executed by a processor, the program or the instruction implements each process of the above-mentioned auxiliary method for code editing, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here.
The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and so on.
The embodiment of the present application further provides a chip, where the chip includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is configured to run a program or an instruction to implement each process of the auxiliary method embodiment for code editing, and can achieve the same technical effect, and in order to avoid repetition, the description is omitted here.
It should be understood that the chips mentioned in the embodiments of the present application may also be referred to as system-on-chip, system-on-chip or system-on-chip, etc.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element. Further, it should be noted that the scope of the methods and apparatus of the embodiments of the present application is not limited to performing the functions in the order illustrated or discussed, but may include performing the functions in a substantially simultaneous manner or in a reverse order based on the functions involved, e.g., the methods described may be performed in an order different than that described, and various steps may be added, omitted, or combined. In addition, features described with reference to certain examples may be combined in other examples.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present application.
While the present embodiments have been described with reference to the accompanying drawings, it is to be understood that the invention is not limited to the precise embodiments described above, which are meant to be illustrative and not restrictive, and that various changes may be made therein by those skilled in the art without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (12)

1. A method of assisting in code editing, the method comprising:
under the condition that a user inputs a first code text based on an input method interface, detecting whether the first code text comprises preset characters or not, wherein the first code text comprises at least one code statement;
executing target operation on the at least one code statement under the condition that the first code text comprises the preset characters;
wherein the target operation is at least one of: automatic indentation, automatic line feed, and target character deletion.
2. The method of claim 1, further comprising:
if the first code text comprises a first target character string, displaying the first target character string in a target color;
wherein the first target character string is any one of the following: built-in keywords, function names, variable names and character strings with misspellings.
3. The method of claim 1, further comprising:
and if the first character string input by the user meets the preset condition, displaying the recommended output character at the recommended position of the input method, wherein the first character string is the character string input in the process of inputting the first code text.
4. The method of claim 3, wherein if the first character string input by the user satisfies a preset condition, displaying the recommended output character at the input method recommendation position comprises:
and if the first character string input by the user meets the preset condition, displaying the recommended output character at the input method recommended position based on the code style.
5. The method of claim 4, wherein if the first character string input by the user satisfies a preset condition, displaying the recommended output character at the input method recommendation position comprises:
if the first character string input by the user is a second target character string and the code style is a first code style, displaying the second character string in the first spelling format at the recommended position of the input method under the condition that the second character string is input by the user on the input method interface; alternatively, the first and second electrodes may be,
and if the first character string input by the user is the third target character string and the code style is the second code style, displaying a preset segmentation symbol at the input method recommended position after the first character string is input by the user.
6. An auxiliary apparatus for code editing, characterized in that the auxiliary apparatus for code editing comprises: a detection module and an execution module;
the detection module is used for detecting whether a first code text is included in the first code text or not under the condition that the first code text is input by a user based on an input method interface, and the first code text includes at least one code sentence;
the execution module is used for executing target operation on the at least one code statement under the condition that the detection module detects that the first code text comprises preset characters;
wherein the target operation is any one of: automatic indentation, automatic line feed, and target character deletion.
7. The apparatus for assisting code editing according to claim 6, further comprising: a display module;
the display module is used for displaying a first target character string in a target color if the first code text comprises the first target character string;
wherein the first target character string comprises any one of: built-in keywords, function names, variable names and character strings with misspellings.
8. The code editing assistance apparatus according to claim 6, further comprising a display module;
the display module is used for displaying recommended output characters at the recommended position of the input method if a first character string input by a user meets a preset condition, wherein the first character string is input in the process of inputting the first code text.
9. The code editing aid of claim 8, wherein the display module is specifically configured to:
and if the first character string input by the user meets the preset condition, displaying the recommended output character at the input method recommended position based on the code style.
10. The code editing aid of claim 9, wherein the display module is specifically configured to:
if the first character string input by the user is a second target character string and the code style is a first code style, displaying the second character string in the first spelling format at the recommended position of the input method under the condition that the second character string is input by the user on the input method interface; alternatively, the first and second electrodes may be,
and if the first character string input by the user is the third target character string and the code style is the second code style, displaying a preset separator at the input method recommended position after the first character is input by the user.
11. An electronic device comprising a processor, a memory and a program or instructions stored on the memory and executable on the processor, the program or instructions when executed by the processor implementing the steps of the method of code editing assistance of any one of claims 1 to 5.
12. A readable storage medium, characterized in that it stores thereon a program or instructions which, when executed by a processor, implement the steps of a method of assisting in the editing of code according to any one of claims 1 to 5.
CN202110106653.8A 2021-01-26 2021-01-26 Auxiliary method and device for code editing and electronic equipment Active CN112764734B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110106653.8A CN112764734B (en) 2021-01-26 2021-01-26 Auxiliary method and device for code editing and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110106653.8A CN112764734B (en) 2021-01-26 2021-01-26 Auxiliary method and device for code editing and electronic equipment

Publications (2)

Publication Number Publication Date
CN112764734A true CN112764734A (en) 2021-05-07
CN112764734B CN112764734B (en) 2024-05-10

Family

ID=75705915

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110106653.8A Active CN112764734B (en) 2021-01-26 2021-01-26 Auxiliary method and device for code editing and electronic equipment

Country Status (1)

Country Link
CN (1) CN112764734B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114296708A (en) * 2022-03-11 2022-04-08 来也科技(北京)有限公司 RPA code generation method and device combining RPA and AI and electronic equipment
WO2024022432A1 (en) * 2022-07-28 2024-02-01 北京字跳网络技术有限公司 Information processing methods and apparatus, and electronic device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008234646A (en) * 2007-03-15 2008-10-02 Ricoh Co Ltd Class object wrapper of document object model (dom) element of project task management system for managing project schedule on network
CN105824794A (en) * 2016-03-11 2016-08-03 天脉聚源(北京)教育科技有限公司 Annotation adding method and device
CN109683907A (en) * 2018-12-29 2019-04-26 深圳乐信软件技术有限公司 Code completion method, apparatus, equipment and storage medium
CN109918064A (en) * 2019-01-29 2019-06-21 深圳点猫科技有限公司 A kind of implementation method and device of the code completion based on ace extension

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008234646A (en) * 2007-03-15 2008-10-02 Ricoh Co Ltd Class object wrapper of document object model (dom) element of project task management system for managing project schedule on network
CN105824794A (en) * 2016-03-11 2016-08-03 天脉聚源(北京)教育科技有限公司 Annotation adding method and device
CN109683907A (en) * 2018-12-29 2019-04-26 深圳乐信软件技术有限公司 Code completion method, apparatus, equipment and storage medium
CN109918064A (en) * 2019-01-29 2019-06-21 深圳点猫科技有限公司 A kind of implementation method and device of the code completion based on ace extension

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114296708A (en) * 2022-03-11 2022-04-08 来也科技(北京)有限公司 RPA code generation method and device combining RPA and AI and electronic equipment
WO2024022432A1 (en) * 2022-07-28 2024-02-01 北京字跳网络技术有限公司 Information processing methods and apparatus, and electronic device

Also Published As

Publication number Publication date
CN112764734B (en) 2024-05-10

Similar Documents

Publication Publication Date Title
US10698604B2 (en) Typing assistance for editing
US8077974B2 (en) Compact stylus-based input technique for indic scripts
US10838513B2 (en) Responding to selection of a displayed character string
EP2713255B1 (en) Method and electronic device for prompting character input
US10402474B2 (en) Keyboard input corresponding to multiple languages
CN104718545A (en) Incremental multi-word recognition
CN101256462A (en) Hand-written input method and apparatus based on complete mixing association storeroom
WO2022135474A1 (en) Information recommendation method and apparatus, and electronic device
US9298276B1 (en) Word prediction for numbers and symbols
CN112269475A (en) Character display method and device and electronic equipment
CN112764734B (en) Auxiliary method and device for code editing and electronic equipment
WO2021254251A1 (en) Input display method and apparatus, and electronic device
CN111984589A (en) Document processing method, document processing device and electronic equipment
WO2022105754A1 (en) Character input method and apparatus, and electronic device
CN101369209B (en) Hand-written input device and method for complete mixing input
CN107797676B (en) Single character input method and device
US11899904B2 (en) Text input system with correction facility
CN112148135A (en) Input method processing method and device and electronic equipment
CN111142683B (en) Input assisting program, input assisting method, and input assisting device
CN112684910A (en) Input method candidate word display method and device and electronic equipment
US8386236B2 (en) Method for prompting by suggesting stroke order of chinese character, electronic device, and computer program product
WO2022143523A1 (en) Vocabulary display method and apparatus, and electronic device
CN115437548A (en) Display method and device of virtual keyboard, electronic equipment and storage medium
CN111966267A (en) Application comment method and device and electronic equipment
CN113190125A (en) Input correction method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant