WO2016023509A1 - 呈现文件的方法和文件呈现装置 - Google Patents

呈现文件的方法和文件呈现装置 Download PDF

Info

Publication number
WO2016023509A1
WO2016023509A1 PCT/CN2015/086875 CN2015086875W WO2016023509A1 WO 2016023509 A1 WO2016023509 A1 WO 2016023509A1 CN 2015086875 W CN2015086875 W CN 2015086875W WO 2016023509 A1 WO2016023509 A1 WO 2016023509A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
block
file block
memory
content
Prior art date
Application number
PCT/CN2015/086875
Other languages
English (en)
French (fr)
Inventor
裴廷斌
Original Assignee
北京配天技术有限公司
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 北京配天技术有限公司 filed Critical 北京配天技术有限公司
Publication of WO2016023509A1 publication Critical patent/WO2016023509A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/168Details of user interfaces specifically adapted to file systems, e.g. browsing and visualisation, 2d or 3d GUIs

Definitions

  • the present invention relates to the field of file processing, and in particular, to a method and a file presentation apparatus for presenting a file.
  • the text editing software Gedit used in the Ubuntu system uses a method of sampling a large-capacity text file into a memory in batches, and the method is performed every time.
  • the content of a part of the text file is loaded for a period of time, and the content of the text file loaded into the memory is instantly presented to the user in a "load-and-display" manner.
  • this method can reduce the loading time of large-capacity text into zero, shorten the waiting time of users.
  • the entire contents of the text file will still be loaded into the memory, which still consumes a large amount of memory resources.
  • the technical problem to be solved by the present invention is to provide a method for presenting a file and a file presentation device, which can effectively reduce the occupation of system memory resources when a large-capacity file is presented without affecting the user experience.
  • the present invention provides a method for presenting a file, including:
  • the first file block is moved out of the memory and the file block adjacent to the first file block is loaded into the memory and rendered.
  • the file to be presented is divided into a plurality of file blocks, wherein the step of partially overlapping the contents of the adjacent file blocks is specifically: dividing the file into a plurality of file blocks according to a predetermined file block size, wherein the latter file block is The file content of the first 1/N area is the same as the file content of the last 1/N area of the previous file block; N is a predetermined constant.
  • the step of moving the first file block out of the memory and loading the file block adjacent to the first file block into the memory and presenting includes:
  • the first file block is moved out of the memory and the previous file block is loaded into the memory and presented;
  • the first file block is moved out of the memory and the next file block is loaded into the memory and presented;
  • 1/N is greater than or equal to 1/M+1/L.
  • the first 1/M area of the first file block and the back 1/L area of the first file block are both greater than or equal to a maximum range that causes the cursor to move.
  • the determining whether the currently displayed display area is located in the predetermined area of the first file block includes determining whether the cursor position input by the user is located in a predetermined area of the first file block.
  • file is an editable file
  • the method further includes:
  • the step of saving the content of the file in which the first file block is changed is specifically as follows:
  • the temporary file is named with the file name of the file to be rendered.
  • the present invention also provides a method for presenting a file, including:
  • the first file block is moved out of the memory and the file block adjacent to the first file block is loaded into the memory and rendered.
  • the step of dividing the file to be presented into multiple file blocks, wherein the content of the adjacent file blocks partially overlap is:
  • the file is divided into a plurality of file blocks according to a predetermined file block size, wherein the file content of the first 1/N area of the latter file block is the same as the file content of the last 1/N area of the previous file block; N is a predetermined constant .
  • the step of moving the first file block out of the memory and loading the file block adjacent to the first file block into the memory and presenting includes:
  • the first file block is moved out of the memory and the previous file block is loaded into the memory and presented;
  • the first file block is moved out of the memory and the next file block is loaded into the memory and presented;
  • 1/N is greater than or equal to 1/M+1/L.
  • the determining whether the currently displayed display area is located in a predetermined area of the first file block includes:
  • file is an editable file
  • the method further includes:
  • the step of saving the content of the file in which the first file block is changed is specifically as follows:
  • the temporary file is named with the file name of the file to be rendered.
  • the present invention also provides a file presentation apparatus, including:
  • a dividing module configured to divide the file to be rendered into a plurality of file blocks, wherein content of the adjacent file blocks partially overlaps
  • a rendering module configured to load the first file block into the memory, and present the first file block, where the first file block is a file block that needs to be currently rendered;
  • a first determining module configured to determine whether the currently displayed display area is located in a predetermined area of the first file block
  • a switching module configured to: when the currently displayed display area is located in a predetermined area of the first file block, move the first file block out of the memory and load the file block adjacent to the first file block into the memory and present.
  • the dividing module is configured to divide the file into multiple file blocks according to a predetermined file block size, wherein the file content of the first 1/N area of the latter file block is the same as the file content of the last 1/N area of the previous file block. ; N is a predetermined constant.
  • the switching module is used to:
  • the first file block is moved out of the memory and the previous file block is loaded into the memory and presented;
  • the first file block is moved out of the memory and the next file block is loaded into the memory and presented;
  • 1/N is greater than or equal to 1/M+1/L.
  • the first determining module is configured to determine whether the cursor position input by the user is located in a predetermined area of the first file block.
  • the file rendering device further comprises:
  • a second determining module configured to determine the first file before the first file block is moved out of the memory and the file block adjacent to the first file block is loaded into the memory and presented, if the cursor position is in a predetermined area of the first file block Whether the file content of the block has changed;
  • a saving module if the file content of the first file block is changed
  • the save module is used to:
  • the present invention also provides a file presentation apparatus, including:
  • processors a memory, and a data bus
  • the processor and the memory are respectively connected to the data bus for data interactive communication through the data bus
  • the memory is used to store files, and the processor is configured to perform the following steps:
  • the first file block is moved out of the memory and the file block adjacent to the first file block is loaded into the memory and rendered.
  • the processor is configured to divide the file into multiple file blocks according to a predetermined file block size, where the file content of the first 1/N area of the latter file block is the same as the file content of the last 1/N area of the previous file block; N is a predetermined constant.
  • the processor is used to:
  • the first file block is moved out of the memory and the previous file block is loaded into the memory and presented;
  • the first file block is moved out of the memory and the next file block is loaded into the memory and presented;
  • 1/N is greater than or equal to 1/M+1/L.
  • the processor is configured to determine whether the cursor position input by the user is located in a predetermined area of the first file block.
  • the processor is further used to:
  • the cursor position is in a predetermined area of the first file block, determining whether the file content of the first file block changes before moving the first file block out of the memory and loading the file block adjacent to the first file block into the memory and presenting ;
  • the processor is used to:
  • the beneficial effects of the present invention are: by dividing the file to be presented into multiple file blocks and loading and rendering only one of the file blocks, the system memory resources can be effectively reduced when the large-capacity file is presented. Occupied, and due to the partial overlap of adjacent file blocks, smooth switching of adjacent file blocks can be achieved, and the user experience is improved.
  • FIG. 1 is a schematic diagram of a method for presenting a file in the prior art
  • FIG. 2 is a schematic flow chart of a method for presenting a file according to a first embodiment of the present invention
  • Figure 3 is a schematic diagram of file division in the first embodiment of the present invention.
  • FIG. 4 is a schematic diagram of a file block loaded into a memory in the first embodiment of the present invention.
  • FIG. 5 is a schematic diagram of file block switching in the first embodiment of the present invention.
  • FIG. 6 is a schematic flow chart of file saving in the first embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of a file presentation apparatus according to a first embodiment of the present invention.
  • Figure 8 is a block diagram showing the structure of a file presentation apparatus according to a second embodiment of the present invention.
  • FIG. 2 is a schematic flowchart of a method for presenting a file according to a first embodiment of the present invention. As shown in FIG. 2, the method for presenting a file of the first embodiment includes:
  • S10 Divide the file to be presented into a plurality of file blocks, wherein contents of adjacent file blocks partially overlap.
  • the file to be presented may be divided into multiple file blocks of the same capacity, or may be files blocks of different capacities.
  • the same capacity means that the file areas occupied by the plurality of file blocks are the same size. That is, the files are divided into multiple file blocks of the same size according to the same capacity.
  • S11 Loading the first file block into the memory, and presenting the first file block, where the first file block is a file block that needs to be currently rendered.
  • only one file block can be loaded into the memory at a time and presented to the user. Before loading a file block into memory, you need to move the file block that has been loaded into memory and is being presented to the user out of memory.
  • S12 Determine whether the currently displayed display area is located in a predetermined area of the first file block.
  • the first file block may have a plurality of predetermined areas, and the currently presented display areas perform different operations when they are located in different predetermined areas.
  • a file block located before the first file adjacent to the first file block may be loaded into the memory and presented, or the file adjacent to the first file block may be located before the first file.
  • the file block is loaded into memory and rendered.
  • the file may be divided into a plurality of file blocks according to a predetermined file block size, wherein the file content of the first 1/N area of the latter file block is the last 1 of the previous file block.
  • the contents of the /N area are the same; N is a predetermined constant.
  • the size of the overlapping portion of the content of the adjacent file blocks can be adjusted as needed, but should not be too large, that is, the predetermined constant N should not be too small, so that the file to be rendered is not too efficiently divided into multiple text blocks.
  • the file content of the first 2/3 area of the latter file block is the same as the file content of the last 2/3 area of the previous file block to ensure a smooth transition when switching between file blocks and file blocks.
  • the file block n+1 has 2/3 regions overlapping, specifically, the last 2/3 region of the file block n is the same as the file content of the first 2/3 region of the file block n+1. In this way, due to the partial overlap of adjacent file blocks, smooth switching of adjacent file blocks can be implemented, thereby improving the user experience.
  • the currently displayed display area may be the cursor position input by the user. That is, in S12, it is judged whether or not the cursor position input by the user is located in a predetermined area of the first file block.
  • the cursor position input by the user indicates the position where the user performs the touch screen or the key operation, and the key operation may include related keys for performing file editing, such as pressing the up and down direction keys, and pressing the pageup or pagedown keys.
  • Each file block is pre-divided into different area ranges, and the predetermined area of the file block to be presented refers to a certain area range of the different area of the file block partitioned for the loaded memory, which is relatively close to the adjacent file block.
  • the size of the predetermined area can be set as needed.
  • the first file block is moved out of the memory and the previous file block is loaded.
  • the memory is rendered; if the currently displayed display area is located in the back 1/L area of the first file block, the first file block is moved out of memory and the next file block is loaded into memory and rendered.
  • the first 1/M area of the first file block and the last 1/L area of the first file block are all predetermined areas of the first file block, where 1/N is greater than or equal to 1/M+1/L. Specifically, if the definition area A is to switch the file block to be presented to the predetermined area of the previous file block, the area B is to switch the file block to be presented to the predetermined area of the next file block, and the area C is the adjacent file block.
  • the overlapping area, the area S is the maximum range that causes the cursor to move in a single time.
  • area A and area B should be greater than or equal to area S, so as to avoid the problem that the file cursor is misaligned after switching the file block because the cursor movement range is beyond the current file block storage range; however, the range of area A and area B is not suitable. Too large, so as not to trigger the area where the file block is switched too small, and fall into the dilemma of frequently switching file blocks.
  • the area C needs to be greater than or equal to the area A+ area B, so that the cursor will be located in the A area or the B area of the new file block after switching to the new file block; however, the area C should not be too large, otherwise the file block may be caused. The division efficiency is too low.
  • the area A and the area B may take the following values: 1/10, 1/8, 1/6, 1/4, 1/3, etc.
  • the corresponding area C is taken as 1/5, 1/4, 1/3, 1/2, 2/3, etc., and only needs to satisfy the area A, the area B is greater than or equal to the area S, and the area C is greater than or It is equal to the area A+ area B.
  • the predetermined area is related to the maximum range in which the single button causes the cursor to move, and the maximum range in which the single button causes the cursor to move varies depending on the type of the button.
  • buttons PageUp and PageDown have a large moving range, for example, a dozen lines can be moved at a time
  • the maximum range of the cursor that can be moved by a single button is often determined by the range of the single movable cursor of the page PageUp and PageDown. For example, in the case of displaying a scroll bar, 15 lines of code can be displayed per page. Since the buttons PageUp and PageDown move the cursor one page at a time, S can be set to an area of approximately 15 lines of code.
  • one file block can be divided into three parts: a first 1/3 area, a middle 1/3 area, and a back 1/3 area, and the predetermined area refers to a file block to be presented.
  • X represents the cursor
  • the current file block is the file block to be rendered that has been loaded into memory.
  • a key operation that is, when editing the current file block
  • the cursor X is located in the first 1/3 area of the current file block, the current file block is moved out of the memory, and the previous file block is loaded into the memory and presented to the user. If the cursor X is in the last 1/3 of the current file block, the current file block is moved out of memory and the next file block is loaded into memory and presented to the user.
  • the file of the first file block is determined before the first file block is moved out of the memory and the file block adjacent to the first file block is loaded into the memory and presented. Whether the content has changed. If the file content of the first file block changes, the user is prompted whether to save the file content whose first file block has changed. Receiving an instruction input by the user to save or instruct to abandon the saved instruction; and saving the file content of the first file block according to the instruction saved by the instruction input by the user, or restoring the saved file according to the instruction input by the user to restore the first file block Original content.
  • all modifications made by the user to the current file are performed on the file block to be rendered currently loaded into the memory, so that only the file content of the file block to be rendered currently loaded into the memory is used.
  • the full text of the file can be saved by overwriting the contents of the file in the corresponding area of the original file. This requires that the file block to be rendered that has been loaded into memory cannot be misaligned when it is spliced with the portion of the file that has not been loaded into the memory, otherwise the file information will be lost. Therefore, it is necessary to accurately locate the boundary of the area of the file in the original file when the file is saved.
  • the starting position of the file block to be rendered is recorded (Start Position) and end position (Stop Position).
  • the current file block is the file block to be rendered that has been loaded into memory.
  • the starting position is the position of the starting point of the current file block in the full text of the file, that is, the offset generated by the file pointer moving from the beginning of the file to the beginning of the current file block.
  • the end position is the position of the current file block end point in the full text of the file, that is, the offset generated by the file pointer moving from the beginning of the file to the end of the current file block.
  • saving the file content that is changed by the first file block includes:
  • S140 Create a blank temporary file in the same directory as the file to be rendered.
  • S141 Write the first text content of the unloaded memory between the beginning of the file and the starting position of the first file block in the file to be rendered to the temporary file.
  • S142 Write the file content of the first file block to the temporary file, so that the file content whose first file block is changed and the first text content are sequentially connected in the temporary file.
  • S143 Write the file to be presented from the end position of the first file block in the file to be rendered to the second text content of the unloaded memory between the end of the file, to write the second text content to the first file.
  • the text content whose file block has changed is sequentially connected in the temporary file.
  • the text content that is changed when the first file block is changed is empty, and the file is not loaded into the memory from the beginning of the file to the start position.
  • a text content is directly linked to the second text content of the unloaded memory between the end of the file and the end of the file. After the save is completed, the start position and the end position will coincide with one point.
  • the file to be presented is divided into a plurality of file blocks, wherein content of the adjacent file blocks partially overlaps; the first file block is loaded into the memory, and the first file block is presented, first The file block is a file block that needs to be presented currently; determining whether the currently displayed display area is located in a predetermined area of the first file block; if the currently displayed display area is located in a predetermined area of the first file block, moving the first file block out of the memory and The file block adjacent to the first file block is loaded into the memory and rendered, which can effectively reduce the occupation of the system memory resources when the large-capacity text file is presented without affecting the user experience.
  • FIG. 7 is a schematic structural diagram of a file presentation apparatus according to a first embodiment of the present invention.
  • the file presentation apparatus 10 includes a division module 11, a presentation module 12, a first determination module 13, a switching module 14, a second determination module 15, and a save module 16.
  • the dividing module 11 is configured to divide the file to be presented into a plurality of file blocks, wherein the contents of the adjacent file blocks partially overlap.
  • the presentation module 12 is connected to the partitioning module 11 for loading the first file block into the memory and presenting the first file block, where the first file block is a file block that needs to be presented currently.
  • the first determining module 13 is connected to the rendering module 12 for determining whether the currently displayed display area is located in a predetermined area of the first file block.
  • the switching module 14 is connected to the first determining module 13 for moving the first file block out of the memory and loading the file block adjacent to the first file block if the currently displayed display area is located in a predetermined area of the first file block. Memory is presented.
  • the second judging module 15 is connected to the switching module 14 for loading the first file block out of the memory and loading the file block adjacent to the first file block into the memory and presenting if the cursor position is in a predetermined area of the first file block. Previously, it was judged whether or not the file content of the first file block has changed.
  • the saving module 16 is connected to the second determining module 15 for: if the file content of the first file block is changed, prompting the user whether to save the file content whose first file block has changed; receiving the indication input by the user to save or instruct to give up saving
  • the instruction saves the file content of the first file block according to the instruction saved by the user input instruction, or restores the original content of the first file block according to the instruction input by the user.
  • the dividing module 11 may divide the file to be presented into a plurality of file blocks having the same capacity, or may be file blocks having different capacities.
  • the same capacity means that the file areas occupied by the plurality of divided file blocks have the same size, that is, the files are divided into a plurality of file blocks having the same size according to the same capacity.
  • the dividing module 11 also divides the file into a plurality of file blocks according to a predetermined file block size, wherein the file content of the first 1/N area of the latter file block and the file of the last 1/N area of the previous file block are The content is the same; N is a predetermined constant.
  • the dividing module 1 divides the file into a plurality of file blocks, and the size of the overlapping portion of the content of the adjacent file blocks can be adjusted as needed, but should not be too large, so that the efficiency of dividing the file into multiple file blocks is too low.
  • N may be 3/2, and the file content of the first 2/3 area of the latter file block is the same as the file content of the last 2/3 area of the previous file block.
  • the currently displayed display area may be a cursor position input by the user.
  • the first determining module 13 is configured to determine whether the cursor position input by the user is located in a predetermined area of the first file block.
  • the cursor position input by the user indicates the position where the user performs the touch screen or the key operation, and the key operation may include related keys for performing file editing, such as pressing the up and down direction keys, and pressing the pageup or pagedown keys.
  • the user performs a key operation or a touch screen operation on a file block that has been loaded into the memory, the current position of the cursor is detected while receiving the key value.
  • the size of the predetermined area can be set as needed.
  • the first file block is moved out of the memory and the previous file block is loaded.
  • the memory is rendered; if the currently displayed display area is located in the back 1/L area of the first file block, the first file block is moved out of memory and the next file block is loaded into memory and rendered.
  • the first 1/M area of the first file block and the last 1/L area of the first file block are all predetermined areas of the first file block, where 1/N is greater than or equal to 1/M+1/L.
  • the defined area A is to switch the file block to be edited to a predetermined area of the previous file block
  • the area B is to switch the file block to be edited to a predetermined area of the next file block
  • the area C is an adjacent file block.
  • the overlapping area, the area S is the maximum range that causes the cursor to move in a single time.
  • area A and area B should be greater than or equal to area S, so as to avoid the problem that the file cursor is misaligned after switching the file block because the cursor movement range is beyond the current file block storage range; however, the range of area A and area B is not suitable. Too large, so as not to trigger the area where the file block is switched too small, and fall into the dilemma of frequently switching file blocks.
  • the area C needs to be greater than or equal to the area A+ area B, so that the cursor will be located in the A area or the B area of the new file block after switching to the new file block; however, the area C should not be too large, otherwise the file block may be caused.
  • the division efficiency is too low. Specifically, for example, if the entire area of the file block to be edited is set to 1, the area A and the area B may take the following values: 1/10, 1/8, 1/6, 1/4, 1/3, etc.
  • the corresponding area C is taken as 1/5, 1/4, 1/3, 1/2, 2/3, etc., and only needs to satisfy the area A, the area B is greater than or equal to the area S, and the area C is greater than or It is equal to the area A+ area B.
  • the predetermined area is related to the maximum range in which the single button causes the cursor to move, and the maximum range in which the single button causes the cursor to move varies depending on the type of the button.
  • the maximum range of the cursor that can be moved by a single button is often determined by the range of the single movable cursor of the page PageUp and PageDown. For example, in the case of displaying a scroll bar, 15 lines of code can be displayed per page. Since the buttons PageUp and PageDown move the cursor one page at a time, S can be set to an area of approximately 15 lines of code.
  • one file block can be divided into three parts: a first 1/3 area, a middle 1/3 area, and a back 1/3 area, and the predetermined area refers to a file block to be presented.
  • the file is an editable file
  • the cursor position is in a predetermined area of the first file block, before the first file block is moved out of the memory and the file block adjacent to the first file block is loaded into the memory and presented, the second judgment is made.
  • the module 15 determines whether the file content of the first file block has changed. If the file content of the first file block changes, the saving module 16 prompts the user whether to save the file content whose first file block has changed; receives an instruction input by the user to save or instruct to abandon the saved instruction; and saves according to the instruction input by the user.
  • the instruction saves the content of the file in which the first file block is changed, or restores the original content of the first file block according to the instruction input by the user.
  • all modifications made by the user to the current file are performed on the file block to be rendered currently loaded into the memory, so that only the file content of the file block to be rendered currently loaded into the memory is used.
  • the full text of the file can be saved by overwriting the contents of the file in the corresponding area of the original file. This requires that the file block to be rendered that has been loaded into memory cannot be misaligned when it is spliced with the portion of the file that has not been loaded into the memory, otherwise the file information will be lost. Therefore, it is necessary to accurately locate the boundary of the area of the file in the original file when the file is saved.
  • the saving module 16 records the starting position of the file block to be rendered (Start) Position) and end position (Stop Position).
  • the starting position is the position of the starting point of the current file block in the full text of the file, that is, the offset generated by the file pointer moving from the beginning of the file to the beginning of the current file block.
  • the end position is the position of the current file block end point in the full text of the file, that is, the offset generated by the file pointer moving from the beginning of the file to the end of the current file block.
  • a blank temporary file is created in the same directory of the file to be rendered; the file to be rendered is from the beginning of the file to the first file block to be presented.
  • the first text content of the unloaded memory between the starting positions in the file is written to the temporary file; the file content of the first file block is written to the temporary file, so that the file content of the first file block is changed.
  • the first text content is sequentially connected in the temporary file; the file to be rendered is written into the temporary file from the end position of the first file block in the file to be rendered to the second text content of the unloaded memory between the end of the file,
  • the file content in which the second text content is changed with the first file block is sequentially connected in the temporary file; the file to be rendered is deleted after the file name of the file to be rendered is recorded; and the temporary file is named with the file name of the file to be rendered.
  • the saving module 16 completes the saving operation of the large-capacity file, which causes the file block to be rendered in the loaded memory to be spliced without any misalignment after being modified and the portion of the file that has not been loaded into the memory. Will not cause the loss of text information.
  • the rendering module 12 performs an operation of moving the text block to be rendered out of the memory and loading the adjacent text block into the memory for performing. Subsequent text editing operations.
  • FIG. 8 is a block diagram showing the structure of a file presentation apparatus according to a second embodiment of the present invention.
  • the file presentation device 20 can include a processor 210, a memory 220, and a data bus 230.
  • Processor 210 and memory 220 are coupled to data bus 230 for data interactive communication over data bus 230, respectively.
  • Memory 220 can include read only memory and random access memory and provides instructions and data to processor 210. A portion of the memory 220 may also include non-volatile random access memory (NVRAM).
  • NVRAM non-volatile random access memory
  • the memory 220 stores the following elements, executable modules or data structures, or a subset thereof, or an extended set thereof:
  • Operation instructions include various operation instructions for implementing various operations.
  • Operating system Includes a variety of system programs for implementing various basic services and handling hardware-based tasks.
  • the memory 220 is also used to store files.
  • the processor 210 performs the following operations by calling an operation instruction stored in the memory 220 (which can be stored in the operating system):
  • the processor 210 divides the file into a plurality of file blocks according to a predetermined file block size, wherein the file content of the first 1/N area of the latter file block is the same as the file content of the last 1/N area of the previous file block;
  • the predetermined constant The size of the overlapping portion of the content of the adjacent file blocks can be adjusted as needed, but should not be too large, that is, the predetermined constant N should not be too small, so that the file to be rendered is not too efficiently divided into multiple text blocks. Since the adjacent file blocks partially overlap, smooth switching of adjacent file blocks can be realized, and the user experience is improved.
  • the processor 210 determines whether the cursor position input by the user is located in a predetermined area of the first file block when determining whether the currently presented display area is located in a predetermined area of the first file block. Specifically, if the currently displayed display area is located in the first 1/M area of the first file block, the first file block is moved out of the memory and the previous file block is loaded into the memory and rendered; if the currently displayed display area is located in the first When the 1/L area of a file block is moved, the first file block is moved out of memory and the next file block is loaded into memory and rendered. Where 1/N is greater than or equal to 1/M+1/L.
  • the file is an editable file; if the cursor position is in a predetermined area of the first file block, the processor 210 determines that the first file block is moved out of the memory and the file block adjacent to the first file block is loaded into the memory and presented. Whether the file content of the first file block has changed. If the file content of the first file block is changed, the processor 210 is configured to: prompt the user whether to save the file content in which the first file block is changed; receive an instruction input by the user to save or instruct to abandon the saved instruction; and input according to the user The instruction indicating the saving saves the content of the file in which the first file block is changed, or restores the original content of the first file block according to the instruction input by the user.
  • the processor 210 When saving the file content of the first file block, the processor 210 is configured to: create a blank temporary file in the same directory of the file to be rendered; and upload the file to be rendered from the beginning of the file to the first file block.
  • the content of the file and the first text content are sequentially connected in the temporary file;
  • the file to be rendered is written from the end position of the first file block in the file to be rendered to the second text content of the unloaded memory between the end of the file Entering a temporary file, so that the content of the file whose second text content is changed with the first file block is sequentially connected in the temporary file; deleting the file name of the file to be presented and deleting the file to be presented; the file name of the file to be presented Name the temporary file.
  • the saving operation of the large-capacity file is completed. This
  • the file to be presented is divided into a plurality of file blocks, wherein contents of adjacent file blocks are partially overlapped; the first file block is loaded into the memory, and the first file block is presented, and the first file block is presented. a file block that is currently required to be rendered; determining whether the currently displayed display area is located in a predetermined area of the first file block; if the currently displayed display area is located in a predetermined area of the first file block, moving the first file block out of memory and The file blocks adjacent to the first file block are loaded into the memory and presented, which can effectively reduce the occupation of the system memory resources when the large-capacity text file is presented without affecting the user experience.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种呈现文件的方法和文件呈现装置,其中,所述方法包括:将待呈现的文件划分为多个文件块,其中相邻的文件块的内容部分重叠(S10);将第一文件块载入内存中,并呈现第一文件块,第一文件块为当前需要呈现的文件块(S11);判断当前呈现的显示区域是否位于第一文件块的预定区域(S12);若当前呈现的显示区域位于第一文件块的预定区域,则将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现(S13)。通过上述方式,能够在不对用户体验造成影响的前提下,有效地降低呈现大容量文本文件时对系统内存资源的占用。

