CN109284481B - Prompt text processing method and device and computer readable storage medium - Google Patents

Prompt text processing method and device and computer readable storage medium Download PDF

Info

Publication number
CN109284481B
CN109284481B CN201811042800.4A CN201811042800A CN109284481B CN 109284481 B CN109284481 B CN 109284481B CN 201811042800 A CN201811042800 A CN 201811042800A CN 109284481 B CN109284481 B CN 109284481B
Authority
CN
China
Prior art keywords
line
pixel width
display
display line
tail
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.)
Active
Application number
CN201811042800.4A
Other languages
Chinese (zh)
Other versions
CN109284481A (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.)
Zhengzhou Yunhai Information Technology Co Ltd
Original Assignee
Zhengzhou Yunhai Information Technology 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 Zhengzhou Yunhai Information Technology Co Ltd filed Critical Zhengzhou Yunhai Information Technology Co Ltd
Priority to CN201811042800.4A priority Critical patent/CN109284481B/en
Publication of CN109284481A publication Critical patent/CN109284481A/en
Application granted granted Critical
Publication of CN109284481B publication Critical patent/CN109284481B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/106Display of layout of documents; Previewing

Abstract

The embodiment of the invention discloses a prompt text processing method, which comprises the following steps: receiving a text prompting instruction, wherein the text prompting instruction is used for positioning a first line feed position of a prompting text; executing line feed at a first line feed position of a prompt text according to a text prompt instruction to obtain a head display line; if the first pixel width of the head display line is larger than the preset pixel width, advancing the first line feed position at the tail end of the head display line to obtain a second line feed position; and performing line feed at the second line feed position of the prompt text. The embodiment of the invention also discloses a prompt text processing device and a computer readable storage medium. The embodiment of the invention ensures that the pixel width of each display line is within the preset range, and improves the integrity of the display result.

Description