Description

呈现文件的方法和文件呈现装置
【技术领域】
本发明涉及文件处理领域,特别是涉及一种呈现文件的方法和文件呈现装置。
【背景技术】
传统的文本编辑器运行于操作系统之上,其在对文本文件进行编辑时,需要将文本文件的全部内容载入内存后再进行编辑。而当文本文件的容量较大时,将文本文件的内容全部载入内存将占用大量的内存资源,从而影响操作系统的运行。
为解决上述问题,如图1所示,现有技术中,如Ubuntu系统自带的文本编辑软件Gedit使用的做法是:采样将大容量的文本文件分批载入内存的方法,该方法每隔一段时间载入一部分文本文件的内容,并采用“即载即显”的方式将已载入内存的文本文件的内容即时呈现给用户。这种做法虽然能够将大容量的文本载入时间化整为零,缩短用户的等待时间。但是在累积一段时间后,仍会将文本文件的全部内容载入内存中,依然会占用大量的内存资源。
现有技术中的其它的文件呈现系统也未对大容量文本文件进行有针对性的优化,或者仅在大容量文本文件的载入时间上作出了部分优化,并未从根本上杜绝进行文件呈现时可能发生的大量内存占用。
而当今电子设备日益朝小型化、轻量化发展,其自身配备的内存容量往往比较有限,这就要求在进行文件呈现时必须能够将对内存资源的占用量控制在合理的范围内,以免影响电子设备的正常运行。
【发明内容】
本发明解决的技术问题是,提供一种呈现文件的方法和文件呈现装置,能够在不对用户体验造成影响的前提下,有效地降低呈现大容量文件时对系统内存资源的占用。
为解决上述技术问题,本发明提供了一种呈现文件的方法,包括:
将待呈现的文件划分为容量相同的多个文件块,其中相邻的文件块的内容部分重叠;
将第一文件块载入内存中,并呈现第一文件块,第一文件块为当前需要呈现的文件块;
判断当前呈现的显示区域是否位于第一文件块的预定区域;
若当前呈现的显示区域位于第一文件块的预定区域,则将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现。
其中,将待呈现的文件划分为多个文件块,其中相邻的文件块的内容部分重叠的步骤具体为:按照预定的文件块大小将文件划分为多个文件块,其中后一文件块的前1/N区域的文件内容与前一文件块的后1/N区域的文件内容相同;N为预定的常数。
其中,若当前呈现的显示区域位于第一文件块的预定区域,则将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现的步骤包括:
若当前呈现的显示区域位于第一文件块的前1/M区域时,则将第一文件块移出内存并将前一文件块载入内存并呈现;
若当前呈现的显示区域位于第一文件块的后1/L区域时,则将第一文件块移出内存并将后一文件块载入内存并呈现;
其中1/N大于或等于1/M+1/L。
其中,第一文件块的前1/M区域和第一文件块的后1/L区域均大于或等于单次导致光标可移动的最大范围。
其中,判断当前呈现的显示区域是否位于第一文件块的预定区域包括:判断用户输入的光标位置是否位于第一文件块的预定区域。
其中,文件为可编辑的文件;
若光标位置位于第一文件块的预定区域,在将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现之前,该方法进一步包括:
判断第一文件块的文件内容是否发生改变;
若第一文件块的文件内容发生改变,则提示用户是否保存第一文件块发生改变的文件内容;
接收用户输入的指示保存或指示放弃保存的指令;
并根据用户输入的指示保存的指令对第一文件块发生改变的文件内容进行保存,或者根据用户输入的指示放弃保存的指令恢复第一文件块的原始内容。
其中,对第一文件块发生改变的文件内容进行保存的步骤具体为:
在待呈现的文件的同目录下创建一个空白的临时文件;
将待呈现的文件从文件开头到第一文件块在待呈现的文件中的起始位置之间的未载入内存的第一文本内容写入临时文件;
将第一文件块发生改变的文件内容写入临时文件,以使第一文件块发生改变的文件内容与第一文本内容在临时文件中依次衔接;
将待呈现的文件从第一文件块在待呈现的文件中的结束位置到文件末尾之间的未载入内存的第二文本内容写入临时文件,以使第二文本内容与第一文件块发生改变的文件内容在临时文件中依次衔接;
记录待呈现的文件的文件名后删除待呈现的文件;
以所述待呈现的文件的文件名命名临时文件。
为解决上述技术问题,本发明还提供了一种呈现文件的方法,包括:
将待呈现的文件划分为多个文件块,其中相邻的文件块的内容部分重叠;
将第一文件块载入内存中,并呈现第一文件块,第一文件块为当前需要呈现的文件块;
判断当前呈现的显示区域是否位于第一文件块的预定区域;
若当前呈现的显示区域位于第一文件块的预定区域,则将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现。
其中,将待呈现的文件划分为多个文件块,其中相邻的文件块的内容部分重叠的步骤具体为:
按照预定的文件块大小将文件划分为多个文件块,其中后一文件块的前1/N区域的文件内容与前一文件块的后1/N区域的文件内容相同;N为预定的常数。
其中,若当前呈现的显示区域位于第一文件块的预定区域,则将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现的步骤包括:
若当前呈现的显示区域位于第一文件块的前1/M区域时,则将第一文件块移出内存并将前一文件块载入内存并呈现;
若当前呈现的显示区域位于第一文件块的后1/L区域时,则将第一文件块移出内存并将后一文件块载入内存并呈现;
其中1/N大于或等于1/M+1/L。
其中,判断当前呈现的显示区域是否位于第一文件块的预定区域包括:
判断用户输入的光标位置是否位于第一文件块的预定区域。
其中,文件为可编辑的文件;
若光标位置位于第一文件块的预定区域,在将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现之前,该方法进一步包括:
判断第一文件块的文件内容是否发生改变;
若第一文件块的文件内容发生改变,则提示用户是否保存第一文件块发生改变的文件内容;
接收用户输入的指示保存或指示放弃保存的指令;
并根据用户输入的指示保存的指令对第一文件块发生改变的文件内容进行保存,或者根据用户输入的指示放弃保存的指令恢复第一文件块的原始内容。
其中,对第一文件块发生改变的文件内容进行保存的步骤具体为:
在待呈现的文件的同目录下创建一个空白的临时文件;
将待呈现的文件从文件开头到第一文件块在待呈现的文件中的起始位置之间的未载入内存的第一文本内容写入临时文件;
将第一文件块发生改变的文件内容写入临时文件,以使第一文件块发生改变的文件内容与第一文本内容在临时文件中依次衔接;
将待呈现的文件从第一文件块在待呈现的文件中的结束位置到文件末尾之间的未载入内存的第二文本内容写入临时文件,以使第二文本内容与第一文件块发生改变的文件内容在临时文件中依次衔接;
记录待呈现的文件的文件名后删除待呈现的文件;
以所述待呈现的文件的文件名命名临时文件。
为解决上述技术问题,本发明还提供了一种文件呈现装置,包括:
划分模块,用于将待呈现的文件划分为多个文件块,其中相邻的文件块的内容部分重叠;
呈现模块,用于将第一文件块载入内存中,并呈现第一文件块,第一文件块为当前需要呈现的文件块;
第一判断模块,用于判断当前呈现的显示区域是否位于第一文件块的预定区域;
切换模块,用于若当前呈现的显示区域位于第一文件块的预定区域,则将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现。
其中,划分模块用于按照预定的文件块大小将文件划分为多个文件块,其中后一文件块的前1/N区域的文件内容与前一文件块的后1/N区域的文件内容相同;N为预定的常数。
其中,切换模块用于:
若当前呈现的显示区域位于第一文件块的前1/M区域时,则将第一文件块移出内存并将前一文件块载入内存并呈现;
若当前呈现的显示区域位于第一文件块的后1/L区域时,则将第一文件块移出内存并将后一文件块载入内存并呈现;
其中1/N大于或等于1/M+1/L。
其中,第一判断模块用于判断用户输入的光标位置是否位于第一文件块的预定区域。
其中,文件为可编辑的文件;文件呈现装置进一步包括:
第二判断模块,用于若光标位置位于第一文件块的预定区域,在将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现之前,判断第一文件块的文件内容是否发生改变;
保存模块,用于若第一文件块的文件内容发生改变,则
提示用户是否保存第一文件块发生改变的文件内容;
接收用户输入的指示保存或指示放弃保存的指令;
并根据用户输入的指示保存的指令对第一文件块发生改变的文件内容进行保存,或者根据用户输入的指示放弃保存的指令恢复第一文件块的原始内容。
其中,保存模块用于:
在待呈现的文件的同目录下创建一个空白的临时文件;
将待呈现的文件从文件开头到第一文件块在待呈现的文件中的起始位置之间的未载入内存的第一文本内容写入临时文件;
将第一文件块发生改变的文件内容写入临时文件,以使第一文件块发生改变的文件内容与第一文本内容在临时文件中依次衔接;
将待呈现的文件从第一文件块在待呈现的文件中的结束位置到文件末尾之间的未载入内存的第二文本内容写入临时文件,以使第二文本内容与第一文件块发生改变的文件内容在临时文件中依次衔接;
记录待呈现的文件的文件名后删除待呈现的文件;
以待呈现的文件的文件名命名临时文件。
为解决上述技术问题,本发明还提供了一种文件呈现装置,包括:
处理器、存储器以及数据总线,处理器和存储器分别与数据总线连接,以通过数据总线进行数据交互通信;
其中,存储器用于存储文件,处理器用于执行如下步骤:
将待呈现的文件划分为多个文件块,其中相邻的文件块的内容部分重叠;
将第一文件块载入内存中,并呈现第一文件块,第一文件块为当前需要呈现的文件块;
判断当前呈现的显示区域是否位于第一文件块的预定区域;
若当前呈现的显示区域位于第一文件块的预定区域,则将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现。
其中,处理器用于按照预定的文件块大小将文件划分为多个文件块,其中后一文件块的前1/N区域的文件内容与前一文件块的后1/N区域的文件内容相同;N为预定的常数。
其中,处理器用于:
若当前呈现的显示区域位于第一文件块的前1/M区域时,则将第一文件块移出内存并将前一文件块载入内存并呈现;
若当前呈现的显示区域位于第一文件块的后1/L区域时,则将第一文件块移出内存并将后一文件块载入内存并呈现;
其中1/N大于或等于1/M+1/L。
其中,处理器用于判断用户输入的光标位置是否位于第一文件块的预定区域。
其中,文件为可编辑的文件;处理器进一步用于:
若光标位置位于第一文件块的预定区域,在将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现之前,判断第一文件块的文件内容是否发生改变;
若第一文件块的文件内容发生改变,则
提示用户是否保存第一文件块发生改变的文件内容;
接收用户输入的指示保存或指示放弃保存的指令;
并根据用户输入的指示保存的指令对第一文件块发生改变的文件内容进行保存,或者根据用户输入的指示放弃保存的指令恢复第一文件块的原始内容。
其中,处理器用于:
在待呈现的文件的同目录下创建一个空白的临时文件;
将待呈现的文件从文件开头到第一文件块在待呈现的文件中的起始位置之间的未载入内存的第一文本内容写入临时文件;
将第一文件块发生改变的文件内容写入临时文件,以使第一文件块发生改变的文件内容与第一文本内容在临时文件中依次衔接;
将待呈现的文件从第一文件块在待呈现的文件中的结束位置到文件末尾之间的未载入内存的第二文本内容写入临时文件,以使第二文本内容与第一文件块发生改变的文件内容在临时文件中依次衔接;
记录待呈现的文件的文件名后删除待呈现的文件;
以待呈现的文件的文件名命名临时文件。
通过上述方案,本发明的有益效果是:通过将待呈现的文件划分为多个文件块,并且只载入并呈现其中的一个文件块,能够有效地降低呈现大容量文件时对系统内存资源的占用,并且由于相邻的文件块存在部分重叠,可实现相邻文件块的平滑切换,提升用户体验。
【附图说明】
图1是现有技术中的呈现文件的方法示意图;
图2是本发明第一实施例的呈现文件的方法的流程示意图;
图3是本发明第一实施例中的文件划分的示意图;
图4是本发明第一实施例中的文件块载入内存的示意图;
图5是本发明第一实施例中的文件块切换的示意图;
图6 是本发明第一实施例中的文件保存的流程示意图;
图7是本发明第一实施例的文件呈现装置的结构示意图;
图8是本发明第二实施例的文件呈现装置的结构示意图。
【具体实施方式】
请参阅图2是本发明第一实施例的呈现文件的方法流程示意图。如图2所示,第一实施例的呈现文件的方法包括:
S10:将待呈现的文件划分为多个文件块,其中相邻的文件块的内容部分重叠。
在S10中,可以将待呈现的文件划分为容量相同的多个文件块,也可以是容量不相同的文件块,其中,容量相同是指所划分的多个文件块所占的文件区域大小相同,也即按照容量相同将文件划分为区域大小一致的多个文件块。
S11:将第一文件块载入内存中,并呈现第一文件块,第一文件块为当前需要呈现的文件块。
其中,本实施例中可以一次只载入一个文件块到内存中,并呈现给用户。在将一个文件块载入内存前,需要先将已载入内存、正呈现给用户的文件块移出内存。
S12:判断当前呈现的显示区域是否位于第一文件块的预定区域。
第一文件块可以有多个预定区域,当前呈现的显示区域位于不同的预定区域时执行不同的操作。
S13:若当前呈现的显示区域位于第一文件块的预定区域,则将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现。
在S13中,根据不同的预定区域,可以将与第一文件块相邻的位于第一文件之前的文件块载入内存并呈现,也可以将与第一文件块相邻的位于第一文件之前的文件块载入内存并呈现。如此可以在待呈现的文件容量太大时,能够在不对用户体验造成影响的前提下,有效地降低呈现大容量文件时对系统内存资源的占用。
在更具体的实施例中,在S10中,可以按照预定的文件块大小将文件划分为多个文件块,其中后一文件块的前1/N区域的文件内容与前一文件块的后1/N区域的文件内容相同;N为预定的常数。相邻的文件块的内容重叠部分的大小可以根据需要调整,但不宜过大,即预定的常数N不宜过小,以免待呈现的文件划分为多个文本块的效率过低。例如,后一文件块的前2/3区域的文件内容与前一文件块的后2/3区域的文件内容相同,以保证在文件块与文件块之间进行切换时能够实现平滑过渡。具体地,在划分一个新的文件块时,只需保持前一个文件块的区域大小不变,向后平移1/3区域面积即可得到新文件块的文件区域。如图3所示,保持文件区域大小不变,依图中粗箭头的方向在文件块n的基础上向后平移1/3区域,即得到文件块n+1。文件块n和文件块n+1有2/3区域重叠,具体为,文件块n的后2/3区域与文件块n+1的前2/3区域的文件内容相同。如此由于相邻的文件块存在部分重叠,可实现相邻文件块的平滑切换,提升用户体验。
在S11中,一次只载入一个文件块到内存中,并呈现给用户。在将一个文件块载入内存前,需要先将已载入内存、正呈现给用户的文件块移出内存。如图4所示,待呈现的文件划分为n个区域大小相同的文件块,n为正整数。要将文件块2载入内存并呈现给用户时,需要先将原来已载入内存的文件块1移出内存。
若文件为可编辑的文件,则当前呈现的显示区域可以是用户输入的光标位置。即在S12中,判断用户输入的光标位置是否位于第一文件块的预定区域。其中,用户输入的光标位置即表示用户执行触摸屏或按键操作的位置,而按键操作可以包括进行文件编辑的相关按键,如按上下左右的方向键,以及按pageup或pagedown的按键等。当用户对已载入内存的文件块进行按键操作或触摸屏操作时,会在接收到按键键值的同时检测光标当前位置。
每个文件块预先划分为不同的区域范围,待呈现的文件块的预定区域指的是针对已载入内存的文件块划分的不同区域范围中相对比较靠近相邻文件块的某一区域范围。预定区域的大小可以根据需要设置,在本实施例中,若当前呈现的显示区域位于第一文件块的前1/M区域时,则将第一文件块移出内存并将前一文件块载入内存并呈现;若当前呈现的显示区域位于第一文件块的后1/L区域时,则将第一文件块移出内存并将后一文件块载入内存并呈现。第一文件块的前1/M区域和第一文件块的后1/L区域都是第一文件块的预定区域,其中1/N大于或等于1/M+1/L。具体地,如果定义区域A为将待呈现的文件块切换至前一文件块的预定区域,区域B为将待呈现的文件块切换至后一文件块的预定区域,区域C为相邻文件块的重叠区域,区域S为单次导致光标可移动的最大范围。则区域A、区域B均应大于或等于区域S,以免由于光标移动范围超出当前文件块容纳范围,而导致切换文件块后出现文件光标定位失准的问题;但区域A、区域B的范围不宜过大,以免因不会触发切换文件块的区域太小,而陷入需要频繁切换文件块的窘境。区域C需大于或等于区域A+区域B,以免在切换至新的文件块后会出现光标位于新文件块的A区域或B区域内的情况;但区域C也不宜过大,否则易造成文件块划分效率过低。具体地,例如若将待呈现的文件块的整个区域设定为1,则区域A、区域B可以取如下值:1/10、1/8、1/6、1/4、1/3等,相对应的区域C则取为1/5、1/4、1/3、1/2、2/3等,只需满足区域A、区域B均大于或等于区域S,以及区域C大于或等于区域A+区域B即可。可见在本实施例中,预定区域与单次按键导致光标可移动的最大范围相关,而单次按键导致光标可移动的最大范围根据按键类型的不同而有所不同。一般来说,由于按键PageUp、PageDown移动范围较大,如一次可移动十几行,单次按键导致光标可移动的最大范围的大小往往由按键PageUp、PageDown单次可移动光标的范围决定。例如,在显示滚动条的情况下每页可显示15行代码,由于按键PageUp、PageDown单次将光标移动一页的范围,此时可将S定为大致15行代码的区域。
举例来说,在本发明实施例中,优选地,一个文件块可以划分为三部分:前1/3区域、中间1/3区域以及后1/3区域,预定区域是指待呈现的文件块的前1/3区域或后1/3区域(即此时M=L=3)。若光标位于待呈现的文件块的前1/3区域时,则将待呈现的文件块移出内存并将前一文件块载入内存并呈现给用户;若光标位于待编辑的文件块的后1/3区域时,则将待呈现的文件块移出内存并将后一文件块载入内存并呈现给用户。若文件为可编辑的文件,如图5所示,X表示光标,当前文件块即为已载入内存的待呈现的文件块。用户进行按键操作,即对当前文件块进行编辑时,如果光标X位于当前文件块的前1/3区域时,则将当前文件块移出内存,并将前一文件块载入内存并呈现给用户;如果光标X位于当前文件块的后1/3区域时,则将当前文件块移出内存,并将后一文件块载入内存并呈现给用户。在切换文件块之前,记录光标X的当前位置及文件块切换所导致的光标X的偏移量;在文件块切换完成后,依据此前记录的光标X的位置及光标X的偏移量恢复光标X在文件中的位置,以使得切换前后光标在整个文件中所处的位置保持不变。这样在用户看来,文件块切换前后光标位置并没有发生任何改变,从而确保用户在从当前文件块切换至前一文件块或后一文件块时能够获得与一次性将文件全文载入内存的方案完全相同的用户体验。
在S12中,若光标位置位于第一文件块的预定区域,在将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现之前,判断第一文件块的文件内容是否发生改变。若第一文件块的文件内容发生改变,则提示用户是否保存第一文件块发生改变的文件内容。接收用户输入的指示保存或指示放弃保存的指令;并根据用户输入的指示保存的指令对第一文件块发生改变的文件内容进行保存,或者根据用户输入的指示放弃保存的指令恢复第一文件块的原始内容。
在本发明实施例中,用户对当前文件所作的一切修改都是针对当前已载入内存的待呈现的文件块进行的,因此只需用当前已载入内存的待呈现的文件块的文件内容覆盖掉原文件对应区域的文件内容即可完成对文件全文的保存。这就要求必须保证已载入内存的待呈现的文件块在被修改后与尚未载入内存的文件部分在进行拼接时不能发生任何错位,否则会导致文件信息的丢失。因此需要在保存文件时能够准确定位当前载入内存的文件块在原文件中所对应区域的边界。
当将待呈现的文件块载入内存时,会记录待呈现的文件块的起始位置(Start Position)和结束位置(Stop Position)。如图5所示,当前文件块即为已载入内存的待呈现的文件块。起始位置为当前文件块起点在文件全文中所处的位置,即文件指针从文件开头移动到当前文件块起点所产生的偏移量。结束位置为当前文件块终点在文件全文中所处的位置,即文件指针从文件开头移动到当前文件块终点所产生的偏移量。在保存文件时,通过调用此前记录的起始位置和结束位置,对当前文件块在原文件中对应区域的边界进行准确定位,再以当前文件块的文件内容覆盖掉原文件中对应区域的文件内容,即可完成对大容量文件的保存。
在本发明实施例中,如图6所示,对第一文件块发生改变的文件内容进行保存包括:
S140:在待呈现的文件的同目录下创建一个空白的临时文件。
S141:将待呈现的文件从文件开头到第一文件块在待呈现的文件中的起始位置之间的未载入内存的第一文本内容写入临时文件。
S142:将第一文件块发生改变的文件内容写入临时文件,以使第一文件块发生改变的文件内容与第一文本内容在临时文件中依次衔接。
S143:将待呈现的文件从第一文件块在待呈现的文件中的结束位置到文件末尾之间的未载入内存的第二文本内容写入临时文件,以使第二文本内容与第一文件块发生改变的文本内容在临时文件中依次衔接。
例如,若第一文件块发生改变的文件内容被全部删除,则保存时意味着第一文件块发生改变的文本内容为空,文件从文件开头到起始位置之间的未载入内存的第一文本内容会与文件从结束位置到文件末尾之间的未载入内存的第二文本内容直接衔接在一起,保存完毕后起始位置与结束位置会重合为一个点。
S144:记录待呈现的文件的文件名后删除待呈现的文件。
S145:以上述待呈现的文件的文件名命名临时文件。
至此,完成对大容量文件的保存操作。这就使得已载入内存的待呈现的文件块在被修改后与尚未载入内存的文件部分在进行拼接时不会发生任何错位,也不会造成文本信息的丢失。
在本发明实施例中,通过将待呈现的文件划分为多个文件块,其中相邻的文件块的内容部分重叠;将第一文件块载入内存中,并呈现第一文件块,第一文件块为当前需要呈现的文件块;判断当前呈现的显示区域是否位于第一文件块的预定区域;若当前呈现的显示区域位于第一文件块的预定区域,则将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现,能够在不对用户体验造成影响的前提下,有效地降低呈现大容量文本文件时对系统内存资源的占用。
请参阅图7,图7是本发明第一实施例的文件呈现装置的结构示意图。如图7所示,文件呈现装置10包括划分模块11、呈现模块12、第一判断模块13、切换模块14、第二判断模块15以及保存模块16。
在本发明实施例中,划分模块11用于将待呈现的文件划分为多个文件块,其中相邻的文件块的内容部分重叠。呈现模块12与划分模块11连接,用于将第一文件块载入内存中,并呈现第一文件块,第一文件块为当前需要呈现的文件块。第一判断模块13与呈现模块12连接,用于判断当前呈现的显示区域是否位于第一文件块的预定区域。切换模块14与第一判断模块13连接,用于若当前呈现的显示区域位于第一文件块的预定区域,则将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现。第二判断模块15与切换模块14连接,用于若光标位置位于第一文件块的预定区域,在将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现之前,判断第一文件块的文件内容是否发生改变。保存模块16与第二判断模块15连接,用于若第一文件块的文件内容发生改变,则:提示用户是否保存第一文件块发生改变的文件内容;接收用户输入的指示保存或指示放弃保存的指令,并根据用户输入的指示保存的指令对第一文件块发生改变的文件内容进行保存,或者根据用户输入的指示放弃保存的指令恢复第一文件块的原始内容。
举例来说,在本发明实施例中,划分模块11可以将待呈现的文件划分为容量相同的多个文件块,也可以是容量不相同的文件块。其中,容量相同是指所划分的多个文件块所占的文件区域大小相同,也即按照容量相同将文件划分为区域大小一致的多个文件块。
举例来说,划分模块11也按照预定的文件块大小将文件划分为多个文件块,其中后一文件块的前1/N区域的文件内容与前一文件块的后1/N区域的文件内容相同;N为预定的常数。划分模块1将文件划分为多个文件块,相邻的文件块的内容重叠部分的大小可以根据需要调整,但不宜过大,以免文件划分为多个文件块的效率过低。优选地,N可以为3/2,则后一文件块的前2/3区域的文件内容与前一文件块的后2/3区域的文件内容相同。具体地,在划分一个新的文件块时,只需保持前一个文件块的文本区域大小不变,向后平移1/3区域面积即可得到新文件块的文件区域。如此由于相邻的文件块存在部分重叠,可实现相邻文件块的平滑切换,提升用户体验。
在本发明实施例中,若文件为可编辑的文件,则当前呈现的显示区域可以是用户输入的光标位置。第一判断模块13用于判断用户输入的光标位置是否位于第一文件块的预定区域。其中,用户输入的光标位置即表示用户执行触摸屏或按键操作的位置,而按键操作可以包括进行文件编辑的相关按键,如按上下左右的方向键,以及按pageup或pagedown的按键等。当用户对已载入内存的文件块进行按键操作或触摸屏操作时,会在接收到按键键值的同时检测光标当前位置。预定区域的大小可以根据需要设置,在本实施例中,若当前呈现的显示区域位于第一文件块的前1/M区域时,则将第一文件块移出内存并将前一文件块载入内存并呈现;若当前呈现的显示区域位于第一文件块的后1/L区域时,则将第一文件块移出内存并将后一文件块载入内存并呈现。第一文件块的前1/M区域和第一文件块的后1/L区域都是第一文件块的预定区域,其中1/N大于或等于1/M+1/L。具体地,如果定义区域A为将待编辑的文件块切换至前一文件块的预定区域,区域B为将待编辑的文件块切换至后一文件块的预定区域,区域C为相邻文件块的重叠区域,区域S为单次导致光标可移动的最大范围。则区域A、区域B均应大于或等于区域S,以免由于光标移动范围超出当前文件块容纳范围,而导致切换文件块后出现文件光标定位失准的问题;但区域A、区域B的范围不宜过大,以免因不会触发切换文件块的区域太小,而陷入需要频繁切换文件块的窘境。区域C需大于或等于区域A+区域B,以免在切换至新的文件块后会出现光标位于新文件块的A区域或B区域内的情况;但区域C也不宜过大,否则易造成文件块划分效率过低。具体地,例如若将待编辑的文件块的整个区域设定为1,则区域A、区域B可以取如下值:1/10、1/8、1/6、1/4、1/3等,相对应的区域C则取为1/5、1/4、1/3、1/2、2/3等,只需满足区域A、区域B均大于或等于区域S,以及区域C大于或等于区域A+区域B即可。可见在本实施例中,预定区域与单次按键导致光标可移动的最大范围相关,而单次按键导致光标可移动的最大范围根据按键类型的不同而有所不同。一般来说,由于按键PageUp、PageDown移动范围较大,如一次可移动十几行,单次按键导致光标可移动的最大范围的大小往往由按键PageUp、PageDown单次可移动光标的范围决定。例如,在显示滚动条的情况下每页可显示15行代码,由于按键PageUp、PageDown单次将光标移动一页的范围,此时可将S定为大致15行代码的区域。
举例来说,在本发明实施例中,优选地,一个文件块可以划分为三部分:前1/3区域、中间1/3区域以及后1/3区域,预定区域是指待呈现的文件块的前1/3区域或后1/3区域(此时M=L=3)。若光标位于待呈现的文件块的前1/3区域时,则将待呈现的文件块移出内存并将前一文件块载入内存并呈现给用户;若光标位于待呈现的文件块的后1/3区域时,则将待呈现的文件块移出内存并将后一文件块载入内存并呈现给用户。
若文件为可编辑的文件,若光标位置位于第一文件块的预定区域,在将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现之前,第二判断模块15判断第一文件块的文件内容是否发生改变。若第一文件块的文件内容发生改变,则保存模块16提示用户是否保存第一文件块发生改变的文件内容;接收用户输入的指示保存或指示放弃保存的指令;并根据用户输入的指示保存的指令对第一文件块发生改变的文件内容进行保存,或者根据用户输入的指示放弃保存的指令恢复第一文件块的原始内容。
在本发明实施例中,用户对当前文件所作的一切修改都是针对当前已载入内存的待呈现的文件块进行的,因此只需用当前已载入内存的待呈现的文件块的文件内容覆盖掉原文件对应区域的文件内容即可完成对文件全文的保存。这就要求必须保证已载入内存的待呈现的文件块在被修改后与尚未载入内存的文件部分在进行拼接时不能发生任何错位,否则会导致文件信息的丢失。因此需要在保存文件时能够准确定位当前载入内存的文件块在原文件中所对应区域的边界。当将待呈现的文件块载入内存时,保存模块16会记录待呈现的文件块的起始位置(Start Position)和结束位置(Stop Position)。起始位置为当前文件块起点在文件全文中所处的位置,即文件指针从文件开头移动到当前文件块起点所产生的偏移量。结束位置为当前文件块终点在文件全文中所处的位置,即文件指针从文件开头移动到当前文件块终点所产生的偏移量。在保存文件时,通过调用此前记录的起始位置和结束位置,对当前文件块在原文件中对应区域的边界进行准确定位,再以当前文件块的文件内容覆盖掉原文件中对应区域的文件内容,即可完成对大容量文件的保存。这样在用户看来,文件块切换前后光标位置并没有发生任何改变,从而确保用户在从当前文件块切换至前一文件块或后一文件块时能够获得与一次性将文件全文载入内存的方案完全相同的用户体验。
保存模块16对第一文件块发生改变的文件内容进行保存时,在待呈现的文件的同目录下创建一个空白的临时文件;将待呈现的文件从文件开头到第一文件块在待呈现的文件中的起始位置之间的未载入内存的第一文本内容写入临时文件;将第一文件块发生改变的文件内容写入临时文件,以使第一文件块发生改变的文件内容与第一文本内容在临时文件中依次衔接;将待呈现的文件从第一文件块在待呈现的文件中的结束位置到文件末尾之间的未载入内存的第二文本内容写入临时文件,以使第二文本内容与第一文件块发生改变的文件内容在临时文件中依次衔接;记录待呈现的文件的文件名后删除待呈现的文件;以待呈现的文件的文件名命名临时文件。至此,保存模块16完成对大容量文件的保存操作,这就使得已载入内存的待呈现的文件块在被修改后与尚未载入内存的文件部分在进行拼接时不会发生任何错位,也不会造成文本信息的丢失。
保存模块16完成对第一文件块发生改变的的文件内容进行保存的操作后,呈现模块12执行将待呈现的文本块移出内存并将与之相邻的文本块载入内存的操作,以进行后续的文本编辑操作。
图8是本发明第二实施例的文件呈现装置的结构示意图。文件呈现装置20可包括处理器210、存储器220以及数据总线230。处理器210和存储器220分别与数据总线230连接,以通过数据总线230进行数据交互通信。
存储器220可以包括只读存储器和随机存取存储器,并向处理器210提供指令和数据。存储器220的一部分还可以包括非易失性随机存取存储器(NVRAM)。
存储器220存储了如下的元素,可执行模块或者数据结构,或者它们的子集,或者它们的扩展集:
操作指令:包括各种操作指令,用于实现各种操作。
操作系统:包括各种系统程序,用于实现各种基础业务以及处理基于硬件的任务。
在本发明实施例中,存储器220还用于存储文件。处理器210通过调用存储器220存储的操作指令(该操作指令可存储在操作系统中),执行如下操作:
将待呈现的文件划分为多个文件块,其中相邻的文件块的内容部分重叠;将第一文件块载入内存中,并呈现第一文件块,第一文件块为当前需要呈现的文件块;判断当前呈现的显示区域是否位于第一文件块的预定区域;若当前呈现的显示区域位于第一文件块的预定区域,则将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现。
处理器210按照预定的文件块大小将文件划分为多个文件块,其中后一文件块的前1/N区域的文件内容与前一文件块的后1/N区域的文件内容相同;N为预定的常数。相邻的文件块的内容重叠部分的大小可以根据需要调整,但不宜过大,即预定的常数N不宜过小,以免待呈现的文件划分为多个文本块的效率过低。由于相邻的文件块存在部分重叠,可实现相邻文件块的平滑切换,提升用户体验。
处理器210将第一文件块载入内存中时,一次只载入一个文件块到内存中,并呈现给用户。在将一个文件块载入内存前,需要先将已载入内存、正呈现给用户的文件块移出内存。
处理器210在判断当前呈现的显示区域是否位于第一文件块的预定区域时,判断用户输入的光标位置是否位于第一文件块的预定区域。具体地,若当前呈现的显示区域位于第一文件块的前1/M区域时,则将第一文件块移出内存并将前一文件块载入内存并呈现;若当前呈现的显示区域位于第一文件块的后1/L区域时,则将第一文件块移出内存并将后一文件块载入内存并呈现。其中1/N大于或等于1/M+1/L。
文件为可编辑的文件;若光标位置位于第一文件块的预定区域,处理器210在将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现之前,判断第一文件块的文件内容是否发生改变。若第一文件块的文件内容发生改变,则处理器210用于:提示用户是否保存第一文件块发生改变的文件内容;接收用户输入的指示保存或指示放弃保存的指令;并根据用户输入的指示保存的指令对第一文件块发生改变的文件内容进行保存,或者根据用户输入的指示放弃保存的指令恢复第一文件块的原始内容。
在对第一文件块发生改变的文件内容进行保存时,处理器210用于:在待呈现的文件的同目录下创建一个空白的临时文件;将待呈现的文件从文件开头到第一文件块在待呈现的文件中的起始位置之间的未载入内存的第一文本内容写入临时文件;将第一文件块发生改变的文件内容写入临时文件,以使第一文件块发生改变的文件内容与第一文本内容在临时文件中依次衔接;将待呈现的文件从第一文件块在待呈现的文件中的结束位置到文件末尾之间的未载入内存的第二文本内容写入临时文件,以使第二文本内容与第一文件块发生改变的文件内容在临时文件中依次衔接;记录待呈现的文件的文件名后删除待呈现的文件;以待呈现的文件的文件名命名临时文件。至此,完成对大容量文件的保存操作。这就使得已载入内存的待呈现的文件块在被修改后与尚未载入内存的文件部分在进行拼接时不会发生任何错位,也不会造成文本信息的丢失。
综上所述,通过将待呈现的文件划分为多个文件块,其中相邻的文件块的内容部分重叠;将第一文件块载入内存中,并呈现第一文件块,第一文件块为当前需要呈现的文件块;判断当前呈现的显示区域是否位于第一文件块的预定区域;若当前呈现的显示区域位于第一文件块的预定区域,则将第一文件块移出内存并将与第一文件块相邻的文件块载入内存并呈现,能够在不对用户体验造成影响的前提下,有效地降低呈现大容量文本文件时对系统内存资源的占用。
以上所述仅为本发明的实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。

Claims (25)

  1. 一种呈现文件的方法,其中,所述方法包括:
    将待呈现的文件划分为容量相同的多个文件块,其中相邻的文件块的内容部分重叠;
    将第一文件块载入内存中,并呈现所述第一文件块,所述第一文件块为当前需要呈现的文件块;
    判断当前呈现的显示区域是否位于所述第一文件块的预定区域;
    若当前呈现的显示区域位于所述第一文件块的预定区域,则将所述第一文件块移出所述内存并将与所述第一文件块相邻的文件块载入所述内存并呈现。
  2. 根据权利要求1所述的方法,其中,所述将待呈现的文件划分为多个文件块,其中相邻的文件块的内容部分重叠的步骤具体为:按照预定的文件块大小将所述文件划分为多个文件块,其中后一文件块的前1/N区域的文件内容与前一文件块的后1/N区域的文件内容相同;N为预定的常数。
  3. 根据权利要求2所述的方法,其中,所述若当前呈现的显示区域位于所述第一文件块的预定区域,则将所述第一文件块移出所述内存并将与所述第一文件块相邻的文件块载入所述内存并呈现的步骤包括:
    若当前呈现的显示区域位于所述第一文件块的前1/M区域时,则将所述第一文件块移出所述内存并将前一文件块载入所述内存并呈现;
    若当前呈现的显示区域位于所述第一文件块的后1/L区域时,则将所述第一文件块移出所述内存并将后一文件块载入所述内存并呈现;
    其中1/N大于或等于1/M+1/L。
  4. 根据权利要求3所述的方法,其中,所述第一文件块的前1/M区域和所述第一文件块的后1/L区域均大于或等于单次导致光标可移动的最大范围。
  5. 根据权利要求1-4任一项所述的方法,其中,所述判断当前呈现的显示区域是否位于所述第一文件块的预定区域包括:判断用户输入的光标位置是否位于所述第一文件块的预定区域。
  6. 根据权利要求5所述的方法,其中,所述文件为可编辑的文件;
    若所述光标位置位于所述第一文件块的预定区域,在所述将所述第一文件块移出所述内存并将与所述第一文件块相邻的文件块载入所述内存并呈现之前,所述方法进一步包括:
    判断所述第一文件块的文件内容是否发生改变;
    若所述第一文件块的文件内容发生改变,则提示用户是否保存所述第一文件块发生改变的文件内容;
    接收用户输入的指示保存或指示放弃保存的指令;
    并根据用户输入的指示保存的指令对所述第一文件块发生改变的文件内容进行保存,或者根据用户输入的指示放弃保存的指令恢复所述第一文件块的原始内容。
  7. 根据权利要求6所述的方法,其中,所述对所述第一文件块发生改变的文件内容进行保存的步骤具体为:
    在所述待呈现的文件的同目录下创建一个空白的临时文件;
    将所述待呈现的文件从文件开头到所述第一文件块在所述待呈现的文件中的起始位置之间的未载入内存的第一文本内容写入所述临时文件;
    将所述第一文件块发生改变的文件内容写入所述临时文件,以使所述第一文件块发生改变的文件内容与所述第一文本内容在所述临时文件中依次衔接;
    将所述待呈现的文件从所述第一文件块在所述待呈现的文件中的结束位置到文件末尾之间的未载入内存的第二文本内容写入所述临时文件,以使所述第二文本内容与所述第一文件块发生改变的文件内容在所述临时文件中依次衔接;
    记录所述待呈现的文件的文件名后删除所述待呈现的文件;
    以所述待呈现的文件的文件名命名所述临时文件。
  8. 一种呈现文件的方法,其中,所述方法包括:
    将待呈现的文件划分为多个文件块,其中相邻的文件块的内容部分重叠;
    将第一文件块载入内存中,并呈现所述第一文件块,所述第一文件块为当前需要呈现的文件块;
    判断当前呈现的显示区域是否位于所述第一文件块的预定区域;
    若当前呈现的显示区域位于所述第一文件块的预定区域,则将所述第一文件块移出所述内存并将与所述第一文件块相邻的文件块载入所述内存并呈现。
  9. 根据权利要求8所述的方法,其中,所述将待呈现的文件划分为多个文件块,其中相邻的文件块的内容部分重叠的步骤具体为:
    按照预定的文件块大小将所述文件划分为多个文件块,其中后一文件块的前1/N区域的文件内容与前一文件块的后1/N区域的文件内容相同;N为预定的常数。
  10. 根据权利要求9所述的方法,其中,所述若当前呈现的显示区域位于所述第一文件块的预定区域,则将所述第一文件块移出所述内存并将与所述第一文件块相邻的文件块载入所述内存并呈现的步骤包括:
    若当前呈现的显示区域位于所述第一文件块的前1/M区域时,则将所述第一文件块移出所述内存并将前一文件块载入所述内存并呈现;
    若当前呈现的显示区域位于所述第一文件块的后1/L区域时,则将所述第一文件块移出所述内存并将后一文件块载入所述内存并呈现;
    其中1/N大于或等于1/M+1/L。
  11. 根据权利要求8-10任一项所述的方法,其中,所述判断当前呈现的显示区域是否位于所述第一文件块的预定区域包括:
    判断用户输入的光标位置是否位于所述第一文件块的预定区域。
  12. 根据权利要求11所述的方法,其中,所述文件为可编辑的文件;
    若所述光标位置位于所述第一文件块的预定区域,在所述将所述第一文件块移出所述内存并将与所述第一文件块相邻的文件块载入所述内存并呈现之前,所述方法进一步包括:
    判断所述第一文件块的文件内容是否发生改变;
    若所述第一文件块的文件内容发生改变,则提示用户是否保存所述第一文件块发生改变的文件内容;
    接收用户输入的指示保存或指示放弃保存的指令;
    并根据用户输入的指示保存的指令对所述第一文件块发生改变的文件内容进行保存,或者根据用户输入的指示放弃保存的指令恢复所述第一文件块的原始内容。
  13. 根据权利要求12所述的方法,其中,所述对所述第一文件块发生改变的文件内容进行保存的步骤具体为:
    在所述待呈现的文件的同目录下创建一个空白的临时文件;
    将所述待呈现的文件从文件开头到所述第一文件块在所述待呈现的文件中的起始位置之间的未载入内存的第一文本内容写入所述临时文件;
    将所述第一文件块发生改变的文件内容写入所述临时文件,以使所述第一文件块发生改变的文件内容与所述第一文本内容在所述临时文件中依次衔接;
    将所述待呈现的文件从所述第一文件块在所述待呈现的文件中的结束位置到文件末尾之间的未载入内存的第二文本内容写入所述临时文件,以使所述第二文本内容与所述第一文件块发生改变的文件内容在所述临时文件中依次衔接;
    记录所述待呈现的文件的文件名后删除所述待呈现的文件;
    以所述待呈现的文件的文件名命名所述临时文件。
  14. 一种文件呈现装置,其中,所述文件呈现装置包括:
    划分模块,用于将待呈现的文件划分为多个文件块,其中相邻的文件块的内容部分重叠;
    呈现模块,用于将第一文件块载入内存中,并呈现所述第一文件块,所述第一文件块为当前需要呈现的文件块;
    第一判断模块,用于判断当前呈现的显示区域是否位于所述第一文件块的预定区域;
    切换模块,用于若当前呈现的显示区域位于所述第一文件块的预定区域,则将所述第一文件块移出所述内存并将与所述第一文件块相邻的文件块载入所述内存并呈现。
  15. 根据权利要求14所述的文件呈现装置,其中,所述划分模块用于按照预定的文件块大小将所述文件划分为多个文件块,其中后一文件块的前1/N区域的文件内容与前一文件块的后1/N区域的文件内容相同;N为预定的常数。
  16. 根据权利要求15所述的文件呈现装置,其中,所述切换模块用于:
    若当前呈现的显示区域位于所述第一文件块的前1/M区域时,则将所述第一文件块移出所述内存并将前一文件块载入所述内存并呈现;
    若当前呈现的显示区域位于所述第一文件块的后1/L区域时,则将所述第一文件块移出所述内存并将后一文件块载入所述内存并呈现;
    其中1/N大于或等于1/M+1/L。
  17. 根据权利要求14-16任一项所述的文件呈现装置,其中,所述第一判断模块用于判断用户输入的光标位置是否位于所述第一文件块的预定区域。
  18. 根据权利要求17所述的文件呈现装置,其中,所述文件为可编辑的文件;所述文件呈现装置进一步包括:
    第二判断模块,用于若所述光标位置位于所述第一文件块的预定区域,在所述将所述第一文件块移出所述内存并将与所述第一文件块相邻的文件块载入所述内存并呈现之前,判断所述第一文件块的文件内容是否发生改变;
    保存模块,用于若所述第一文件块的文件内容发生改变,则
    提示用户是否保存所述第一文件块发生改变的文件内容;
    接收用户输入的指示保存或指示放弃保存的指令;
    并根据用户输入的指示保存的指令对所述第一文件块发生改变的文件内容进行保存,或者根据用户输入的指示放弃保存的指令恢复所述第一文件块的原始内容。
  19. 根据权利要求18所述的文件呈现装置,其中,所述保存模块用于:
    在所述待呈现的文件的同目录下创建一个空白的临时文件;
    将所述待呈现的文件从文件开头到所述第一文件块在所述待呈现的文件中的起始位置之间的未载入内存的第一文本内容写入所述临时文件;
    将所述第一文件块发生改变的文件内容写入所述临时文件,以使所述第一文件块发生改变的文件内容与所述第一文本内容在所述临时文件中依次衔接;
    将所述待呈现的文件从所述第一文件块在所述待呈现的文件中的结束位置到文件末尾之间的未载入内存的第二文本内容写入所述临时文件,以使所述第二文本内容与所述第一文件块发生改变的文件内容在所述临时文件中依次衔接;
    记录所述待呈现的文件的文件名后删除所述待呈现的文件;
    以所述待呈现的文件的文件名命名所述临时文件。
  20. 一种文件呈现装置,其中,包括:处理器、存储器以及数据总线,所述处理器和所述存储器分别与所述数据总线连接,以通过所述数据总线进行数据交互通信;
    其中,所述存储器用于存储文件,所述处理器用于执行如下步骤:
    将待呈现的文件划分为多个文件块,其中相邻的文件块的内容部分重叠;
    将第一文件块载入内存中,并呈现所述第一文件块,所述第一文件块为当前需要呈现的文件块;
    判断当前呈现的显示区域是否位于所述第一文件块的预定区域;
    若当前呈现的显示区域位于所述第一文件块的预定区域,则将所述第一文件块移出所述内存并将与所述第一文件块相邻的文件块载入所述内存并呈现。
  21. 根据权利要求20所述的文件呈现装置,其中,所述处理器用于按照预定的文件块大小将所述文件划分为多个文件块,其中后一文件块的前1/N区域的文件内容与前一文件块的后1/N区域的文件内容相同;N为预定的常数。
  22. 根据权利要求21所述的文件呈现装置,其中,所述处理器用于:
    若当前呈现的显示区域位于所述第一文件块的前1/M区域时,则将所述第一文件块移出所述内存并将前一文件块载入所述内存并呈现;
    若当前呈现的显示区域位于所述第一文件块的后1/L区域时,则将所述第一文件块移出所述内存并将后一文件块载入所述内存并呈现;
    其中1/N大于或等于1/M+1/L。
  23. 根据权利要求20-22任一项所述的文件呈现装置,其中,所述处理器用于判断用户输入的光标位置是否位于所述第一文件块的预定区域。
  24. 根据权利要求23所述的文件呈现装置,其中,所述文件为可编辑的文件;所述处理器进一步用于:
    若所述光标位置位于所述第一文件块的预定区域,在所述将所述第一文件块移出所述内存并将与所述第一文件块相邻的文件块载入所述内存并呈现之前,判断所述第一文件块的文件内容是否发生改变;
    若所述第一文件块的文件内容发生改变,则
    提示用户是否保存所述第一文件块发生改变的文件内容;
    接收用户输入的指示保存或指示放弃保存的指令;
    并根据用户输入的指示保存的指令对所述第一文件块发生改变的文件内容进行保存,或者根据用户输入的指示放弃保存的指令恢复所述第一文件块的原始内容。
  25. 根据权利要求24所述的文件呈现装置,其中,所述处理器用于:
    在所述待呈现的文件的同目录下创建一个空白的临时文件;
    将所述待呈现的文件从文件开头到所述第一文件块在所述待呈现的文件中的起始位置之间的未载入内存的第一文本内容写入所述临时文件;
    将所述第一文件块发生改变的文件内容写入所述临时文件,以使所述第一文件块发生改变的文件内容与所述第一文本内容在所述临时文件中依次衔接;
    将所述待呈现的文件从所述第一文件块在所述待呈现的文件中的结束位置到文件末尾之间的未载入内存的第二文本内容写入所述临时文件,以使所述第二文本内容与所述第一文件块发生改变的文件内容在所述临时文件中依次衔接;
    记录所述待呈现的文件的文件名后删除所述待呈现的文件;
    以所述待呈现的文件的文件名命名所述临时文件。