Prompt text processing method and device and computer readable storage medium
Technical Field
The present invention relates to the field of text processing, and in particular, to a method and an apparatus for processing prompt text, and a computer-readable storage medium.
Background
The text prompt attributes include a title (title) attribute that specifies additional information about the target element that would normally display a piece of prompt text when the mouse is moved over the target element, and a hypertext reference (alt) attribute that specifies displaying an alternate prompt text when the picture cannot be rendered.
In the page development process, the situation that the display of text information is incomplete or the display of the text information completely destroys the page layout is often encountered, at this time, the text prompt attribute of the page is usually required to be utilized to display all the text information in the prompt text, but when the text information is too long, the situation that the display of the text displayed in the prompt text is incomplete occurs.
For the above situation, most of the current practice is: the method can solve the problem that the text displayed in the prompt text is incomplete in display, but the widths of pixels occupied by Chinese characters, letters and symbols in display are not the same, and the widths of pixels of character string line-feed intercepted according to the number of characters of the text are not the same, so that the problem of incomplete display results is caused.
Disclosure of Invention
The embodiment of the invention provides a prompt text processing method, a prompt text processing device and a computer readable storage medium, which ensure that the pixel width of each display line is within a preset range and improve the accuracy of a display result.
The first aspect of the present invention provides a method for processing a prompt text, including:
receiving a text prompt instruction, wherein the text prompt instruction is used for positioning a first line feed position of a prompt text;
executing line feed at the first line feed position of the prompt text according to the text prompt instruction to obtain a head display line;
if the first pixel width of the head display line is larger than the preset pixel width, advancing the first line feed position at the tail end of the head display line to obtain a second line feed position;
and executing line feed at the second line feed position of the prompt text.
In one possible design of the first aspect, the performing line feed at the first line feed position of the prompt text according to the text prompt instruction, and obtaining a head display line includes:
determining N first line feed positions in the prompt text according to the text prompt instruction;
executing line feed at N first line feed positions of the prompt text to obtain N first preliminary display lines and a tail display line, wherein the prompt text character number of each first preliminary display line is a first character number, the prompt text character number of the tail display line is a second character number, the first character number is not less than the second character number, and N is an integer greater than 1.
In one possible design of the first aspect, the determining N first line feed positions in the prompt text further includes:
acquiring a third pixel width and a preset pixel width of the prompt text, and determining the ratio of the third pixel width to the preset pixel width as the number of interception lines;
and acquiring a second number of characters of the prompt text, and determining a first number of characters according to the second number of characters, wherein the tail of the first number of characters is within a preset range of the ratio of the second number of characters to the intercepted number of lines.
In a possible design of the first aspect, if the first pixel width of the head display line is greater than the preset pixel width, advancing the first line feed position at the end of the head display line to obtain the second line feed position includes:
determining a first pixel width of each of the N header display lines;
and sequentially advancing the first line feed position at the tail end of the head display line with each first pixel width larger than the preset pixel width to obtain N second line feed positions.
In a possible design of the first aspect, the advancing the first line feed position at the end of the head display line with each fourth pixel width being greater than the preset pixel width in turn to obtain the second line feed position further includes:
if the third number of characters of the tail display line is larger than the first number of characters and the fourth pixel width of the tail display line is larger than the preset pixel width, determining M third line changing positions of the tail display line;
performing line feed at the M third line feed positions of the tail display line to obtain M +1 first tail sub-display lines, wherein a fifth pixel width of each first tail sub-display line is not greater than the preset pixel width, and M is an integer greater than or equal to 1;
correspondingly, the line feed at the second line feed position of the prompt text comprises:
and executing line feed at the N second line feed positions and the M third line feed positions of the prompt text.
In a possible design of the first aspect, the advancing the first line feed position at the end of the head display line with each fourth pixel width being greater than the preset pixel width in turn to obtain the second line feed position further includes:
if the third character number of the tail display line is not more than the first character number and the fourth pixel width of the tail display line is more than the preset pixel width, determining a fourth line feed position of the tail display line;
executing line feed at a fourth line feed position of the tail display line to obtain a first head sub-display line and a second tail sub-display line, wherein a fifth pixel width and a sixth pixel width of the first head sub-display line are not greater than the preset pixel width;
correspondingly, the line feed at the second line feed position of the prompt text comprises:
and performing line feed at the N second line feed positions and the fourth line feed position of the prompt text.
In a possible design of the first aspect, if the first pixel width of the head display line is greater than the preset pixel width, advancing the first line feed position at the end of the head display line to obtain the second line feed position includes:
sequentially and circularly executing a first circular line-feed strategy and a second circular line-feed strategy until the second pixel width of the head display line is not more than the preset pixel width and the seventh pixel width of the tail display line is not more than the preset pixel width;
the first round-robin routing policy is configured to:
if the first pixel width of the head display line is larger than the preset pixel width, advancing the first line change position at the tail end of the head display line to obtain a second line change position, so that the second pixel width of the head display line is not larger than the preset pixel width;
the second round-robin routing policy is configured to:
when the seventh pixel width is larger than the preset pixel width, executing line feed at a fifth line feed position of the tail display line to obtain a second head sub display line and a third tail sub display line, updating the second head sub display line into the head display line, and updating the third tail sub display line into the tail display line;
correspondingly, the line feed at the second line feed position of the prompt text comprises:
and performing line feed at the second line feed position and the fifth line feed position of the prompt text.
A second aspect of the present invention provides a prompt text processing apparatus, including:
the receiving module is used for receiving a text prompting instruction, and the text prompting instruction is used for positioning a first line feed position of a prompting text;
the first processing module is used for executing line feed at the first line feed position of the prompt text according to the text prompt instruction received by the receiving module to obtain a head display line;
the second processing module is used for advancing the first line feed position at the tail end of the head display line to obtain a second line feed position if the first pixel width of the head display line obtained by the first processing module is greater than the preset pixel width;
and the third processing module is used for executing line feed at the second line feed position obtained by the second processing module of the prompt text.
In one possible design of the second aspect, the first processing module is configured to:
determining N first line feed positions in the prompt text according to the text prompt instruction received by the receiving module;
executing line feed at N first line feed positions of the prompt text to obtain N first preliminary display lines and a tail display line, wherein the prompt text character number of each first preliminary display line is a first character number, the prompt text character number of the tail display line is a second character number, the first character number is not less than the second character number, and N is an integer greater than 1.
In a possible design of the second aspect, the prompt text processing apparatus further includes an obtaining module;
the acquisition module is used for acquiring a third pixel width and a preset pixel width of the prompt text and determining the ratio of the third pixel width to the preset pixel width as the number of interception lines;
and acquiring a second number of characters of the prompt text, and determining a first number of characters according to the second number of characters, wherein the tail of the first number of characters is within a preset range of the ratio of the second number of characters to the intercepted number of lines.
In a possible design of the second aspect, the second processing module is specifically configured to determine a first pixel width of each of the N header display lines;
and sequentially advancing the first line feed position at the tail end of the head display line with each first pixel width larger than the preset pixel width to obtain N second line feed positions.
In one possible design of the second aspect, the prompt text processing apparatus further includes a fourth processing module;
the fourth processing module is specifically configured to: if the third number of characters of the tail display line is larger than the first number of characters and the fourth pixel width of the tail display line is larger than the preset pixel width, determining M third line changing positions of the tail display line;
and performing line feed at the M third line feed positions of the tail display line to obtain M +1 first tail sub-display lines, wherein the fifth pixel width of each first tail sub-display line is not greater than the preset pixel width, and M is an integer greater than or equal to 1.
Correspondingly, the third processing module is specifically configured to: and executing line feed at the N second line feed positions and the M third line feed positions of the prompt text.
In one possible design of the second aspect, the prompt text processing apparatus further includes a fourth processing module;
the fourth processing module is specifically configured to determine M third line feed positions of the tail display line if the third number of characters of the tail display line is greater than the first number of characters and the fourth pixel width of the tail display line is greater than the preset pixel width;
and performing line feed at the M third line feed positions of the tail display line to obtain M +1 first tail sub-display lines, wherein the fifth pixel width of each first tail sub-display line is not greater than the preset pixel width, and M is an integer greater than or equal to 1.
Correspondingly, the third processing module is specifically configured to: and executing line feed at the N second line feed positions and the M third line feed positions of the prompt text.
In one possible design of the second aspect, the prompt text processing apparatus further includes a fourth processing module;
the fourth processing module is used for determining a fourth line feed position of the tail display line if the third character number of the tail display line is not more than the first character number and the fourth pixel width of the tail display line is more than the preset pixel width;
executing line feed at a fourth line feed position of the tail display line to obtain a first head sub-display line and a second tail sub-display line, wherein a fifth pixel width and a sixth pixel width of the first head sub-display line are not greater than the preset pixel width;
correspondingly, the third processing module is specifically configured to: and performing line feed at the N second line feed positions and the fourth line feed position of the prompt text.
In a possible design of the second aspect, the first processing module is specifically configured to sequentially and cyclically execute the first loop linefeed strategy and the second loop linefeed strategy until the second pixel width of the head display line is not greater than the preset pixel width and the seventh pixel width of the tail display line is not greater than the preset pixel width;
the first round-robin routing policy is configured to:
if the first pixel width of the head display line is larger than the preset pixel width, advancing the first line change position at the tail end of the head display line to obtain a second line change position, so that the second pixel width of the head display line is not larger than the preset pixel width;
the second round-robin routing policy is configured to:
when the seventh pixel width is larger than the preset pixel width, executing line feed at a fifth line feed position of the tail display line to obtain a second head sub display line and a third tail sub display line, updating the second head sub display line into the head display line, and updating the third tail sub display line into the tail display line;
correspondingly, the fourth processing module is specifically configured to: and performing line feed at the second line feed position and the fifth line feed position of the prompt text.
A third aspect of the present invention provides a computer-readable storage medium having stored therein instructions, which when run on a computer, cause the computer to perform the method of the above-described aspects.
According to the technical scheme, the embodiment of the invention has the following advantages:
the embodiment of the invention provides a prompt text processing method, which comprises the steps of firstly receiving a text prompt instruction, wherein the text prompt instruction is used for positioning a first line feed position of a prompt text; then, line feed is executed at the first line feed position of the prompt text according to the text prompt instruction to obtain a head display line; if the first pixel width of the head display line is larger than the preset pixel width, advancing the first line feed position at the tail end of the head display line to obtain a second line feed position; and finally, performing line feed at the second line feed position of the prompt text. Through the mode, when the prompt text is displayed, on the basis of line changing executed at the first line changing position, the line changing position at the tail end of the display line with the pixel width larger than the preset pixel width is adjusted, so that the pixel width of each preliminary display line is not larger than the preset pixel width, the pixel width of the head display line is ensured to be within the preset range, and the integrity of the display result is improved.
Drawings
FIG. 1 is a schematic diagram of an embodiment of a method for processing a prompt text in an embodiment of the present invention;
FIG. 2 is a schematic diagram of an embodiment of a prompt text processing apparatus according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of another embodiment of a prompt text processing apparatus according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of another embodiment of a prompt text processing apparatus according to an embodiment of the present invention;
FIG. 5 is a schematic flow chart of prompt text processing in an application scenario of the present invention;
fig. 6 is a schematic flow chart of processing a prompt text in an application scenario of the present invention.
Detailed Description
The embodiment of the invention provides a prompt text processing method, a prompt text processing device and a computer readable storage medium, which ensure that the pixel width of a display line is within a preset range and improve the integrity of a display result.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are, for example, capable of operation in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Referring to fig. 1, an embodiment of a method for processing a prompt text in an embodiment of the present invention includes:
101. and receiving a text prompt instruction, wherein the text prompt instruction is used for positioning a first line feed position of a prompt text.
In this embodiment of the application, the text prompt instruction may be sent by an input device, where the input device may include but is not limited to one or more of a trackball, a mouse, a joystick, and the like, and the text prompt instruction may carry position information of a target element, where the target element has a text prompt attribute, and the target element may be a web page link or a text keyword, and the like. Taking an input device as an example of a mouse, when the position of the mouse moves to a position near the target element, which is equivalent to receiving a text prompt instruction, since the target element has a text prompt attribute (a title attribute or an alt attribute), a preset title value is displayed in a preset area around the target element at this time, and the preset title value is collectively referred to as a prompt text hereinafter.
In the embodiment of the application, the physical length or the pixel width of the prompt text may be very long, if the prompt text is directly displayed in the preset area without line feed processing, and due to the limited length of the display area or other display contents on the display area, the situation that the prompt text is not completely displayed, blocks other display contents, or is covered by other display contents may occur. If the text is intercepted and the line feed character is added after the text is prompted every other preset characters, the method can solve the problems to a certain extent, but because the pixel widths of the Chinese characters, the numbers and the symbols are different during displaying, the pixel widths of the character strings in each line after line feed are very different, and the displayed results are different and the display interface is not friendly. In the embodiment of the application, the line feed strategy of the prompt text is improved before the prompt text is displayed in the preset area around the target element. Specifically, the line feed policy may be deployed in a temporary partition (div), a temporary div may be created by using a transliterated scripting language (js), the temporary div is loaded into a Document Object Model (DOM) tree, and after a text prompt instruction carrying position information of a target element is received, a prompt text that needs to be displayed in a title may be inserted into the div.
In the embodiment of the application, after the prompt text to be displayed in the title is inserted into the div, the preparation work of the prompt text is equivalently completed, and then the first line feed position in the prompt text can be positioned in the div. The first line feed position may be a line feed position obtained after the initial determination is performed, for example, a center character position of the prompt text may be used as the first line feed position or a position after a preset number of characters is used as the first line feed position according to an actual situation.
102. And executing line feed at a first line feed position of the prompt text according to the text prompt instruction to obtain a head display line.
In the embodiment of the application, after the first line feed position of the prompt text is located, line feed is performed at the first line feed position of the prompt text according to the text prompt instruction, and it can be understood that a head display line and a tail display line can be obtained after line feed is performed at the first line feed position of the prompt text, where the head display line starts from a first character of the prompt text to the text between the first line feed position, and the tail display line starts from the text between the first line feed position and a last character. Taking the example that when the prompt text is "the link can be directly jumped to the live interface in the ABC network", after the first line change position of the prompt text is positioned as the eighth character, i.e., "jump" and "transfer", line feed is performed at the first line change position of the prompt text, and the head display line "the link can be jumped directly" and the tail display line "transfer to the live interface in the ABC network" are obtained.
103. And if the first pixel width of the head display line is larger than the preset pixel width, advancing the first line feed position at the tail end of the head display line to obtain a second line feed position.
In the embodiment of the present application, after performing line feed at the first line feed position of the prompt text to obtain the head display line, it is required to determine whether the pixel width of the head display line meets the requirement of the display interface, specifically, it may be determined whether the pixel width of the head display line meets the requirement of the display interface by determining whether the pixel width of the head display line is greater than a preset pixel width, it may be understood that, when the first pixel width of the head display line is too large, the first pixel width is likely to be covered by other real objects of the display interface, or exceeds the display range of the display interface, so that the display content of the prompt text is incomplete, further, if the first pixel width of the head display line is greater than the preset pixel width, it is determined that the first pixel width obtained by line feed does not meet the requirement of the head display line display interface, and the preset pixel width may be determined by a user in combination with the display object arrangement of the display interface and the display range of the display interface, or an optimal value calculated by the computer according to the display target arrangement of the display interface and the display range of the display interface, and in actual application, the preset pixel width determination method may be selected as required, which is not limited herein.
In this embodiment of the present application, when the first pixel width of the head display line is greater than the preset pixel width, it is determined that the head display line obtained by line pre-swapping does not meet the requirement of the display interface, and the pixel width of the head display line needs to be adjusted. Advancing the first linefeed position at the end of the head display line may be to move the first linefeed position forward by a certain number of characters until the first pixel width of the head display line is greater than the preset pixel width, resulting in a second linefeed position. Taking an example that when the prompt text is "the link can be directly jumped to a live interface in the ABC network", the head display line "the link can be jumped directly" and the tail display line "the live interface in the ABC network" obtained through the pre-line-dividing step, if the preset pixel width is 5 characters, the head display line includes 8 characters at this time, that is, the first pixel width of the head display line is greater than the preset pixel width, the first line change position at the end of the head display line needs to be advanced by at least 3 characters at least to ensure that the first pixel width of the head display line is not greater than 5 characters. It should be noted that the number of characters with the advanced first line feed position needs to be selected according to actual conditions, if the number of advanced characters is too small, the width of the first pixel of the head display line is still very wide, and if the number of advanced characters is too large, the head display line is over-segmented, which may adversely affect the aesthetics of the display interface and the readability of the prompt text. Optionally, the first line feed position may be advanced by 1 character number in sequence, and it is determined whether the first pixel width of the sequential head display line is equal to the preset pixel width or slightly smaller than the preset pixel width each time the first line feed position is advanced, and the advance is stopped until the first pixel width of the head display line is equal to the preset pixel width or slightly smaller than the preset pixel width.
104. And performing line feed at the second line feed position of the prompt text.
In the embodiment of the application, the first line feed position at the end of the head display line is advanced to obtain the second line feed position, which is equivalent to obtaining the line feed position capable of meeting the interface display pixel width condition of the head display line, and then the line feed is executed at the second line feed position of the prompt text, so that the head display line meeting the interface display pixel width condition of the head display line can be obtained.
In the embodiment of the application, a text prompt instruction is received at first, and the text prompt instruction is used for positioning a first line feed position of a prompt text; then, line feed is executed at a first line feed position of the prompt text according to the text prompt instruction to obtain a head display line; if the first pixel width of the head display line is larger than the preset pixel width, advancing the first line feed position at the tail end of the head display line to obtain a second line feed position; and finally, performing line feed at a second line feed position of the prompt text. Through the mode, when the prompt text is displayed, on the basis of line changing executed at the first line changing position, the line changing position at the tail end of the display line with the pixel width larger than the preset pixel width is adjusted, so that the pixel width of the initial display line is not larger than the preset pixel width, the pixel width of the head display line is ensured to be within the preset range, and the integrity of the display result is improved to a certain extent.
Optionally, on the basis of the first embodiment corresponding to fig. 1, in a second optional embodiment of the prompt text processing method according to the embodiment of the present invention, performing line feed at the first line feed position of the prompt text according to the text prompt instruction, and obtaining the head display line may include:
determining N first line feed positions in a prompt text according to a text prompt instruction;
line feed is executed at N first line feed positions of the prompt text to obtain N first preliminary display lines and a tail display line, the number of prompt text characters of each first preliminary display line is a first character number, the number of prompt text characters of the tail display line is a second character number, the first character number is not less than the second character number, and N is an integer greater than 1.
In the embodiment of the application, when the first line feed positions are multiple, the line splitting conditions of each head display line and each tail display line are described in detail, and it can be understood that when the pixel width of the prompt text is too long, line feeding of the prompt text through a single first line feed position can only ensure that the first pixel width of the head display line meets the requirement and can not ensure the display requirement of the tail display line.
In this embodiment of the application, specifically, executing line feed at N first line feed positions of the prompt text, and a positioning manner of the N first line feed positions may be a first number of characters determined by a user or a computer based on display target arrangement of a current display interface and a display width of the display interface, where the first number of characters is approximately a number of characters that each line of the current display interface is estimated to be preferentially accommodated, and specifically, a confirmation manner of the first number of characters may include: acquiring a third pixel width and a preset pixel width of the prompt text, and determining the ratio of the third pixel width and the preset pixel width as the number of interception lines; acquiring a second character number of the prompt text, determining a first character number according to the second character number, wherein the tail of the first character number is within a preset range of a ratio of the second character number to the intercepted line number, for example, when the total pixel width of the prompt text is totalwidth, the available display width around the target element is requiredwidth at this time, and calculating a multiple num1 of totalwidth/requiredwidth, wherein num1 is the line number of the prompt text which needs to be intercepted approximately, and the character number of the prompt text is length, and thus the character number of each line of the text which needs to be intercepted/num 1 is num 2. And then, primarily intercepting the text within a preset range of num2, specifically, intercepting the prompt text once at an intercepting position every time the intercepting position is spaced from the first character by num2 characters from the first character of the prompt text, wherein each intercepting position is N first line feed positions. For example, if the prompt text is "the link can jump directly to the live interface in the ABCD network", if the total pixel width totalwidth of the prompt text is 1440px, the pixel width requiredwidth that can be displayed by the prompt text in the display interface is 360px, the number of lines num1 to 1440/360 to 4 and the number of characters in the prompt text is length21 are calculated, the number of characters num2 to length/num1 to 21/4 to 5.25 and 5 that are close to 5.25 are determined as the first number of characters, and then the first line change position is located after four characters "to go", "to", "network" and "boundary" are respectively calculated. Through the positioning of the N first line feed positions, the estimated optimal line feed position of the prompt text is positioned, and further line feed position adjustment can be conveniently carried out subsequently. It should be noted that, if the first line feed position is located in the full english name, if the line is fed at the first line feed position, the english word is disassembled, which affects the accuracy of the display result. It should be noted that the above step of positioning the first linefeed position is only an illustration, and the first linefeed position may be determined according to actual requirements in the application process.
In the embodiment of the present application, after positioning of the N first line feed positions is completed, line feed may be performed on the N first line feed positions of the prompt text to obtain N first preliminary display lines and a tail display line, where the number of characters of the prompt text of each first preliminary display line is a first number of characters, and the number of characters of the prompt text of the tail display line is a second number of characters, it can be understood that, after the line splitting operation performed at intervals of the first number of characters, in order to ensure that the width of pixels of the tail display line is small, it is necessary to ensure that the first number of characters is not less than the second number of characters.
In the embodiment of the application, the number of the first line feed positions is multiple, the number of the characters between the first line feed positions is the first number of characters, the first number of characters is not less than the second number of characters of the tail display line, the number of the estimated optimal line feed positions is changed into multiple, and the pixel width of the tail display line can be reduced when the pixel width of the prompt text is too long.
Optionally, on the basis of the second embodiment corresponding to fig. 1, in a third optional embodiment of the prompt text processing method according to the embodiment of the present invention, if the first pixel width of the head display line is greater than the preset pixel width, advancing the first line feed position at the end of the head display line, and obtaining the second line feed position may include:
determining a first pixel width for each of the N header display lines;
and sequentially advancing the first line feed position at the tail end of the head display line with each first pixel width larger than the preset pixel width to obtain a second line feed position, so that the second pixel width of the N head display lines is not larger than the preset pixel width.
In the embodiment of the application, when the pixel width of the prompt text is too long, a plurality of first branch positions are determined in the preliminary branch process, so that the pixel width of each display line can be further shortened when the pixel width of the prompt text is too long, N head display lines and one tail display line are obtained, and then the pixel width of each display line obtained in the preliminary branch process needs to be adjusted to meet the pixel width display requirement of a display interface. It should be noted that the N head display lines include the same number of characters, i.e., the first number of characters, but the pixel width of each character number pair is different, so that even though the number of characters of the head display lines is the same, the pixel widths may be different, and further, a situation may occur in which the pixel width of a part of the N head display lines meets the pixel width display requirement of the display interface, and the pixel width display requirement of the other part of the N head display lines does not meet the pixel width display requirement of the display interface.
In the embodiment of the application, the first pixel width of each head display line in the N head display lines is determined, and then the first line feed position at the tail end of each head display line with the first pixel width larger than the preset pixel width is advanced in sequence to obtain the second line feed position. Specifically, each head display line may be sequentially traversed according to a front-back order of the prompt text, and when the head display line having the first pixel width larger than the preset pixel width is traversed, the first line feed position at the end of the head display line is advanced. Optionally, the first line feed position may be advanced by 1 character number in sequence, and it is determined whether the first pixel width of the sequential head display line is equal to the preset pixel width or slightly smaller than the preset pixel width each time the first line feed position is advanced, and the advance is stopped until the first pixel width of the head display line is equal to the preset pixel width or slightly smaller than the preset pixel width. When the first line feed position adjustment of the first pixel width larger than the preset pixel width at the end of the head display line is completed, correspondingly, the number of characters of the next head display line of the head display line which completes the pixel adjustment is correspondingly increased, if the first pixel width of the next head display line after the number of characters is increased is not more than the preset pixel width, the first line feed position at the end of the next head display line is not required to be adjusted, and the next head display line is directly traversed, if the first pixel width of the next head display line after the number of characters is increased is larger than the preset pixel width, the first line feed position at the end of the next head display line needs to be adjusted, and the specific adjustment method of the first line feed position may refer to the adjustment method when traversing to the head display line with the first pixel width larger than the preset pixel width, which is not described herein again. Before and after the first line feed position at the tail end of the head display line with each first pixel width larger than the preset pixel width is referred to, N second line feed positions are obtained, wherein one part of the N second line feed positions is the same as the original first line feed position, and the other part of the N second line feed positions is different from the original first line feed position.
In the embodiment of the application, when the prompt text is displayed, on the basis of executing line changing at the N first line changing positions, the line changing position at the tail end of the display line with the pixel width larger than the preset pixel width is adjusted, so that the pixel width of the N initial display lines is not larger than the preset pixel width, the pixel width of the head display line is ensured to be within the preset range, and the integrity of the display result is improved to a certain extent.
Optionally, on the basis of the third embodiment corresponding to fig. 1, in a fourth optional embodiment of the prompt text processing method according to the embodiment of the present invention, the step of sequentially advancing the first line feed position at the end of the head display line whose fourth pixel width is greater than the preset pixel width to obtain the second line feed position further includes:
if the third number of characters of the tail display line is larger than the first number of characters and the fourth pixel width of the tail display line is larger than the preset pixel width, determining M third line feed positions of the tail display line;
executing line feed at M third line feed positions of the tail display line to obtain M +1 first tail sub-display lines, wherein the fifth pixel width of each first tail sub-display line is not more than the preset pixel width, and M is an integer greater than or equal to 1;
correspondingly, the line feed is executed at the second line feed position of the prompt text, and the line feed comprises the following steps:
and performing line feed at N second line feed positions and M third line feed positions of the prompt text.
In the embodiment of the application, before and after the first line change position at the tail end of the head display line with each first pixel width larger than the preset pixel width is referred to, N second line change positions are obtained, after the line change is performed on the prompt text at the N second line change positions, N head display lines meeting the requirement of the display interface pixel width can be obtained, it can be understood that the first line change position at the tail end of the head display line with each first pixel width larger than the preset pixel width is advanced, when the number of the head display lines with the first pixel width larger than the preset pixel width is large, or the head display line with the first pixel width far larger than the preset pixel width exists, the first display position at the tail end of the last head display line in the N head display lines may be advanced much more than the unadjusted first display position at this time, and further, the number of characters of the tail display line may be far larger than the second number of characters, so that the pixel width of the trailing display line is much larger than the preset pixel width.
In the embodiment of the present application, considering a processing policy when the tail display line does not satisfy the requirement for the width of the interface display pixel, it can be understood that, when the fourth pixel width of the tail display line is greater than the preset pixel width, the tail display line may be considered to not satisfy the requirement for the width of the interface display pixel, and further, when the fourth pixel width of the tail display line is greater than the preset pixel width, it may occur: 1. the third number of characters of the tail display line is greater than the first number of characters; 2. and then, describing the line dividing strategy of the tail display line when the third character number of the tail display line is greater than the first character number.
In this embodiment of the application, if the number of the third characters of the tail display line is greater than the number of the first characters and the width of the fourth pixel of the tail display line is greater than the preset pixel width, M third line feed positions of the tail display line are determined, and when the number of the third characters of the tail display line is greater than the first character number, in order to improve line feed efficiency, the M third line feed positions in the tail display line may be first located. After line feed is performed at the third line feed position of M songs in the prompt text, M +1 first tail sub-display lines can be obtained, wherein the fifth pixel width of each first tail sub-display line is not greater than the preset pixel width.
In the embodiment of the application, after the division of the head display line is completed, when the tail display line does not meet the pixel display requirement of the display interface, the division is further performed on the tail display line, and the pixel width of each tail sub-display line is adjusted, so that the pixel widths of the head display line and the tail display line are ensured to be within a preset range, and the integrity of the display result is improved to a certain extent.
Optionally, on the basis of the third embodiment corresponding to fig. 1, in a fifth optional embodiment of the prompt text processing method according to the embodiment of the present invention, the step of sequentially advancing the first line feed position of the end of the head display line whose fourth pixel width is greater than the preset pixel width to obtain the second line feed position may further include:
if the third number of characters of the tail display line is not more than the first number of characters and the fourth pixel width of the tail display line is more than the preset pixel width, determining M third line feed positions of the tail display line;
performing line feed at a fourth line feed position of the tail display line to obtain a first head sub-display line and a second tail sub-display line, wherein a fifth pixel width of the first head sub-display line and a sixth pixel width of the second tail sub-display line are not greater than a preset pixel width;
correspondingly, the line feed is executed at the second line feed position of the prompt text, and the line feed comprises the following steps:
and performing line feed at N second line feed positions and a fourth line feed position of the prompt text.
In the embodiment of the application, before and after the first line change position at the tail end of the head display line with each first pixel width larger than the preset pixel width is referred to, N second line change positions are obtained, after the line change is performed on the prompt text at the N second line change positions, N head display lines meeting the requirement of the display interface pixel width can be obtained, it can be understood that the first line change position at the tail end of the head display line with each first pixel width larger than the preset pixel width is advanced, when the number of the head display lines with the first pixel width larger than the preset pixel width is large, or the head display line with the first pixel width far larger than the preset pixel width exists, the first display position at the tail end of the last head display line in the N head display lines may be advanced much more than the unadjusted first display position at this time, and further, the number of characters of the tail display line may be far larger than the second number of characters, so that the pixel width of the trailing display line is much larger than the preset pixel width.
In the embodiment of the present application, considering a processing policy when the tail display line does not satisfy the requirement for the width of the interface display pixel, it can be understood that, when the fourth pixel width of the tail display line is greater than the preset pixel width, the tail display line may be considered to not satisfy the requirement for the width of the interface display pixel, and further, when the fourth pixel width of the tail display line is greater than the preset pixel width, it may occur: 1. the third number of characters of the tail display line is greater than the first number of characters; 2. and then, describing the line dividing strategy of the tail display line when the third character number of the tail display line is less than or equal to the first character number.
In this embodiment, if the third number of characters of the tail display line is less than or equal to the first number of characters and the fourth pixel width of the tail display line is greater than the preset pixel width, the fourth line change position of the tail display line is determined, line change is performed at the fourth line change position of the tail display line, and a first head sub-display line and a second tail sub-display line are obtained, wherein the fifth pixel width of the first head sub-display line and the sixth pixel width of the second tail sub-display line are not greater than the preset pixel width.
In the embodiment of the application, after the division of the head display line is completed, when the tail display line does not meet the pixel display requirement of the display interface, the tail display line is further divided, and the widths of the first head sub-display line and the first head sub-display line after the division are adjusted, so that the widths of the pixels of the head display line and the tail display line are ensured to be within a preset range, and the integrity of the display result is improved to a certain extent.
For convenience of understanding, the method for processing the prompt text will be described below through a specific flow, please refer to fig. 2, where fig. 2 is a schematic flow diagram of the prompt text processing in the application scenario of the present invention, and as shown in the figure, specifically:
taking the prompt text as "title: attribute of the element, when the mouse moves to the element, displaying a section of tool-tip text; js: the abbreviation javascript is a dynamic type, weak type, prototype-based language, and has a built-in support type; and div: a tag element of one of the pages; and dom: the document object model is explained by taking a standard programming interface for processing extensible markup language recommended by the organization of W3C as an example:
201. when the coordinate point position of the mouse is near the target element with the text prompt attribute, js is used to create a temporary div and loaded into the DOM tree.
202. The prompt text that needs to be displayed in the title is inserted into the div.
203. The total pixel width totalwidth of the prompt text is 3410px, the pixel width requiredwidth with which the prompt text can be displayed in the display interface is 320px at this time, and the number of lines num1 to be cut out of the prompt text is calculated to be 3410/320 to 10.65.
204. The total number of characters of the presentation text is 127, the number of characters num2 which the text needs to be cut is calculated from this, 127/10.65 which the number of characters num1 is 127/10.9, 11 which is relatively close to 11.9 is determined as the first number of characters, and then the first line feed position is positioned after "11 characters" of "nature", "time", "this", "i", "class", "d", "sign", "like", "referral", and "respectively.
Because the "i" and the "d" place the "javascript" and the "div" in the two full english names, if the line is changed at the two first line change positions, the english word can be detached, and the accuracy of the displayed result can be affected, therefore, the first line change position after the "i" and the "d" can be adaptively moved forward to the front of the two full english names of the "javascript" and the "div", but because in the application example, the first line change position is moved forward to the front of the "javascript", the "i" and the "d" can be obtained; js: the display line of the display interface can cause the final display interface to be unattractive, therefore, if the whole semantic meaning is not influenced, part of punctuations can be deleted, or the first line change position is adjusted under the condition of meeting the requirement of the pixel width displayed by the interface, so that part of punctuations can be attributed into the previous display line, and the first line change position is positioned in ' nature ', ' time ', '; "," t "," class "," of ","; 11 characters of "sign," "like," "referee," and "" are used herein.
205. When the text is prompted for "sex", "time", "this", ": "," class "," of "," the "," of; the "ends of the", "label", "elephant", "referral" and "perform wrapping, resulting in 11 head display lines and 1 tail display line.
11 header display behavior:
title: properties of elements
When the mouse is moved into an element
Displaying a section of tool prompt text;
js:javascipt
abbreviation, is a dynamic class
Type, weak type, based on prototypes
Language, built-in support type;
and div: label of one of pages
An element; and dom: document object
Model, W3C organization recommendation
For processing extensible markup language
1 tail shows behavior:
standard programming interface
206. Determining the first pixel width of each of the 11 head display lines as: 240px, 345px, 162px, 282px, 345px, 314px, 324px, 293px, 328px and 345 px.
207. Sequentially advancing the first line feed position at the tail end of each head display line with the first pixel width larger than the preset pixel width to obtain a second line feed position, so that the second pixel width of the N head display lines is not larger than the preset pixel width;
since the pixel width requiredwidth with which the prompt text display can be performed is 320px, the first display line with the first pixel width larger than the preset pixel width appears as follows: "when the mouse is moved into an element," will ", the" first line feed position of the end is advanced by one character when the mouse is moved into an element: ", when the mouse is moved to the element", the first pixel width of the head display line is changed to a second pixel width, and the second pixel width is 314, which meets the pixel display requirement of the display interface.
Displaying a section of tool-tip text when "the first line feed position of the end advances by one character when the mouse moves into the element, and the next head display line becomes"; "the pixel width corresponding to one character is increased compared to the previous first pixel width, and then" the time "displays a section of tool-tip text; "the first line feed position of the end advances by two characters, resulting in: when the tool-tip is displayed, the first pixel width of the head display line is changed into the second pixel width, and the second pixel width is 314, so that the pixel display requirement of the display interface is met.
Displaying a tooltip text when about; "after the first line feed position at the end advances by two characters, the next head display line becomes" this; js: javascript ", compared with the previous first pixel width, the pixel width corresponding to two characters is increased, at this time, the first pixel width of the head display line is changed into the second pixel width, the second pixel width is 222, the pixel display requirement of the display interface is still met, and the first line feed position does not need to be adjusted.
And so on, the first line feed position at the tail end of each head display line with the first pixel width larger than the preset pixel width is advanced in sequence to obtain a second line feed position, so that the second pixel widths of the N head display lines are not larger than the preset pixel width, and the final 11 head display behaviors are obtained:
title: properties of elements
When the mouse is moved into an element
Displaying a tool prompt text
Then, the process is carried out; js: javascript
Abbreviation, is a dynamic class
Type, weak type, based on prototype
Language of (2), built-in support type
(ii) a And div: label of one of pages
A label element; and dom: document pair
Image model, W3C tissue
Recommended processing extensible markup
The corresponding tail display line becomes:
standard programming interface for languages
The third number of characters of the tail display line is 9, the third number of characters is not greater than the first number of characters, and the width of the fourth pixel of the tail display line is smaller than the preset pixel width, so that the tail display line does not need to be adjusted.
In the embodiment of the application, after the first line feed position at the tail end of the head display line is adjusted in an advance mode, the tail display line is correspondingly increased, and if the number of third characters of the tail display line is greater than the first character number and the width of a fourth pixel of the tail display line is greater than the preset pixel width, M third line feed positions of the tail display line are determined; executing line feed at M third line feed positions of the tail display line to obtain M +1 first tail sub-display lines, wherein the fifth pixel width of each first tail sub-display line is not more than the preset pixel width, and M is an integer greater than or equal to 1; or
If the third number of characters of the tail display line is not more than the first number of characters and the fourth pixel width of the tail display line is more than the preset pixel width, determining M third line feed positions of the tail display line;
and performing line feed at a fourth line feed position of the tail display line to obtain a first head sub-display line and a second tail sub-display line, wherein a fifth pixel width of the first head sub-display line and a sixth pixel width of the second tail sub-display line are not greater than the preset pixel width.
In the embodiment of the application, when the prompt text is displayed, on the basis of executing line changing at the N first line changing positions, the line changing position at the tail end of the display line with the pixel width larger than the preset pixel width is adjusted, so that the pixel width of the N initial display lines is not larger than the preset pixel width, the pixel width of the head display line is ensured to be within the preset range, and the integrity of the display result is improved to a certain extent.
Optionally, on the basis of the first embodiment corresponding to fig. 1, in a sixth optional embodiment of the prompt text processing method according to the embodiment of the present invention, if the first pixel width of the head display line is greater than the preset pixel width, advancing the first line feed position at the end of the head display line to obtain a second line feed position, so that the second pixel width of the head display line is not greater than the preset pixel width may include:
sequentially and circularly executing the first circular line-feed strategy and the second circular line-feed strategy until the second pixel width of the head display line is not more than the preset pixel width and the seventh pixel width of the tail display line is not more than the preset pixel width;
the first round-robin routing policy is configured to:
if the first pixel width of the head display line is larger than the preset pixel width, advancing the first line feed position at the tail end of the head display line to obtain a second line feed position, so that the second pixel width of the head display line is not larger than the preset pixel width;
the second round-robin routing policy is configured to:
when the seventh pixel width is larger than the preset pixel width, executing line changing at a fifth line changing position of the tail display line to obtain a second head sub display line and a third tail sub display line, updating the second head sub display line into the head display line, and updating the third tail sub display line into the tail display line;
correspondingly, the line feed is executed at the second line feed position of the prompt text, and the line feed comprises the following steps:
and performing line feed at the second line feed position and the fifth line feed position of the prompt text.
In the embodiment of the application, another line feed position positioning strategy is provided, and when the line pre-division is performed, N first line feed positions are not positioned at one time, but after each first line feed position is positioned, the pixel width of a head display line is adjusted first, and then the next first line feed position is positioned.
In the embodiment of the application, specifically, at the first line feed position of the positioning prompt text, line feed is executed at the first line feed position of the prompt text according to the text prompt instruction to obtain a head display line and a tail display line, and then the first loop strategy and the second loop strategy are executed in a loop mode in sequence until the second pixel width of the head display line is not greater than the preset pixel width and the seventh pixel width of the tail display line is not greater than the preset pixel width. It should be noted that the sequential loop-through execution is understood to be that the first loop-through policy is executed first, then the second loop-through policy is executed, then the first loop-through policy is executed in sequence, then the second loop-through policy is executed, until a loop termination condition is met, and then the loop is ended.
In an embodiment of the present application, the first round-robin routing policy is configured to: if the first pixel width of the head display line is larger than the preset pixel width, the first line feed position at the tail end of the head display line is advanced to obtain a second line feed position, so that the second pixel width of the head display line is not larger than the preset pixel width.
In the embodiment of the present application, if the first pixel width of the head display line is greater than the preset pixel width, the first line feed position at the end of the head display line is advanced, where how to advance the first line feed position at the end of the head display line may refer to the manner in the above embodiment, and details are not repeated here. After the pixel width adjustment strategy of the head display line is executed, the head display line meets the display requirement of the interface pixel width, if the pixel width of the tail display line meets the display requirement of the interface pixel width at the moment, namely the second pixel width of the head display line is not more than the preset pixel width, and the seventh pixel width of the tail display line is not more than the preset pixel width, the cycle is ended, and the display line meeting the display requirement of the interface pixel width is obtained. It can be understood that, if the pixel width of the tail display line does not meet the display requirement of the interface pixel width, the pixel width of the tail display line is adjusted through the second loop-by-loop line-feed strategy. It is understood that the first loop wrapping strategy can be implemented to obtain the following two results:
1. the second pixel width of the head display line is not more than the preset pixel width, and the seventh pixel width of the tail display line is not more than the preset pixel width;
2. the second pixel width of the head display line is not more than the preset pixel width, and the seventh pixel width of the tail display line is more than the preset pixel width;
if the first result is that the second pixel width of the head display line is not greater than the preset pixel width, and the seventh pixel width of the tail display line is not greater than the preset pixel width, the cycle is directly ended without continuously executing the second cycle line strategy, and the display line meeting the interface pixel width display requirement can be obtained.
If the second result is that the second pixel width of the head display line is not greater than the preset pixel width and the seventh pixel width of the tail display line is greater than the preset pixel width, a second loop strategy is executed.
In an embodiment of the present application, the second round-robin routing policy is configured to: and when the seventh pixel width is larger than the preset pixel width, executing line changing at a fifth line changing position of the tail display line to obtain a second head sub display line and a third tail sub display line, updating the second head sub display line into the head display line, and updating the third tail sub display line into the tail display line. In this embodiment of the present application, when the pixel width of the tail display line does not meet the display requirement of the interface pixel width, the tail display line needs to be split, it can be understood that, after the tail display line is split, a new second head sub-display line and a third tail sub-display line can be obtained, where the pixel widths of the second head sub-display line and the third tail sub-display line are both smaller than the original tail display line, at this time, the second head sub-display line and the third tail sub-display line are determined as the new head display line and the tail display line, if the pixel width adjustment policy of the head display line can be continuously executed, it can be understood that, after the second loop wrapping policy is executed, the following four results can be obtained:
1. the second pixel width of the head display line is not more than the preset pixel width, and the seventh pixel width of the tail display line is not more than the preset pixel width;
2. the second pixel width of the head display line is not more than the preset pixel width, and the seventh pixel width of the tail display line is more than the preset pixel width;
3. the second pixel width of the head display line is greater than the preset pixel width, and the seventh pixel width of the tail display line is not greater than the preset pixel width;
4. the second pixel width of the head display line is greater than the preset pixel width, and the seventh pixel width of the tail display line is greater than the preset pixel width.
If the first result is that the second pixel width of the head display line is not greater than the preset pixel width, and the seventh pixel width of the tail display line is not greater than the preset pixel width, the cycle is directly ended without continuously executing the first cycle line strategy, and the display line meeting the interface pixel width display requirement can be obtained.
If the second result is that the second pixel width of the head display line is not greater than the preset pixel width and the seventh pixel width of the tail display line is greater than the preset pixel width, a second loop strategy is executed.
And if the third result and the fourth result are obtained, executing a first line feed strategy.
In the embodiment of the application, after the division of the head display line is completed, when the tail display line does not meet the pixel display requirement of the display interface, the tail display line is further divided, the tail display line is divided into a new head display line and a new tail display line, and the first circular line change strategy and the second circular line change strategy are circularly executed, so that the display line meeting the display requirement of the interface pixel width can be obtained, the pixel widths of the head display line and the tail display line are ensured to be within a preset range, and the integrity of the display result is improved to a certain extent.
For convenience of understanding, the method for processing the prompt text will be described below through a specific flow, please refer to fig. 3, where fig. 3 is a schematic flow diagram of the prompt text processing in the application scenario of the present invention, and as shown in the figure, specifically:
taking the prompt text as "title: attribute of the element, when the mouse moves to the element, displaying a section of tool-tip text; js: the abbreviation javascript is a dynamic type, weak type, prototype-based language, and has a built-in support type; and div: a tag element of one of the pages; and dom: the document object model is explained by taking a standard programming interface for processing extensible markup language recommended by the organization of W3C as an example:
301. when the coordinate point position of the mouse is near the target element with the text prompt attribute, js is used to create a temporary div and loaded into the DOM tree.
302. The prompt text that needs to be displayed in the title is inserted into the div.
303. The total pixel width totalwidth of the prompt text is 3410px, the pixel width requiredwidth with which the prompt text can be displayed in the display interface is 320px at this time, and the number of lines num1 to be cut out of the prompt text is calculated to be 3410/320 to 10.65.
304. The total number of characters of the prompt text is length 127, the number of characters to be cut of the text, num2 length/num1 127/10.65, 11.9, is calculated according to the total number of characters, 11 which is closer to 11.9 is determined as a first number of characters, and then the first line feed position is positioned after the characters are 'nature'.
305. And performing line feed after the 'nature' of the prompt text to obtain a head display line and a tail display line.
Header display behavior:
title: properties of elements
Tail display behavior:
when the mouse moves to the element, displaying a section of tool prompt text; js: the abbreviation javascript is a dynamic type, weak type, prototype-based language, and has a built-in support type; and div: a tag element of one of the pages; and dom: the document object model is a standard programming interface for processing extensible markup language recommended by W3C organization
306. Executing a first loop strategy: determining a first pixel width of the header display line as: 240px, when the first pixel width of the head display line is not greater than the preset pixel width.
307. Executing a second loop strategy: and when the pixel width of the tail display line is larger than the preset pixel width, executing line changing at the fifth line changing position of the tail display line to obtain a second head sub display line and a third tail sub display line, updating the second head sub display line into the head display line, updating the third tail sub display line into the tail display line, and returning to execute the first circulation strategy.
In this application example, the fifth line feed position is located at the end of the tail display line at intervals of 11 characters, and at this time, the second head sub-display line:
when the mouse is moved into an element
The third tail child shows behavior:
displaying a tool prompt text; js: the abbreviation javascript is a dynamic type, weak type, prototype-based language, and has a built-in support type; and div: a tag element of one of the pages; and dom: the document object model is a standard programming interface for the W3C organization to process the extensible markup language recommendation.
The second head display line "is determined to be a new head display line when the mouse is moved into the element, the third tail display line is determined to be a new tail display line, and the new head display line and the tail display line are brought into the first loop strategy.
308. And repeating the steps until the second pixel width of the head display line is not more than the preset pixel width and the seventh pixel width of the tail display line is not more than the preset pixel width to obtain the final head display line:
title: properties of elements
When the mouse is moved into an element
Displaying a tool prompt text
Then, the process is carried out; js: javascript
Abbreviation, is a dynamic class
Type, weak type, based on prototype
Language of (2), built-in support type
(ii) a And div: label of one of pages
A label element; and dom: document pair
Image model, W3C tissue
Recommended processing extensible markup
The corresponding tail shows behavior:
standard programming interface for languages
309. The loop is ended.
In the embodiment of the application, when the prompt text is displayed, on the basis of executing line changing at the N first line changing positions, the line changing position at the tail end of the display line with the pixel width larger than the preset pixel width is adjusted, so that the pixel width of the N initial display lines is not larger than the preset pixel width, the pixel width of the head display line is ensured to be within the preset range, and the integrity of the display result is improved to a certain extent.
Referring to fig. 4, fig. 4 is a schematic view of an embodiment of a prompt text processing apparatus according to an embodiment of the present invention, and the prompt text processing apparatus includes:
a receiving module 401, configured to receive a text prompt instruction, where the text prompt instruction is used to locate a first line feed position of a prompt text;
a first processing module 402, configured to execute line feed at a first line feed position of the prompt text according to the text prompt instruction received by the receiving module 401, to obtain a header display line;
a second processing module 403, configured to advance a first line feed position at an end of the head display line to obtain a second line feed position if the first pixel width of the head display line obtained by the first processing module is greater than a preset pixel width;
and a third processing module 404, configured to execute line feed at the second line feed position obtained by the second processing module of the prompt text.
In this embodiment, the receiving module 401 receives a text prompt instruction, where the text prompt instruction is used to locate a first line feed position of a prompt text, the first processing module 402 performs line feed at the first line feed position of the prompt text according to the text prompt instruction received by the receiving module 401 to obtain a head display line, if a first pixel width of the head display line obtained by the first processing module is greater than a preset pixel width, the second processing module 403 advances the first line feed position at the end of the head display line to obtain a second line feed position, and the third processing module 404 performs line feed at the second line feed position obtained by the second processing module of the prompt text.
In the embodiment of the present application, a device for processing a prompt text is provided, where a receiving module 401 receives a text prompt instruction, where the text prompt instruction is used to locate a first line change position of a prompt text, a first processing module 402 executes line change at the first line change position of the prompt text according to the text prompt instruction received by the receiving module 401 to obtain a head display line, if a first pixel width of the head display line obtained by the first processing module is greater than a preset pixel width, a second processing module 403 advances the first line change position at the end of the head display line to obtain a second line change position, and a third processing module 404 executes line change at the second line change position obtained by the second processing module of the prompt text. Through the mode, when the prompt text is displayed, on the basis of line changing executed at the first line changing position, the line changing position at the tail end of the display line with the pixel width larger than the preset pixel width is adjusted, so that the pixel width of the initial display line is not larger than the preset pixel width, the pixel width of the head display line is ensured to be within the preset range, and the integrity of the display result is improved to a certain extent.
Optionally, on the basis of the embodiment corresponding to fig. 4, in another embodiment of the device for processing prompt text provided in the embodiment of the present invention,
a first processing module 402, specifically configured to determine N first line feed positions in a prompt text according to a text prompt instruction;
line feed is executed at N first line feed positions of the prompt text to obtain N first preliminary display lines and a tail display line, the number of prompt text characters of each first preliminary display line is a first character number, the number of prompt text characters of the tail display line is a second character number, the first character number is not less than the second character number, and N is an integer greater than 1.
In the embodiment of the application, the number of the first line feed positions is multiple, the number of the characters between the first line feed positions is the first number of characters, the first number of characters is not less than the second number of characters of the tail display line, the number of the estimated optimal line feed positions is changed into multiple, and the pixel width of the tail display line can be reduced when the pixel width of the prompt text is too long.
Optionally, on the basis of the embodiment corresponding to fig. 4, please refer to fig. 5, in another embodiment of the prompt text processing apparatus according to the embodiment of the present invention, the prompt text processing apparatus further includes an obtaining module 501;
the obtaining module 501 is configured to obtain a third pixel width and a preset pixel width of the prompt text, and determine a ratio of the third pixel width to the preset pixel width as a clipping line number;
and acquiring a second character number of the prompt text, and determining a first character number according to the second character number, wherein the tail of the first character number is in a preset range of the ratio of the second character number to the interception line number.
In the embodiment of the application, in the selection of the first number of characters at the first line-changing position in the line pre-changing, the ratio of the pixel width of the prompt text to the preset pixel width preferred by the display interface is used as the number of pre-intercepting lines, and the first number of characters is determined to be within the preset range of the ratio of the number of characters of the prompt text to the number of intercepting lines, so that the prompt text after line pre-changing is close to the final line-dividing result, the subsequent adjusting times can be reduced, and the processing efficiency is improved.
Optionally, on the basis of the embodiment corresponding to fig. 4, in another embodiment of the device for processing prompt text provided in the embodiment of the present invention,
a second processing module 403, specifically configured to determine a first pixel width of each of the N header display lines;
and sequentially advancing the first line feed position at the tail end of the head display line with each first pixel width larger than the preset pixel width to obtain N second line feed positions.
In the embodiment of the application, the number of the first line feed positions is multiple, the number of the characters between the first line feed positions is the first number of characters, the first number of characters is not less than the second number of characters of the tail display line, the number of the estimated optimal line feed positions is changed into multiple, and the pixel width of the tail display line can be reduced when the pixel width of the prompt text is too long.
Optionally, on the basis of the embodiment corresponding to fig. 3, please refer to fig. 6, in another embodiment of the prompt text processing apparatus according to the embodiment of the present invention, the prompt text processing apparatus further includes a fourth processing module 601;
the fourth processing module 601 is specifically configured to determine M third line feed positions of the tail display line if the third number of characters of the tail display line is greater than the first number of characters and the fourth pixel width of the tail display line is greater than the preset pixel width;
and performing line feed at M third line feed positions of the tail display line to obtain M +1 first tail sub-display lines, wherein the fifth pixel width of each first tail sub-display line is not more than the preset pixel width, and M is an integer greater than or equal to 1.
Correspondingly, the third processing module 404 is specifically configured to: and performing line feed at N second line feed positions and M third line feed positions of the prompt text.
In the embodiment of the application, after the division of the head display line is completed, when the tail display line does not meet the pixel display requirement of the display interface, the division is further performed on the tail display line, and the pixel width of each tail sub-display line is adjusted, so that the pixel widths of the head display line and the tail display line are ensured to be within a preset range, and the integrity of the display result is improved to a certain extent.
Optionally, on the basis of the embodiment corresponding to fig. 3, in another embodiment of the device for processing prompt text provided in the embodiment of the present invention, the device for processing prompt text further includes a fourth processing module 601;
the fourth processing module 601 is configured to determine a fourth line feed position of the tail display line if the third number of characters of the tail display line is not greater than the first number of characters and the fourth pixel width of the tail display line is greater than the preset pixel width;
performing line feed at a fourth line feed position of the tail display line to obtain a first head sub-display line and a second tail sub-display line, wherein the fifth pixel width and the sixth pixel width of the first head sub-display line are not more than the preset pixel width;
correspondingly, the third processing module 404 is specifically configured to: and performing line feed at N second line feed positions and a fourth line feed position of the prompt text.
In the embodiment of the application, after the division of the head display line is completed, when the tail display line does not meet the pixel display requirement of the display interface, the tail display line is further divided, and the widths of the first head sub-display line and the first head sub-display line after the division are adjusted, so that the widths of the pixels of the head display line and the tail display line are ensured to be within a preset range, and the integrity of the display result is improved to a certain extent.
Optionally, on the basis of the embodiment corresponding to fig. 4, in another embodiment of the device for processing prompt text provided in the embodiment of the present invention,
the first processing module 402 is specifically configured to sequentially and cyclically execute the first loop linefeed strategy and the second loop linefeed strategy until the second pixel width of the head display line is not greater than the preset pixel width and the seventh pixel width of the tail display line is not greater than the preset pixel width;
the first round-robin routing policy is configured to:
if the first pixel width of the head display line is larger than the preset pixel width, advancing the first line feed position at the tail end of the head display line to obtain a second line feed position, so that the second pixel width of the head display line is not larger than the preset pixel width;
the second round-robin routing policy is configured to:
when the seventh pixel width is larger than the preset pixel width, executing line changing at a fifth line changing position of the tail display line to obtain a second head sub display line and a third tail sub display line, updating the second head sub display line into the head display line, and updating the third tail sub display line into the tail display line;
correspondingly, the fourth processing module is specifically configured to: and performing line feed at the second line feed position and the fifth line feed position of the prompt text.
In the embodiment of the application, after the division of the head display line is completed, when the tail display line does not meet the pixel display requirement of the display interface, the tail display line is further divided, the tail display line is divided into a new head display line and a new tail display line, and the first circular line change strategy and the second circular line change strategy are circularly executed, so that the display line meeting the display requirement of the interface pixel width can be obtained, the pixel widths of the head display line and the tail display line are ensured to be within a preset range, and the integrity of the display result is improved to a certain extent.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (7)