PCT/CN2015/086875 2014-08-13 2015-08-13 呈现文件的方法和文件呈现装置 WO2016023509A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410398501.X 2014-08-13
CN201410398501.XA CN104199856B (zh) 2014-08-13 2014-08-13 呈现文件的方法和文件呈现装置

Publications (1)

Publication Number Publication Date
WO2016023509A1 true WO2016023509A1 (zh) 2016-02-18

Family

ID=52085149

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/086875 WO2016023509A1 (zh) 2014-08-13 2015-08-13 呈现文件的方法和文件呈现装置

Country Status (2)

Country Link
CN (1) CN104199856B (zh)
WO (1) WO2016023509A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104199856B (zh) * 2014-08-13 2021-04-06 北京配天技术有限公司 呈现文件的方法和文件呈现装置
WO2017113317A1 (zh) * 2015-12-31 2017-07-06 深圳配天智能技术研究院有限公司 一种文件编辑方法和文件编辑器

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
FR2829845A1 (fr) * 2001-09-17 2003-03-21 Pierre Schweitzer Procede pour la visualisation d'un document sur un equipement portatif
CN102567285A (zh) * 2010-12-13 2012-07-11 汉王科技股份有限公司 一种文档加载的方法及装置
CN102768662A (zh) * 2011-05-05 2012-11-07 阿里巴巴集团控股有限公司 一种加载图片的方法和装置
CN103176952A (zh) * 2011-12-20 2013-06-26 北大方正集团有限公司 文档显示方法和装置
CN104199856A (zh) * 2014-08-13 2014-12-10 北京配天技术有限公司 呈现文件的方法和文件呈现装置

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100553326C (zh) * 2005-10-21 2009-10-21 深圳Tcl新技术有限公司 通过电视的动态用户操作界面实现快速搜索的方法
CN100429658C (zh) * 2006-09-07 2008-10-29 北京优纳科技有限公司 大容量快速图像浏览系统
CN101059949B (zh) * 2007-04-03 2010-05-26 广东威创视讯科技股份有限公司 海量图像数据的压缩、存储和显示方法
CN101127578A (zh) * 2007-09-14 2008-02-20 广东威创日新电子有限公司 一种处理海量数据的方法及系统
CN101763407B (zh) * 2009-11-19 2012-05-30 青岛海信移动通信技术股份有限公司 一种基于Brew平台的txt文件阅读方法及其阅读器

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
FR2829845A1 (fr) * 2001-09-17 2003-03-21 Pierre Schweitzer Procede pour la visualisation d'un document sur un equipement portatif
CN102567285A (zh) * 2010-12-13 2012-07-11 汉王科技股份有限公司 一种文档加载的方法及装置
CN102768662A (zh) * 2011-05-05 2012-11-07 阿里巴巴集团控股有限公司 一种加载图片的方法和装置
CN103176952A (zh) * 2011-12-20 2013-06-26 北大方正集团有限公司 文档显示方法和装置
CN104199856A (zh) * 2014-08-13 2014-12-10 北京配天技术有限公司 呈现文件的方法和文件呈现装置