1. A method for processing prompt text, comprising:
receiving a text prompt instruction, wherein the text prompt instruction is used for positioning a first line feed position of a prompt text;
acquiring a third pixel width and a preset pixel width of a prompt text, and determining the ratio of the third pixel width to the preset pixel width as the number of interception lines;
acquiring a second number of characters of the prompt text, and determining a first number of characters according to the second number of characters, wherein the tail of the first number of characters is within a preset range of a ratio of the second number of characters to the number of intercepted lines;
executing line feed at the first line feed position of the prompt text according to the text prompt instruction to obtain a head display line;
if the first pixel width of the head display line is greater than the preset pixel width, advancing the first line feed position at the tail end of the head display line to obtain a second line feed position, wherein if the first pixel width of the head display line is greater than the preset pixel width, advancing the first line feed position at the tail end of the head display line to obtain the second line feed position comprises: determining the first pixel width of each head display line in the N head display lines, and sequentially advancing the first line feed position at the tail end of the head display line with the first pixel width larger than the preset pixel width to obtain N second line feed positions;
if the third number of characters of the tail display line is larger than the first number of characters and the fourth pixel width of the tail display line is larger than the preset pixel width, determining M third line feed positions of the tail display line;
executing line feed on the M third line feed positions of the tail display line to obtain M +1 first tail sub-display lines, wherein the fifth pixel width of each first tail sub-display line is not greater than the preset pixel width, and M is an integer greater than or equal to 1;
performing line feed at the second line feed location of the prompt text, wherein performing line feed at the second line feed location of the prompt text comprises: and executing line feed at the N second line feed positions and the M third line feed positions of the prompt text.
2. The method of claim 1, wherein performing line wrapping at the first line wrapping position in the prompt text according to the text prompt instruction, and wherein obtaining a head display line comprises:
determining N first line feed positions in the prompt text according to the text prompt instruction;
n of the prompt text execute line feed on the first line feed position to obtain N first preliminary display lines and a tail display line, each the prompt text character number of the first preliminary display line is a first character number, the prompt text character number of the tail display line is a second character number, the first character number is not less than the second character number, and N is an integer greater than 1.
3. The method of claim 1, wherein the sequentially advancing the first line feed position at the end of the head display line with each first pixel width larger than the preset pixel width to obtain the second line feed position further comprises:
if the third number of characters of the tail display line is not greater than the first number of characters and the fourth pixel width of the tail display line is greater than the preset pixel width, determining a fourth line feed position of the tail display line;
executing line feed at a fourth line feed position of the tail display line to obtain a first head sub-display line and a second tail sub-display line, wherein a fifth pixel width and a sixth pixel width of the first head sub-display line are not greater than the preset pixel width;
correspondingly, the performing line feed at the second line feed position of the prompt text further includes:
and executing line feed at the N second line feed positions and the fourth line feed position of the prompt text.
4. The method of claim 1, wherein if the first pixel width of the head display line is greater than the predetermined pixel width, advancing the first line feed position at the end of the head display line to obtain a second line feed position, further comprising:
sequentially and circularly executing a first circular line-feed strategy and a second circular line-feed strategy until the second pixel width of the head display line is not more than the preset pixel width and the seventh pixel width of the tail display line is not more than the preset pixel width;
the first round-robin routing policy is configured to:
if the first pixel width of the head display line is larger than the preset pixel width, advancing the first line changing position at the tail end of the head display line to obtain a second line changing position, so that the second pixel width of the head display line is not larger than the preset pixel width;
the second round-robin routing policy is configured to:
when the seventh pixel width is larger than the preset pixel width, executing line feed at a fifth line feed position of the tail display line to obtain a second head sub display line and a third tail sub display line, updating the second head sub display line to the head display line, and updating the third tail sub display line to the tail display line;
correspondingly, the performing line feed at the second line feed position of the prompt text includes:
and executing line feed at the second line feed position and the fifth line feed position of the prompt text.
5. A prompt text processing apparatus characterized by comprising:
the receiving module is used for receiving a text prompting instruction, and the text prompting instruction is used for positioning a first line feed position of a prompting text;
the processing module is used for acquiring a third pixel width and a preset pixel width of the prompt text and determining the ratio of the third pixel width to the preset pixel width as the number of interception lines;
the processing module is further configured to obtain a second number of characters of the prompt text, determine a first number of characters according to the second number of characters, and determine that the first number of characters is within a preset range of a ratio of the second number of characters to the number of intercepted lines;
the processing module is further configured to execute line feed at the first line feed position of the prompt text according to the text prompt instruction to obtain a header display line;
the processing module is further configured to advance a first line feed position at the end of the header display line to obtain a second line feed position when the first pixel width of the header display line is greater than a preset pixel width, wherein if the first pixel width of the header display line is greater than the preset pixel width, the advance the first line feed position at the end of the header display line to obtain the second line feed position includes: determining the first pixel width of each head display line in the N head display lines, and sequentially advancing the first line feed position at the tail end of the head display line with the first pixel width larger than the preset pixel width to obtain N second line feed positions;
the processing module is further configured to determine M third line feed positions of the tail display line when a third number of characters of the tail display line is greater than the first number of characters and a fourth pixel width of the tail display line is greater than the preset pixel width;
the processing module is further configured to perform line feed at the M third line feed positions of the tail display line to obtain M +1 first tail sub-display lines, where a fifth pixel width of each first tail sub-display line is not greater than the preset pixel width, and M is an integer greater than or equal to 1;
the processing module is further configured to execute line feed at the N second line feed positions and the M third line feed positions of the prompt text.
6. The device of claim 5, wherein the processing module is further configured to:
determining N first line feed positions in the prompt text according to the text prompt instruction received by the receiving module;
n of the prompt text execute line feed on the first line feed position to obtain N first preliminary display lines and a tail display line, each the prompt text character number of the first preliminary display line is a first character number, the prompt text character number of the tail display line is a second character number, the first character number is not less than the second character number, and N is an integer greater than 1.
7. A computer-readable storage medium comprising instructions that, when executed on a computer, cause the computer to perform the method of any of claims 1 to 4.
CN201811042800.4A 2018-09-06 2018-09-06 Prompt text processing method and device and computer readable storage medium Active CN109284481B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811042800.4A CN109284481B (en) 2018-09-06 2018-09-06 Prompt text processing method and device and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811042800.4A CN109284481B (en) 2018-09-06 2018-09-06 Prompt text processing method and device and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN109284481A CN109284481A (en) 2019-01-29
CN109284481B true CN109284481B (en) 2021-11-19