Also Published As

Publication number Publication date
CN104199856A (zh) 2014-12-10
CN104199856B (zh) 2021-04-06

Similar Documents

Publication Publication Date Title
WO2013043004A2 (en) Apparatus and method for controlling screen rotation in a portable terminal
WO2013078899A1 (zh) 一种基于手机的软件处理方法及手机
WO2018076868A1 (zh) 一种数据同步方法、装置、系统、存储介质和服务器
WO2015016516A1 (en) Method and device for managing tab window indicating application group including heterogeneous applications
WO2018076865A1 (zh) 数据分享方法、装置、存储介质及电子设备
WO2018076841A1 (zh) 数据分享方法、装置、存储介质及服务器
WO2018076867A1 (zh) 数据备份的删除方法、装置、系统、存储介质和服务器
WO2018120681A1 (zh) 数据同步方法、装置、系统、数据处理服务器和存储介质
WO2018076844A1 (zh) 数据备份的方法、装置、存储介质及电子设备
WO2014038824A1 (en) Method for changing object position and electronic device thereof
WO2015020417A1 (en) Method for displaying and an electronic device thereof
WO2018056642A2 (en) Electronic device and method thereof for managing applications
WO2018076869A1 (zh) 一种数据备份方法、装置、存储介质和电子设备
WO2020256301A1 (en) Electronic device including storage and method for using the storage
WO2014029170A1 (zh) 电容和电磁双模触摸屏的触控方法及手持式电子设备
WO2013091456A1 (zh) 桌面管理方法和装置
WO2018076829A1 (zh) 终端数据的处理方法、装置、系统、存储介质及服务器
WO2018161580A1 (zh) 广播的控制方法、装置、存储介质及电子设备
WO2017206879A1 (zh) 一种移动终端应用程序的处理方法、装置、存储介质及电子设备
WO2016056856A1 (ko) 무결성 검증 데이터 생성 방법 및 시스템
WO2020062615A1 (zh) 显示面板的伽马值调节方法、装置及显示设备
WO2016023509A1 (zh) 呈现文件的方法和文件呈现装置
WO2017045418A1 (zh) 一种基于内存剩余容量调节照相机帧率的方法及系统
EP3025225A1 (en) Method for displaying and an electronic device thereof
WO2015088196A1 (ko) 자막 편집 장치 및 자막 편집 방법

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15832577

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205N DATED 21/04/2017)

122 Ep: pct application non-entry in european phase

Ref document number: 15832577

Country of ref document: EP

Kind code of ref document: A1