Family

ID=65183808

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811042800.4A Active CN109284481B (en) 2018-09-06 2018-09-06 Prompt text processing method and device and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN109284481B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113705190A (en) * 2021-09-02 2021-11-26 北京字节跳动网络技术有限公司 Text processing method, device and equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102057369A (en) * 2008-04-15 2011-05-11 Opera软件股份公司 Method and device for dynamically wrapping text when displaying a selected region of an electronic document
CN106331828A (en) * 2016-08-19 2017-01-11 暴风集团股份有限公司 Method and system for adjusting subtitle according to picture
CN106873925A (en) * 2015-12-10 2017-06-20 北京国双科技有限公司 The display methods and device of label text
CN107783946A (en) * 2016-08-27 2018-03-09 上海卓易电子科技有限公司 Text display method and text display

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7219309B2 (en) * 2001-05-02 2007-05-15 Bitstream Inc. Innovations for the display of web pages

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102057369A (en) * 2008-04-15 2011-05-11 Opera软件股份公司 Method and device for dynamically wrapping text when displaying a selected region of an electronic document
CN106873925A (en) * 2015-12-10 2017-06-20 北京国双科技有限公司 The display methods and device of label text
CN106331828A (en) * 2016-08-19 2017-01-11 暴风集团股份有限公司 Method and system for adjusting subtitle according to picture
CN107783946A (en) * 2016-08-27 2018-03-09 上海卓易电子科技有限公司 Text display method and text display

Also Published As

Publication number Publication date
CN109284481A (en) 2019-01-29

Similar Documents

Publication Publication Date Title
EP3399721B1 (en) Interface data displaying method and device
US10210144B2 (en) Creation and display of a webpage with alternative layouts for different webpage widths
CN105094804B (en) The method and apparatus of animation are added in the page
US10902508B2 (en) Methods for extracting and adapting information to generate custom widgets and devices thereof
CN105205080B (en) Redundant file method for cleaning, device and system
US9229915B2 (en) Extended cascading style sheets
JP6606304B2 (en) Fixed native document comments in preview
US20170315982A1 (en) Method, device and mobile terminal for webpage text parsing
CN109725965A (en) Cascading style listing maintenance, device, computer equipment and storage medium
EP3156919A1 (en) Methods for transforming a server side template into a client side template and devices thereof
CN111831384A (en) Language switching method and device, equipment and storage medium
CN110990010A (en) Software interface code generation method and device
US20180113858A1 (en) Interface layout interference detection
WO2015057457A1 (en) Systems and methods to segment text for layout and rendering
CN109284481B (en) Prompt text processing method and device and computer readable storage medium
CN105205077A (en) Page layout method, device and system
CN108694043B (en) Page decoration method and system
CA2602749C (en) System and method of report representation
CN110083845B (en) Webpage translation method and system
US9594737B2 (en) Natural language-aided hypertext document authoring
CN109726346B (en) Page component processing method and device
CN113807048B (en) Method, device, terminal and storage medium for self-adapting to character width
CN111914226A (en) Background picture generation method and device
CN107085578B (en) Webpage editing method and device
CN112445474B (en) Display method for long text file name and storage medium

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