2003-04-26 13:07:59 +00:00
|
|
|
/* text.c
|
|
|
|
*
|
|
|
|
*
|
2002-10-12 11:37:38 +00:00
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version. The Blender
|
|
|
|
* Foundation also sells licenses for use in proprietary software under
|
|
|
|
* the Blender License. See http://www.blender.org/BL/ for information
|
|
|
|
* about this.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
|
|
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h> /* strstr */
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_text_types.h"
|
|
|
|
|
|
|
|
#include "BKE_utildefines.h"
|
|
|
|
#include "BKE_text.h"
|
|
|
|
#include "BKE_library.h"
|
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_main.h"
|
|
|
|
|
2003-11-23 14:28:46 +00:00
|
|
|
#include "BPY_extern.h"
|
|
|
|
|
2002-11-25 12:02:15 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/***************/ /*
|
|
|
|
|
|
|
|
How Texts should work
|
|
|
|
--
|
|
|
|
A text should relate to a file as follows -
|
|
|
|
(Text *)->name should be the place where the
|
|
|
|
file will or has been saved.
|
|
|
|
|
|
|
|
(Text *)->flags has the following bits
|
|
|
|
TXT_ISDIRTY - should always be set if the file in mem. differs from
|
|
|
|
the file on disk, or if there is no file on disk.
|
|
|
|
TXT_ISTMP - should always be set if the (Text *)->name file has not
|
|
|
|
been written before, and attempts to save should result
|
|
|
|
in "Save over?"
|
|
|
|
TXT_ISMEM - should always be set if the Text has not been mapped to
|
|
|
|
a file, in which case (Text *)->name may be NULL or garbage.
|
|
|
|
TXT_ISEXT - should always be set if the Text is not to be written into
|
|
|
|
the .blend
|
|
|
|
TXT_ISSCRIPT - should be set if the user has designated the text
|
BPython:
- Made Blender.event var (previously only used by script links) hold ascii value -- where it applies -- of current event during events callback registered with Draw.Register(gui, events, button_events). Useful for gui scripts like Campbell's Python console. No problem using this var to hold the value, since in gui scripts it was not used (always None).
- Updated Window and Window.Theme with new theme vars and the Time space.
- Script links:
-- Added "Render" event for script links (runs twice, second time as "PostEvent", for clean-up actions). Now FrameChanged links don't run when a single pic is rendered.
-- Added "Enable Script Links" button in the script buttons tab. Now this bit gets saved in .blends along with the rest of G.f, so users can define per .blend if they are on or off by default. "blender -y" also disables all slinks as happened before with OnLoad ones only.
-- Other small changes in the script buttons tab:
When a link is added (button "new"), it becomes the active one for the window, no need to press a button to reach it.
Also, a pupmenu showing all available texts is shown when "new" is pressed, so users can choose a text w/o having to type. Cancel the popup to leave the string button empty (link exists, but has no script assigned). A pulldown would be better UI-wise, but it's kinda weird to show both scripts and normal texts (Blender doesn't differentiate them) in a script links pulldown. With a popup we can show only texts ending in ".py" (not done in this commit, need opinions) and if the script has no or another extension, case of many in old and current .blend's, there's still the string box for writing its name.
-- Implemented Ton's space handler script links:
Right now only for the 3d View, but it's trivial to add for others. There are two types: EVENT, to receive 3d View events from a chosen window and DRAW, to draw on the window. Ton's idea was to give scripts a controlled way to integrate better within Blender.
Here's how it works:
- scripts must have a proper header, like:
# SPACEHANDLER.VIEW3D.EVENT
and then they are shown in 3d View's View menu, "Space Handler Scripts" submenu. Check (mark, click on it) a script to make it active.
EVENT handlers should consult the Blender.event var to get the current event, which can be compared with values from the Draw module:
import Blender
from Blender import Draw
evt = Blender.event
if evt == Draw.AKEY:
print "a"
elif evt == Draw.LEFTMOUSE:
print "left mouse button"
else:
return # ignore, pass event back to Blender
Blender.event = None # tell Blender not to process itself the event
DRAW handlers are free to draw to their owner 3D View. OpenGL attributes and modelview and projection matrices are pushed before running the handler and poped when it finishes.
To communicate between EVENT and DRAW handler scripts we have the Blender.Registry module, as always.
Still need to code some nice example, which should also serve to test properly space handlers. Simple tests went fine.
- doc updates about the additions.
=======
Note: the UI part of the space handlers and script links is of course open for changes, I just tried to make it understandable. Probably we won't use the scriptlinks icon for "None Available" (check 3d View -> View -> Space Handler Scripts), though it hints at what space handlers are. The tooltips may not be accepted either, since other menus don't use them. Opinions welcomed.
2005-05-08 21:20:34 +00:00
|
|
|
as a script. (NEW: this was unused, but now it is needed by
|
|
|
|
space handler script links (see header_view3d.c, for example)
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
->>> see also: /makesdna/DNA_text_types.h
|
|
|
|
|
|
|
|
Display
|
|
|
|
--
|
|
|
|
The st->top determines at what line the top of the text is displayed.
|
|
|
|
If the user moves the cursor the st containing that cursor should
|
|
|
|
be popped ... other st's retain their own top location.
|
|
|
|
|
|
|
|
*/ /***************/
|
|
|
|
|
|
|
|
|
|
|
|
/****************/ /*
|
|
|
|
Undo
|
|
|
|
|
|
|
|
Undo/Redo works by storing
|
|
|
|
events in a queue, and a pointer
|
|
|
|
to the current position in the
|
|
|
|
queue...
|
|
|
|
|
|
|
|
Events are stored using an
|
|
|
|
arbitrary op-code system
|
|
|
|
to keep track of
|
|
|
|
a) the two cursors (normal and selected)
|
|
|
|
b) input (visible and control (ie backspace))
|
|
|
|
|
|
|
|
input data is stored as its
|
|
|
|
ASCII value, the opcodes are
|
|
|
|
then selected to not conflict.
|
|
|
|
|
|
|
|
opcodes with data in between are
|
|
|
|
written at the beginning and end
|
|
|
|
of the data to allow undo and redo
|
|
|
|
to simply check the code at the current
|
|
|
|
undo position
|
|
|
|
|
|
|
|
*/ /***************/
|
|
|
|
|
|
|
|
/***/
|
|
|
|
|
|
|
|
static void txt_pop_first(Text *text);
|
|
|
|
static void txt_pop_last(Text *text);
|
|
|
|
static void txt_undo_add_op(Text *text, int op);
|
|
|
|
static void txt_undo_add_block(Text *text, int op, char *buf);
|
|
|
|
static void txt_delete_line(Text *text, TextLine *line);
|
|
|
|
|
|
|
|
/***/
|
|
|
|
|
|
|
|
static char *txt_cut_buffer= NULL;
|
|
|
|
static unsigned char undoing;
|
|
|
|
|
|
|
|
/* allow to switch off undoing externally */
|
|
|
|
void txt_set_undostate(int u)
|
|
|
|
{
|
|
|
|
undoing = u;
|
|
|
|
}
|
|
|
|
|
|
|
|
int txt_get_undostate(void)
|
|
|
|
{
|
|
|
|
return undoing;
|
|
|
|
}
|
|
|
|
|
|
|
|
void free_text(Text *text)
|
|
|
|
{
|
|
|
|
TextLine *tmp;
|
2005-05-13 16:11:28 +00:00
|
|
|
|
|
|
|
for (tmp= text->lines.first; tmp; tmp= tmp->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
MEM_freeN(tmp->line);
|
2005-05-13 16:11:28 +00:00
|
|
|
if (tmp->format)
|
|
|
|
MEM_freeN(tmp->format);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
BLI_freelistN(&text->lines);
|
|
|
|
|
|
|
|
if(text->name) MEM_freeN(text->name);
|
|
|
|
MEM_freeN(text->undo_buf);
|
2003-12-14 01:18:09 +00:00
|
|
|
if (text->compiled) BPY_free_compiled_text(text);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2007-03-11 16:25:17 +00:00
|
|
|
Text *add_empty_text(char *name)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
Text *ta;
|
|
|
|
TextLine *tmp;
|
|
|
|
|
2007-03-12 06:21:58 +00:00
|
|
|
ta= alloc_libblock(&G.main->text, ID_TXT, name);
|
2002-10-12 11:37:38 +00:00
|
|
|
ta->id.us= 1;
|
|
|
|
|
|
|
|
ta->name= NULL;
|
|
|
|
|
|
|
|
ta->undo_pos= -1;
|
|
|
|
ta->undo_len= TXT_INIT_UNDO;
|
|
|
|
ta->undo_buf= MEM_mallocN(ta->undo_len, "undo buf");
|
|
|
|
|
|
|
|
ta->nlines=1;
|
|
|
|
ta->flags= TXT_ISDIRTY | TXT_ISTMP | TXT_ISMEM;
|
|
|
|
|
|
|
|
ta->lines.first= ta->lines.last= NULL;
|
|
|
|
|
|
|
|
tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline");
|
|
|
|
tmp->line= (char*) MEM_mallocN(1, "textline_string");
|
2005-05-13 16:11:28 +00:00
|
|
|
tmp->format= (char*) MEM_mallocN(2, "Syntax_format");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
tmp->line[0]=0;
|
|
|
|
tmp->len= 0;
|
|
|
|
|
|
|
|
tmp->next= NULL;
|
|
|
|
tmp->prev= NULL;
|
|
|
|
|
|
|
|
BLI_addhead(&ta->lines, tmp);
|
|
|
|
|
|
|
|
ta->curl= ta->lines.first;
|
|
|
|
ta->curc= 0;
|
|
|
|
ta->sell= ta->lines.first;
|
|
|
|
ta->selc= 0;
|
|
|
|
|
|
|
|
return ta;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this function removes any control characters from
|
|
|
|
// a textline
|
|
|
|
|
|
|
|
static void cleanup_textline(TextLine * tl)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < tl->len; i++ ) {
|
|
|
|
if (tl->line[i] < ' ' && tl->line[i] != '\t') {
|
|
|
|
memmove(tl->line + i, tl->line + i + 1, tl->len - i);
|
|
|
|
tl->len--;
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int reopen_text(Text *text)
|
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
int i, llen, len;
|
|
|
|
unsigned char *buffer;
|
|
|
|
TextLine *tmp;
|
|
|
|
char sdir[FILE_MAXDIR];
|
|
|
|
char sfile[FILE_MAXFILE];
|
2005-11-06 16:32:54 +00:00
|
|
|
char str[FILE_MAXDIR+FILE_MAXFILE];
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
if (!text || !text->name) return 0;
|
|
|
|
|
2005-11-06 16:32:54 +00:00
|
|
|
BLI_strncpy(str, text->name, FILE_MAXDIR+FILE_MAXFILE);
|
|
|
|
BLI_convertstringcode(str, G.sce, G.scene->r.cfra);
|
|
|
|
BLI_split_dirfile(str, sdir, sfile);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-11-06 16:32:54 +00:00
|
|
|
fp= fopen(str, "r");
|
2002-10-12 11:37:38 +00:00
|
|
|
if(fp==NULL) return 0;
|
|
|
|
|
|
|
|
/* free memory: */
|
|
|
|
|
2005-05-13 16:11:28 +00:00
|
|
|
for (tmp= text->lines.first; tmp; tmp= tmp->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
MEM_freeN(tmp->line);
|
2005-05-19 03:15:49 +00:00
|
|
|
if (tmp->format) MEM_freeN(tmp->format);
|
2005-05-13 16:11:28 +00:00
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_freelistN(&text->lines);
|
|
|
|
|
|
|
|
text->lines.first= text->lines.last= NULL;
|
|
|
|
text->curl= text->sell= NULL;
|
|
|
|
|
|
|
|
/* clear undo buffer */
|
|
|
|
MEM_freeN(text->undo_buf);
|
|
|
|
text->undo_pos= -1;
|
|
|
|
text->undo_len= TXT_INIT_UNDO;
|
|
|
|
text->undo_buf= MEM_mallocN(text->undo_len, "undo buf");
|
|
|
|
|
|
|
|
text->flags= TXT_ISDIRTY | TXT_ISTMP;
|
|
|
|
|
|
|
|
fseek(fp, 0L, SEEK_END);
|
|
|
|
len= ftell(fp);
|
|
|
|
fseek(fp, 0L, SEEK_SET);
|
|
|
|
|
|
|
|
text->undo_pos= -1;
|
|
|
|
|
|
|
|
buffer= MEM_mallocN(len, "text_buffer");
|
|
|
|
// under windows fread can return less then len bytes because
|
|
|
|
// of CR stripping
|
|
|
|
len = fread(buffer, 1, len, fp);
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
text->nlines=0;
|
|
|
|
i=0;
|
|
|
|
llen=0;
|
|
|
|
for(i=0; i<len; i++) {
|
|
|
|
if (buffer[i]=='\n') {
|
|
|
|
tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline");
|
|
|
|
tmp->line= (char*) MEM_mallocN(llen+1, "textline_string");
|
2005-05-13 16:11:28 +00:00
|
|
|
tmp->format= (char*) MEM_mallocN(llen+2, "Syntax_format");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if(llen) memcpy(tmp->line, &buffer[i-llen], llen);
|
|
|
|
tmp->line[llen]=0;
|
|
|
|
tmp->len= llen;
|
|
|
|
|
|
|
|
cleanup_textline(tmp);
|
|
|
|
|
|
|
|
BLI_addtail(&text->lines, tmp);
|
|
|
|
text->nlines++;
|
|
|
|
|
|
|
|
llen=0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
llen++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (llen!=0 || text->nlines==0) {
|
|
|
|
tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline");
|
|
|
|
tmp->line= (char*) MEM_mallocN(llen+1, "textline_string");
|
2005-05-13 16:11:28 +00:00
|
|
|
tmp->format= (char*) MEM_mallocN(llen+2, "Syntax_format");
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
if(llen) memcpy(tmp->line, &buffer[i-llen], llen);
|
|
|
|
|
|
|
|
tmp->line[llen]=0;
|
|
|
|
tmp->len= llen;
|
|
|
|
|
|
|
|
cleanup_textline(tmp);
|
|
|
|
|
|
|
|
BLI_addtail(&text->lines, tmp);
|
|
|
|
text->nlines++;
|
|
|
|
}
|
|
|
|
|
|
|
|
text->curl= text->sell= text->lines.first;
|
|
|
|
text->curc= text->selc= 0;
|
|
|
|
|
|
|
|
MEM_freeN(buffer);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Text *add_text(char *file)
|
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
int i, llen, len;
|
|
|
|
unsigned char *buffer;
|
|
|
|
TextLine *tmp;
|
|
|
|
Text *ta;
|
|
|
|
char sdir[FILE_MAXDIR];
|
|
|
|
char sfile[FILE_MAXFILE];
|
2005-11-06 16:32:54 +00:00
|
|
|
char str[FILE_MAXDIR+FILE_MAXFILE];
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-11-06 16:32:54 +00:00
|
|
|
BLI_strncpy(str, file, FILE_MAXDIR+FILE_MAXFILE);
|
2006-01-06 20:15:18 +00:00
|
|
|
if (G.scene) /* can be NULL (bg mode) */
|
|
|
|
BLI_convertstringcode(str, G.sce, G.scene->r.cfra);
|
2005-11-06 16:32:54 +00:00
|
|
|
BLI_split_dirfile(str, sdir, sfile);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-11-06 16:32:54 +00:00
|
|
|
fp= fopen(str, "r");
|
2002-10-12 11:37:38 +00:00
|
|
|
if(fp==NULL) return NULL;
|
|
|
|
|
|
|
|
ta= alloc_libblock(&G.main->text, ID_TXT, sfile);
|
|
|
|
ta->id.us= 1;
|
|
|
|
|
|
|
|
ta->lines.first= ta->lines.last= NULL;
|
|
|
|
ta->curl= ta->sell= NULL;
|
|
|
|
|
|
|
|
/* ta->flags= TXT_ISTMP | TXT_ISEXT; */
|
|
|
|
ta->flags= TXT_ISTMP;
|
|
|
|
|
|
|
|
fseek(fp, 0L, SEEK_END);
|
|
|
|
len= ftell(fp);
|
|
|
|
fseek(fp, 0L, SEEK_SET);
|
|
|
|
|
|
|
|
ta->name= MEM_mallocN(strlen(file)+1, "text_name");
|
|
|
|
strcpy(ta->name, file);
|
|
|
|
|
|
|
|
ta->undo_pos= -1;
|
|
|
|
ta->undo_len= TXT_INIT_UNDO;
|
|
|
|
ta->undo_buf= MEM_mallocN(ta->undo_len, "undo buf");
|
|
|
|
|
|
|
|
buffer= MEM_mallocN(len, "text_buffer");
|
|
|
|
// under windows fread can return less then len bytes because
|
|
|
|
// of CR stripping
|
|
|
|
len = fread(buffer, 1, len, fp);
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
ta->nlines=0;
|
|
|
|
i=0;
|
|
|
|
llen=0;
|
|
|
|
for(i=0; i<len; i++) {
|
|
|
|
if (buffer[i]=='\n') {
|
|
|
|
tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline");
|
|
|
|
tmp->line= (char*) MEM_mallocN(llen+1, "textline_string");
|
2005-05-13 16:11:28 +00:00
|
|
|
tmp->format= (char*) MEM_mallocN(llen+2, "Syntax_format");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if(llen) memcpy(tmp->line, &buffer[i-llen], llen);
|
|
|
|
tmp->line[llen]=0;
|
|
|
|
tmp->len= llen;
|
|
|
|
|
|
|
|
cleanup_textline(tmp);
|
|
|
|
|
|
|
|
BLI_addtail(&ta->lines, tmp);
|
|
|
|
ta->nlines++;
|
|
|
|
|
|
|
|
llen=0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
llen++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (llen!=0 || ta->nlines==0) {
|
|
|
|
tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline");
|
|
|
|
tmp->line= (char*) MEM_mallocN(llen+1, "textline_string");
|
2005-05-13 16:11:28 +00:00
|
|
|
tmp->format= (char*) MEM_mallocN(llen+2, "Syntax_format");
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
if(llen) memcpy(tmp->line, &buffer[i-llen], llen);
|
|
|
|
|
|
|
|
tmp->line[llen]=0;
|
|
|
|
tmp->len= llen;
|
|
|
|
|
|
|
|
cleanup_textline(tmp);
|
|
|
|
|
|
|
|
BLI_addtail(&ta->lines, tmp);
|
|
|
|
ta->nlines++;
|
|
|
|
}
|
|
|
|
|
|
|
|
ta->curl= ta->sell= ta->lines.first;
|
|
|
|
ta->curc= ta->selc= 0;
|
|
|
|
|
|
|
|
MEM_freeN(buffer);
|
|
|
|
|
|
|
|
return ta;
|
|
|
|
}
|
|
|
|
|
|
|
|
Text *copy_text(Text *ta)
|
|
|
|
{
|
|
|
|
Text *tan;
|
|
|
|
TextLine *line, *tmp;
|
|
|
|
|
|
|
|
tan= copy_libblock(ta);
|
|
|
|
|
|
|
|
tan->name= MEM_mallocN(strlen(ta->name)+1, "text_name");
|
|
|
|
strcpy(tan->name, ta->name);
|
|
|
|
|
|
|
|
tan->flags = ta->flags | TXT_ISDIRTY | TXT_ISTMP;
|
|
|
|
|
|
|
|
tan->lines.first= tan->lines.last= NULL;
|
|
|
|
tan->curl= tan->sell= NULL;
|
|
|
|
|
|
|
|
tan->nlines= ta->nlines;
|
|
|
|
|
|
|
|
line= ta->lines.first;
|
|
|
|
/* Walk down, reconstructing */
|
|
|
|
while (line) {
|
|
|
|
tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline");
|
|
|
|
tmp->line= MEM_mallocN(line->len+1, "textline_string");
|
2005-05-13 16:11:28 +00:00
|
|
|
tmp->format= MEM_mallocN(line->len+2, "Syntax_format");
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-05-13 16:11:28 +00:00
|
|
|
strcpy(tmp->line, line->line);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
tmp->len= line->len;
|
|
|
|
|
|
|
|
BLI_addtail(&tan->lines, tmp);
|
|
|
|
|
|
|
|
line= line->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
tan->curl= tan->sell= tan->lines.first;
|
|
|
|
tan->curc= tan->selc= 0;
|
|
|
|
|
|
|
|
return tan;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************/
|
|
|
|
/* Editing utility functions */
|
|
|
|
/*****************************/
|
|
|
|
|
2005-05-13 16:11:28 +00:00
|
|
|
static void make_new_line (TextLine *line, char *newline, char *newformat)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2005-05-18 23:54:56 +00:00
|
|
|
if (line->line) MEM_freeN(line->line);
|
|
|
|
if (line->format) MEM_freeN(line->format);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
line->line= newline;
|
2005-05-13 16:11:28 +00:00
|
|
|
line->len= strlen(newline);
|
|
|
|
line->format= newformat;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static TextLine *txt_new_line(char *str)
|
|
|
|
{
|
|
|
|
TextLine *tmp;
|
|
|
|
|
|
|
|
if(!str) str= "";
|
|
|
|
|
|
|
|
tmp= (TextLine *) MEM_mallocN(sizeof(TextLine), "textline");
|
|
|
|
tmp->line= MEM_mallocN(strlen(str)+1, "textline_string");
|
2005-05-13 16:11:28 +00:00
|
|
|
tmp->format= MEM_mallocN(strlen(str)+2, "Syntax_format");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
strcpy(tmp->line, str);
|
|
|
|
|
|
|
|
tmp->len= strlen(str);
|
|
|
|
tmp->next= tmp->prev= NULL;
|
|
|
|
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
static TextLine *txt_new_linen(char *str, int n)
|
|
|
|
{
|
|
|
|
TextLine *tmp;
|
|
|
|
|
|
|
|
if(!str) str= "";
|
|
|
|
|
|
|
|
tmp= (TextLine *) MEM_mallocN(sizeof(TextLine), "textline");
|
|
|
|
tmp->line= MEM_mallocN(n+1, "textline_string");
|
2005-05-13 16:11:28 +00:00
|
|
|
tmp->format= MEM_mallocN(n+2, "Syntax_format");
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_strncpy(tmp->line, str, n+1);
|
|
|
|
|
|
|
|
tmp->len= strlen(tmp->line);
|
|
|
|
tmp->next= tmp->prev= NULL;
|
|
|
|
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_clean_text (Text *text)
|
|
|
|
{
|
|
|
|
TextLine **top, **bot;
|
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
|
|
|
|
if (!text->lines.first) {
|
|
|
|
if (text->lines.last) text->lines.first= text->lines.last;
|
|
|
|
else text->lines.first= text->lines.last= txt_new_line(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!text->lines.last) text->lines.last= text->lines.first;
|
|
|
|
|
|
|
|
top= (TextLine **) &text->lines.first;
|
|
|
|
bot= (TextLine **) &text->lines.last;
|
|
|
|
|
|
|
|
while ((*top)->prev) *top= (*top)->prev;
|
|
|
|
while ((*bot)->next) *bot= (*bot)->next;
|
|
|
|
|
|
|
|
if(!text->curl) {
|
|
|
|
if(text->sell) text->curl= text->sell;
|
|
|
|
else text->curl= text->lines.first;
|
|
|
|
text->curc= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!text->sell) {
|
|
|
|
text->sell= text->curl;
|
|
|
|
text->selc= 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int txt_get_span (TextLine *from, TextLine *to)
|
|
|
|
{
|
|
|
|
int ret=0;
|
|
|
|
TextLine *tmp= from;
|
|
|
|
|
|
|
|
if (!to || !from) return 0;
|
|
|
|
if (from==to) return 0;
|
|
|
|
|
|
|
|
/* Look forwards */
|
|
|
|
while (tmp) {
|
|
|
|
if (tmp == to) return ret;
|
|
|
|
ret++;
|
|
|
|
tmp= tmp->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look backwards */
|
|
|
|
if (!tmp) {
|
|
|
|
tmp= from;
|
|
|
|
ret=0;
|
|
|
|
while(tmp) {
|
|
|
|
if (tmp == to) break;
|
|
|
|
ret--;
|
|
|
|
tmp= tmp->prev;
|
|
|
|
}
|
|
|
|
if(!tmp) ret=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void txt_make_dirty (Text *text)
|
|
|
|
{
|
|
|
|
text->flags |= TXT_ISDIRTY;
|
|
|
|
if (text->compiled) BPY_free_compiled_text(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************/
|
|
|
|
/* Cursor utility functions */
|
|
|
|
/****************************/
|
|
|
|
|
|
|
|
static void txt_curs_cur (Text *text, TextLine ***linep, int **charp)
|
|
|
|
{
|
|
|
|
*linep= &text->curl; *charp= &text->curc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void txt_curs_sel (Text *text, TextLine ***linep, int **charp)
|
|
|
|
{
|
|
|
|
*linep= &text->sell; *charp= &text->selc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void txt_curs_first (Text *text, TextLine **linep, int *charp)
|
|
|
|
{
|
|
|
|
if (text->curl==text->sell) {
|
|
|
|
*linep= text->curl;
|
|
|
|
if (text->curc<text->selc) *charp= text->curc;
|
|
|
|
else *charp= text->selc;
|
|
|
|
} else if (txt_get_span(text->lines.first, text->curl)<txt_get_span(text->lines.first, text->sell)) {
|
|
|
|
*linep= text->curl;
|
|
|
|
*charp= text->curc;
|
|
|
|
} else {
|
|
|
|
*linep= text->sell;
|
|
|
|
*charp= text->selc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************/
|
|
|
|
/* Cursor movement functions */
|
|
|
|
/****************************/
|
|
|
|
|
|
|
|
void txt_move_up(Text *text, short sel)
|
|
|
|
{
|
|
|
|
TextLine **linep;
|
|
|
|
int *charp, old;
|
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
if(sel) txt_curs_sel(text, &linep, &charp);
|
|
|
|
else { txt_pop_first(text); txt_curs_cur(text, &linep, &charp); }
|
|
|
|
if (!*linep) return;
|
|
|
|
old= *charp;
|
|
|
|
|
|
|
|
if((*linep)->prev) {
|
|
|
|
*linep= (*linep)->prev;
|
|
|
|
if (*charp > (*linep)->len) {
|
|
|
|
*charp= (*linep)->len;
|
|
|
|
if(!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, (*linep)->next), old, txt_get_span(text->lines.first, *linep), (unsigned short) *charp);
|
|
|
|
} else {
|
|
|
|
if(!undoing) txt_undo_add_op(text, sel?UNDO_SUP:UNDO_CUP);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
*charp= 0;
|
|
|
|
if(!undoing) txt_undo_add_op(text, sel?UNDO_SUP:UNDO_CUP);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!sel) txt_pop_sel(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_move_down(Text *text, short sel)
|
|
|
|
{
|
|
|
|
TextLine **linep;
|
|
|
|
int *charp, old;
|
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
if(sel) txt_curs_sel(text, &linep, &charp);
|
|
|
|
else { txt_pop_last(text); txt_curs_cur(text, &linep, &charp); }
|
|
|
|
if (!*linep) return;
|
|
|
|
old= *charp;
|
|
|
|
|
|
|
|
if((*linep)->next) {
|
|
|
|
*linep= (*linep)->next;
|
|
|
|
if (*charp > (*linep)->len) {
|
|
|
|
*charp= (*linep)->len;
|
|
|
|
if(!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, (*linep)->prev), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
|
|
|
|
} else
|
|
|
|
if(!undoing) txt_undo_add_op(text, sel?UNDO_SDOWN:UNDO_CDOWN);
|
|
|
|
} else {
|
|
|
|
*charp= (*linep)->len;
|
|
|
|
if(!undoing) txt_undo_add_op(text, sel?UNDO_SDOWN:UNDO_CDOWN);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!sel) txt_pop_sel(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_move_left(Text *text, short sel)
|
|
|
|
{
|
|
|
|
TextLine **linep;
|
|
|
|
int *charp, oundoing= undoing;
|
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
if(sel) txt_curs_sel(text, &linep, &charp);
|
|
|
|
else { txt_pop_first(text); txt_curs_cur(text, &linep, &charp); }
|
|
|
|
if (!*linep) return;
|
|
|
|
|
|
|
|
undoing= 1;
|
|
|
|
if (*charp== 0) {
|
|
|
|
if ((*linep)->prev) {
|
|
|
|
txt_move_up(text, sel);
|
|
|
|
*charp= (*linep)->len;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
(*charp)--;
|
|
|
|
}
|
|
|
|
undoing= oundoing;
|
|
|
|
if(!undoing) txt_undo_add_op(text, sel?UNDO_SLEFT:UNDO_CLEFT);
|
|
|
|
|
|
|
|
if(!sel) txt_pop_sel(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_move_right(Text *text, short sel)
|
|
|
|
{
|
|
|
|
TextLine **linep;
|
|
|
|
int *charp, oundoing= undoing;
|
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
if(sel) txt_curs_sel(text, &linep, &charp);
|
|
|
|
else { txt_pop_last(text); txt_curs_cur(text, &linep, &charp); }
|
|
|
|
if (!*linep) return;
|
|
|
|
|
|
|
|
undoing= 1;
|
|
|
|
if (*charp== (*linep)->len) {
|
|
|
|
if ((*linep)->next) {
|
|
|
|
txt_move_down(text, sel);
|
|
|
|
*charp= 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
(*charp)++;
|
|
|
|
}
|
|
|
|
undoing= oundoing;
|
|
|
|
if(!undoing) txt_undo_add_op(text, sel?UNDO_SRIGHT:UNDO_CRIGHT);
|
|
|
|
|
|
|
|
if(!sel) txt_pop_sel(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_move_bol (Text *text, short sel)
|
|
|
|
{
|
|
|
|
TextLine **linep;
|
|
|
|
int *charp, old;
|
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
if(sel) txt_curs_sel(text, &linep, &charp);
|
|
|
|
else txt_curs_cur(text, &linep, &charp);
|
|
|
|
if (!*linep) return;
|
|
|
|
old= *charp;
|
|
|
|
|
|
|
|
*charp= 0;
|
|
|
|
|
|
|
|
if(!sel) txt_pop_sel(text);
|
|
|
|
if(!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_move_eol (Text *text, short sel)
|
|
|
|
{
|
|
|
|
TextLine **linep;
|
|
|
|
int *charp, old;
|
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
if(sel) txt_curs_sel(text, &linep, &charp);
|
|
|
|
else txt_curs_cur(text, &linep, &charp);
|
|
|
|
if (!*linep) return;
|
|
|
|
old= *charp;
|
|
|
|
|
|
|
|
*charp= (*linep)->len;
|
|
|
|
|
|
|
|
if(!sel) txt_pop_sel(text);
|
|
|
|
if(!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_move_bof (Text *text, short sel)
|
|
|
|
{
|
|
|
|
TextLine **linep;
|
|
|
|
int *charp, old;
|
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
if(sel) txt_curs_sel(text, &linep, &charp);
|
|
|
|
else txt_curs_cur(text, &linep, &charp);
|
|
|
|
if (!*linep) return;
|
|
|
|
old= *charp;
|
|
|
|
|
|
|
|
*linep= text->lines.first;
|
|
|
|
*charp= 0;
|
|
|
|
|
|
|
|
if(!sel) txt_pop_sel(text);
|
|
|
|
if(!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_move_eof (Text *text, short sel)
|
|
|
|
{
|
|
|
|
TextLine **linep;
|
|
|
|
int *charp, old;
|
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
if(sel) txt_curs_sel(text, &linep, &charp);
|
|
|
|
else txt_curs_cur(text, &linep, &charp);
|
|
|
|
if (!*linep) return;
|
|
|
|
old= *charp;
|
|
|
|
|
|
|
|
*linep= text->lines.last;
|
|
|
|
*charp= (*linep)->len;
|
|
|
|
|
|
|
|
if(!sel) txt_pop_sel(text);
|
|
|
|
if(!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_move_toline (Text *text, unsigned int line, short sel)
|
|
|
|
{
|
|
|
|
TextLine **linep, *oldl;
|
|
|
|
int *charp, oldc;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
if(sel) txt_curs_sel(text, &linep, &charp);
|
|
|
|
else txt_curs_cur(text, &linep, &charp);
|
|
|
|
if (!*linep) return;
|
|
|
|
oldc= *charp;
|
|
|
|
oldl= *linep;
|
|
|
|
|
|
|
|
*linep= text->lines.first;
|
|
|
|
for (i=0; i<line; i++) {
|
|
|
|
if ((*linep)->next) *linep= (*linep)->next;
|
|
|
|
else break;
|
|
|
|
}
|
|
|
|
*charp= 0;
|
|
|
|
|
|
|
|
if(!sel) txt_pop_sel(text);
|
|
|
|
if(!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************/
|
|
|
|
/* Text selection functions */
|
|
|
|
/****************************/
|
|
|
|
|
|
|
|
static void txt_curs_swap (Text *text)
|
|
|
|
{
|
|
|
|
TextLine *tmpl;
|
|
|
|
int tmpc;
|
|
|
|
|
|
|
|
tmpl= text->curl;
|
|
|
|
text->curl= text->sell;
|
|
|
|
text->sell= tmpl;
|
|
|
|
|
|
|
|
tmpc= text->curc;
|
|
|
|
text->curc= text->selc;
|
|
|
|
text->selc= tmpc;
|
|
|
|
|
|
|
|
if(!undoing) txt_undo_add_op(text, UNDO_SWAP);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void txt_pop_first (Text *text)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (txt_get_span(text->curl, text->sell)<0 ||
|
|
|
|
(text->curl==text->sell && text->curc>text->selc)) {
|
|
|
|
txt_curs_swap(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!undoing) txt_undo_add_toop(text, UNDO_STO,
|
|
|
|
txt_get_span(text->lines.first, text->sell),
|
|
|
|
text->selc,
|
|
|
|
txt_get_span(text->lines.first, text->curl),
|
|
|
|
text->curc);
|
|
|
|
|
|
|
|
txt_pop_sel(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void txt_pop_last (Text *text)
|
|
|
|
{
|
|
|
|
if (txt_get_span(text->curl, text->sell)>0 ||
|
|
|
|
(text->curl==text->sell && text->curc<text->selc)) {
|
|
|
|
txt_curs_swap(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!undoing) txt_undo_add_toop(text, UNDO_STO,
|
|
|
|
txt_get_span(text->lines.first, text->sell),
|
|
|
|
text->selc,
|
|
|
|
txt_get_span(text->lines.first, text->curl),
|
|
|
|
text->curc);
|
|
|
|
|
|
|
|
txt_pop_sel(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* never used: CVS 1.19 */
|
|
|
|
/* static void txt_pop_selr (Text *text) */
|
|
|
|
|
|
|
|
void txt_pop_sel (Text *text)
|
|
|
|
{
|
|
|
|
text->sell= text->curl;
|
|
|
|
text->selc= text->curc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_order_cursors(Text *text)
|
|
|
|
{
|
|
|
|
if (!text) return;
|
|
|
|
if (!text->curl) return;
|
|
|
|
if (!text->sell) return;
|
|
|
|
|
|
|
|
/* Flip so text->curl is before text->sell */
|
|
|
|
if (txt_get_span(text->curl, text->sell)<0 ||
|
|
|
|
(text->curl==text->sell && text->curc>text->selc))
|
|
|
|
txt_curs_swap(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
int txt_has_sel(Text *text)
|
|
|
|
{
|
|
|
|
return ((text->curl!=text->sell) || (text->curc!=text->selc));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void txt_delete_sel (Text *text)
|
|
|
|
{
|
|
|
|
TextLine *tmpl;
|
2005-05-13 16:11:28 +00:00
|
|
|
char *buf, *format;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
if (!text->curl) return;
|
|
|
|
if (!text->sell) return;
|
|
|
|
|
|
|
|
if (!txt_has_sel(text)) return;
|
|
|
|
|
|
|
|
txt_order_cursors(text);
|
|
|
|
|
|
|
|
if(!undoing) {
|
|
|
|
buf= txt_sel_to_buf(text);
|
|
|
|
txt_undo_add_block(text, UNDO_DBLOCK, buf);
|
|
|
|
MEM_freeN(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
buf= MEM_mallocN(text->curc+(text->sell->len - text->selc)+1, "textline_string");
|
2005-05-13 16:11:28 +00:00
|
|
|
format= MEM_mallocN(text->curc+(text->sell->len - text->selc)+2, "Syntax_format");
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
strncpy(buf, text->curl->line, text->curc);
|
|
|
|
strcpy(buf+text->curc, text->sell->line + text->selc);
|
|
|
|
buf[text->curc+(text->sell->len - text->selc)]=0;
|
2005-05-13 16:11:28 +00:00
|
|
|
|
|
|
|
make_new_line(text->curl, buf, format);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
tmpl= text->sell;
|
|
|
|
while (tmpl != text->curl) {
|
|
|
|
tmpl= tmpl->prev;
|
|
|
|
if (!tmpl) break;
|
|
|
|
|
|
|
|
txt_delete_line(text, tmpl->next);
|
|
|
|
}
|
|
|
|
|
|
|
|
text->sell= text->curl;
|
|
|
|
text->selc= text->curc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_sel_all (Text *text)
|
|
|
|
{
|
|
|
|
if (!text) return;
|
|
|
|
|
|
|
|
text->curl= text->lines.first;
|
|
|
|
text->curc= 0;
|
|
|
|
|
|
|
|
text->sell= text->lines.last;
|
|
|
|
text->selc= text->sell->len;
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_sel_line (Text *text)
|
|
|
|
{
|
|
|
|
if (!text) return;
|
|
|
|
if (!text->curl) return;
|
|
|
|
|
|
|
|
text->curc= 0;
|
|
|
|
text->sell= text->curl;
|
|
|
|
text->selc= text->sell->len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************/
|
|
|
|
/* Cut and paste functions */
|
|
|
|
/***************************/
|
|
|
|
|
|
|
|
void txt_print_cutbuffer (void)
|
|
|
|
{
|
|
|
|
printf ("Cut buffer\n--\n%s\n--\n", txt_cut_buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *txt_to_buf (Text *text)
|
|
|
|
{
|
|
|
|
int length;
|
|
|
|
TextLine *tmp, *linef, *linel;
|
|
|
|
int charf, charl;
|
|
|
|
char *buf;
|
|
|
|
|
|
|
|
if (!text) return NULL;
|
|
|
|
if (!text->curl) return NULL;
|
|
|
|
if (!text->sell) return NULL;
|
|
|
|
|
|
|
|
linef= text->lines.first;
|
|
|
|
charf= 0;
|
|
|
|
|
|
|
|
linel= text->lines.last;
|
|
|
|
charl= linel->len;
|
|
|
|
|
|
|
|
if (linef == text->lines.last) {
|
|
|
|
length= charl-charf;
|
|
|
|
|
|
|
|
buf= MEM_mallocN(length+2, "text buffer");
|
|
|
|
|
|
|
|
BLI_strncpy(buf, linef->line + charf, length+1);
|
|
|
|
buf[length]=0;
|
|
|
|
} else {
|
|
|
|
length= linef->len - charf;
|
|
|
|
length+= charl;
|
|
|
|
length+= 2; /* For the 2 '\n' */
|
|
|
|
|
|
|
|
tmp= linef->next;
|
|
|
|
while (tmp && tmp!= linel) {
|
|
|
|
length+= tmp->len+1;
|
|
|
|
tmp= tmp->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf= MEM_mallocN(length+1, "cut buffer");
|
|
|
|
|
|
|
|
strncpy(buf, linef->line + charf, linef->len-charf);
|
|
|
|
length= linef->len - charf;
|
|
|
|
|
|
|
|
buf[length++]='\n';
|
|
|
|
|
|
|
|
tmp= linef->next;
|
|
|
|
while (tmp && tmp!=linel) {
|
|
|
|
strncpy(buf+length, tmp->line, tmp->len);
|
|
|
|
length+= tmp->len;
|
|
|
|
|
|
|
|
buf[length++]='\n';
|
|
|
|
|
|
|
|
tmp= tmp->next;
|
|
|
|
}
|
|
|
|
strncpy(buf+length, linel->line, charl);
|
|
|
|
length+= charl;
|
|
|
|
|
|
|
|
/* python compiler wants an empty end line */
|
|
|
|
buf[length++]='\n';
|
|
|
|
buf[length]=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
int txt_find_string(Text *text, char *findstr)
|
|
|
|
{
|
|
|
|
TextLine *tl, *startl;
|
|
|
|
char *s= NULL;
|
|
|
|
|
|
|
|
if (!text || !text->curl || !text->sell) return 0;
|
|
|
|
|
|
|
|
txt_order_cursors(text);
|
|
|
|
|
|
|
|
tl= startl= text->sell;
|
|
|
|
|
|
|
|
s= strstr(&tl->line[text->selc], findstr);
|
|
|
|
while (!s) {
|
|
|
|
tl= tl->next;
|
|
|
|
if (!tl)
|
|
|
|
tl= text->lines.first;
|
|
|
|
|
|
|
|
s= strstr(tl->line, findstr);
|
|
|
|
if (tl==startl)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s) {
|
|
|
|
text->curl= text->sell= tl;
|
|
|
|
text->curc= (int) (s-tl->line);
|
|
|
|
text->selc= text->curc + strlen(findstr);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
} else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_cut_sel (Text *text)
|
|
|
|
{
|
|
|
|
txt_copy_sel(text);
|
|
|
|
|
|
|
|
txt_delete_sel(text);
|
2003-07-10 18:32:42 +00:00
|
|
|
txt_make_dirty(text);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char *txt_sel_to_buf (Text *text)
|
|
|
|
{
|
|
|
|
char *buf;
|
|
|
|
int length=0;
|
|
|
|
TextLine *tmp, *linef, *linel;
|
|
|
|
int charf, charl;
|
|
|
|
|
|
|
|
if (!text) return NULL;
|
|
|
|
if (!text->curl) return NULL;
|
|
|
|
if (!text->sell) return NULL;
|
|
|
|
|
|
|
|
if (text->curl==text->sell) {
|
|
|
|
linef= linel= text->curl;
|
|
|
|
|
|
|
|
if (text->curc < text->selc) {
|
|
|
|
charf= text->curc;
|
|
|
|
charl= text->selc;
|
|
|
|
} else{
|
|
|
|
charf= text->selc;
|
|
|
|
charl= text->curc;
|
|
|
|
}
|
|
|
|
} else if (txt_get_span(text->curl, text->sell)<0) {
|
|
|
|
linef= text->sell;
|
|
|
|
linel= text->curl;
|
|
|
|
|
|
|
|
charf= text->selc;
|
|
|
|
charl= text->curc;
|
|
|
|
} else {
|
|
|
|
linef= text->curl;
|
|
|
|
linel= text->sell;
|
|
|
|
|
|
|
|
charf= text->curc;
|
|
|
|
charl= text->selc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (linef == linel) {
|
|
|
|
length= charl-charf;
|
|
|
|
|
|
|
|
buf= MEM_mallocN(length+1, "sel buffer");
|
|
|
|
|
|
|
|
BLI_strncpy(buf, linef->line + charf, length+1);
|
|
|
|
} else {
|
|
|
|
length+= linef->len - charf;
|
|
|
|
length+= charl;
|
|
|
|
length++; /* For the '\n' */
|
|
|
|
|
|
|
|
tmp= linef->next;
|
|
|
|
while (tmp && tmp!= linel) {
|
|
|
|
length+= tmp->len+1;
|
|
|
|
tmp= tmp->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf= MEM_mallocN(length+1, "sel buffer");
|
|
|
|
|
|
|
|
strncpy(buf, linef->line+ charf, linef->len-charf);
|
|
|
|
length= linef->len-charf;
|
|
|
|
|
|
|
|
buf[length++]='\n';
|
|
|
|
|
|
|
|
tmp= linef->next;
|
|
|
|
while (tmp && tmp!=linel) {
|
|
|
|
strncpy(buf+length, tmp->line, tmp->len);
|
|
|
|
length+= tmp->len;
|
|
|
|
|
|
|
|
buf[length++]='\n';
|
|
|
|
|
|
|
|
tmp= tmp->next;
|
|
|
|
}
|
|
|
|
strncpy(buf+length, linel->line, charl);
|
|
|
|
length+= charl;
|
|
|
|
|
|
|
|
buf[length]=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_copy_sel (Text *text)
|
|
|
|
{
|
|
|
|
int length=0;
|
|
|
|
TextLine *tmp, *linef, *linel;
|
|
|
|
int charf, charl;
|
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
if (!text->curl) return;
|
|
|
|
if (!text->sell) return;
|
|
|
|
|
|
|
|
if (!txt_has_sel(text)) return;
|
|
|
|
|
|
|
|
if (txt_cut_buffer) MEM_freeN(txt_cut_buffer);
|
|
|
|
txt_cut_buffer= NULL;
|
|
|
|
|
|
|
|
if (text->curl==text->sell) {
|
|
|
|
linef= linel= text->curl;
|
|
|
|
|
|
|
|
if (text->curc < text->selc) {
|
|
|
|
charf= text->curc;
|
|
|
|
charl= text->selc;
|
|
|
|
} else{
|
|
|
|
charf= text->selc;
|
|
|
|
charl= text->curc;
|
|
|
|
}
|
|
|
|
} else if (txt_get_span(text->curl, text->sell)<0) {
|
|
|
|
linef= text->sell;
|
|
|
|
linel= text->curl;
|
|
|
|
|
|
|
|
charf= text->selc;
|
|
|
|
charl= text->curc;
|
|
|
|
} else {
|
|
|
|
linef= text->curl;
|
|
|
|
linel= text->sell;
|
|
|
|
|
|
|
|
charf= text->curc;
|
|
|
|
charl= text->selc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (linef == linel) {
|
|
|
|
length= charl-charf;
|
|
|
|
|
|
|
|
txt_cut_buffer= MEM_mallocN(length+1, "cut buffera");
|
|
|
|
|
|
|
|
BLI_strncpy(txt_cut_buffer, linef->line + charf, length+1);
|
|
|
|
} else {
|
|
|
|
length+= linef->len - charf;
|
|
|
|
length+= charl;
|
|
|
|
length++; /* For the '\n' */
|
|
|
|
|
|
|
|
tmp= linef->next;
|
|
|
|
while (tmp && tmp!= linel) {
|
|
|
|
length+= tmp->len+1;
|
|
|
|
tmp= tmp->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
txt_cut_buffer= MEM_mallocN(length+1, "cut bufferb");
|
|
|
|
|
|
|
|
strncpy(txt_cut_buffer, linef->line+ charf, linef->len-charf);
|
|
|
|
length= linef->len-charf;
|
|
|
|
|
|
|
|
txt_cut_buffer[length++]='\n';
|
|
|
|
|
|
|
|
tmp= linef->next;
|
|
|
|
while (tmp && tmp!=linel) {
|
|
|
|
strncpy(txt_cut_buffer+length, tmp->line, tmp->len);
|
|
|
|
length+= tmp->len;
|
|
|
|
|
|
|
|
txt_cut_buffer[length++]='\n';
|
|
|
|
|
|
|
|
tmp= tmp->next;
|
|
|
|
}
|
|
|
|
strncpy(txt_cut_buffer+length, linel->line, charl);
|
|
|
|
length+= charl;
|
|
|
|
|
|
|
|
txt_cut_buffer[length]=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_insert_buf(Text *text, char *in_buffer)
|
|
|
|
{
|
|
|
|
int i=0, l=0, j, u, len;
|
|
|
|
TextLine *add;
|
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
if (!in_buffer) return;
|
|
|
|
|
|
|
|
txt_delete_sel(text);
|
|
|
|
|
|
|
|
if(!undoing) txt_undo_add_block (text, UNDO_IBLOCK, in_buffer);
|
|
|
|
|
|
|
|
u= undoing;
|
|
|
|
undoing= 1;
|
|
|
|
|
|
|
|
/* Read the first line (or as close as possible */
|
|
|
|
while (in_buffer[i] && in_buffer[i]!='\n') {
|
|
|
|
txt_add_char(text, in_buffer[i]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (in_buffer[i]=='\n') txt_split_curline(text);
|
|
|
|
else { undoing = u; return; }
|
|
|
|
i++;
|
|
|
|
|
|
|
|
/* Read as many full lines as we can */
|
|
|
|
len= strlen(in_buffer);
|
|
|
|
|
|
|
|
while (i<len) {
|
|
|
|
l=0;
|
|
|
|
|
|
|
|
while (in_buffer[i] && in_buffer[i]!='\n') {
|
|
|
|
i++; l++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(in_buffer[i]=='\n') {
|
|
|
|
add= txt_new_linen(in_buffer +(i-l), l);
|
|
|
|
BLI_insertlinkbefore(&text->lines, text->curl, add);
|
|
|
|
i++;
|
|
|
|
} else {
|
|
|
|
for (j= i-l; j<i && j<(int)strlen(in_buffer); j++) {
|
|
|
|
txt_add_char(text, in_buffer[j]);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
undoing= u;
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_free_cut_buffer(void)
|
|
|
|
{
|
|
|
|
if (txt_cut_buffer) MEM_freeN(txt_cut_buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_paste(Text *text)
|
|
|
|
{
|
|
|
|
txt_insert_buf(text, txt_cut_buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************/
|
|
|
|
/* Undo functions */
|
|
|
|
/******************/
|
|
|
|
|
|
|
|
#define MAX_UNDO_TEST(x) \
|
|
|
|
while (text->undo_pos+x >= text->undo_len) { \
|
|
|
|
if(text->undo_len*2 > TXT_MAX_UNDO) { \
|
|
|
|
error("Undo limit reached, buffer cleared\n"); \
|
|
|
|
MEM_freeN(text->undo_buf); \
|
|
|
|
text->undo_len= TXT_INIT_UNDO; \
|
|
|
|
text->undo_buf= MEM_mallocN(text->undo_len, "undo buf"); \
|
|
|
|
text->undo_pos=-1; \
|
|
|
|
return; \
|
|
|
|
} else { \
|
|
|
|
void *tmp= text->undo_buf; \
|
|
|
|
text->undo_buf= MEM_callocN(text->undo_len*2, "undo buf"); \
|
|
|
|
memcpy(text->undo_buf, tmp, text->undo_len); \
|
|
|
|
text->undo_len*=2; \
|
|
|
|
MEM_freeN(tmp); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2006-11-26 16:03:36 +00:00
|
|
|
static void dump_buffer(Text *text)
|
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
int i= 0;
|
|
|
|
|
|
|
|
while (i++<text->undo_pos) printf("%d: %d %c\n", i, text->undo_buf[i], text->undo_buf[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_print_undo(Text *text)
|
|
|
|
{
|
|
|
|
int i= 0;
|
|
|
|
int op;
|
|
|
|
char *ops;
|
|
|
|
int linep, charp;
|
|
|
|
|
|
|
|
dump_buffer(text);
|
|
|
|
|
|
|
|
printf ("---< Undo Buffer >---\n");
|
|
|
|
|
|
|
|
printf ("UndoPosition is %d\n", text->undo_pos);
|
|
|
|
|
|
|
|
while (i<=text->undo_pos) {
|
|
|
|
op= text->undo_buf[i];
|
|
|
|
|
|
|
|
if (op==UNDO_CLEFT) {
|
|
|
|
ops= "Cursor left";
|
|
|
|
} else if (op==UNDO_CRIGHT) {
|
|
|
|
ops= "Cursor right";
|
|
|
|
} else if (op==UNDO_CUP) {
|
|
|
|
ops= "Cursor up";
|
|
|
|
} else if (op==UNDO_CDOWN) {
|
|
|
|
ops= "Cursor down";
|
|
|
|
} else if (op==UNDO_SLEFT) {
|
|
|
|
ops= "Selection left";
|
|
|
|
} else if (op==UNDO_SRIGHT) {
|
|
|
|
ops= "Selection right";
|
|
|
|
} else if (op==UNDO_SUP) {
|
|
|
|
ops= "Selection up";
|
|
|
|
} else if (op==UNDO_SDOWN) {
|
|
|
|
ops= "Selection down";
|
|
|
|
} else if (op==UNDO_STO) {
|
|
|
|
ops= "Selection ";
|
|
|
|
} else if (op==UNDO_CTO) {
|
|
|
|
ops= "Cursor ";
|
|
|
|
} else if (op==UNDO_INSERT) {
|
|
|
|
ops= "Insert";
|
|
|
|
} else if (op==UNDO_BS) {
|
|
|
|
ops= "Backspace";
|
|
|
|
} else if (op==UNDO_DEL) {
|
|
|
|
ops= "Delete";
|
|
|
|
} else if (op==UNDO_SWAP) {
|
|
|
|
ops= "Cursor swap";
|
|
|
|
} else if (op==UNDO_DBLOCK) {
|
|
|
|
ops= "Delete text block";
|
|
|
|
} else if (op==UNDO_IBLOCK) {
|
|
|
|
ops= "Insert text block";
|
2005-12-12 18:35:15 +00:00
|
|
|
} else if (op==UNDO_INDENT) {
|
|
|
|
ops= "Indent ";
|
|
|
|
} else if (op==UNDO_UNINDENT) {
|
|
|
|
ops= "Unindent ";
|
|
|
|
} else if (op==UNDO_COMMENT) {
|
|
|
|
ops= "Comment ";
|
|
|
|
} else if (op==UNDO_UNCOMMENT) {
|
|
|
|
ops= "Uncomment ";
|
2002-10-12 11:37:38 +00:00
|
|
|
} else {
|
|
|
|
ops= "Unknown";
|
|
|
|
}
|
|
|
|
|
|
|
|
printf ("Op (%o) at %d = %s", op, i, ops);
|
|
|
|
if (op==UNDO_INSERT || op==UNDO_BS || op==UNDO_DEL) {
|
|
|
|
i++;
|
|
|
|
printf (" - Char is %c", text->undo_buf[i]);
|
|
|
|
i++;
|
|
|
|
} else if (op==UNDO_STO || op==UNDO_CTO) {
|
|
|
|
i++;
|
|
|
|
|
|
|
|
charp= text->undo_buf[i]; i++;
|
|
|
|
charp= charp+(text->undo_buf[i]<<8); i++;
|
|
|
|
|
|
|
|
linep= text->undo_buf[i]; i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<8); i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<16); i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<24); i++;
|
|
|
|
|
|
|
|
printf ("to <%d, %d> ", linep, charp);
|
|
|
|
|
|
|
|
charp= text->undo_buf[i]; i++;
|
|
|
|
charp= charp+(text->undo_buf[i]<<8); i++;
|
|
|
|
|
|
|
|
linep= text->undo_buf[i]; i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<8); i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<16); i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<24); i++;
|
|
|
|
|
|
|
|
printf ("from <%d, %d>", linep, charp);
|
|
|
|
} else if (op==UNDO_DBLOCK || op==UNDO_IBLOCK) {
|
|
|
|
i++;
|
|
|
|
|
|
|
|
linep= text->undo_buf[i]; i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<8); i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<16); i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<24); i++;
|
|
|
|
|
|
|
|
printf (" (length %d) <", linep);
|
|
|
|
|
|
|
|
while (linep>0) {
|
|
|
|
putchar(text->undo_buf[i]);
|
|
|
|
linep--; i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
linep= text->undo_buf[i]; i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<8); i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<16); i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<24); i++;
|
|
|
|
printf ("> (%d)", linep);
|
2005-12-12 18:35:15 +00:00
|
|
|
} else if (op==UNDO_INDENT || op==UNDO_UNINDENT) {
|
|
|
|
i++;
|
|
|
|
|
|
|
|
charp= text->undo_buf[i]; i++;
|
|
|
|
charp= charp+(text->undo_buf[i]<<8); i++;
|
|
|
|
|
|
|
|
linep= text->undo_buf[i]; i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<8); i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<16); i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<24); i++;
|
|
|
|
|
|
|
|
printf ("to <%d, %d> ", linep, charp);
|
|
|
|
|
|
|
|
charp= text->undo_buf[i]; i++;
|
|
|
|
charp= charp+(text->undo_buf[i]<<8); i++;
|
|
|
|
|
|
|
|
linep= text->undo_buf[i]; i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<8); i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<16); i++;
|
|
|
|
linep= linep+(text->undo_buf[i]<<24); i++;
|
|
|
|
|
|
|
|
printf ("from <%d, %d>", linep, charp);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
printf (" %d\n", i);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void txt_undo_add_op(Text *text, int op)
|
|
|
|
{
|
2008-01-01 18:16:10 +00:00
|
|
|
//XXX MAX_UNDO_TEST(2);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= op;
|
|
|
|
text->undo_buf[text->undo_pos+1]= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void txt_undo_add_block(Text *text, int op, char *buf)
|
|
|
|
{
|
2006-04-03 20:31:10 +00:00
|
|
|
int length;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
length= strlen(buf);
|
|
|
|
|
2008-01-01 18:16:10 +00:00
|
|
|
//XXX MAX_UNDO_TEST(length+11);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= op;
|
|
|
|
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (length)&0xff;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (length>>8)&0xff;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (length>>16)&0xff;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (length>>24)&0xff;
|
|
|
|
|
|
|
|
text->undo_pos++;
|
|
|
|
strncpy(text->undo_buf+text->undo_pos, buf, length);
|
|
|
|
text->undo_pos+=length;
|
|
|
|
|
|
|
|
text->undo_buf[text->undo_pos]= (length)&0xff;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (length>>8)&0xff;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (length>>16)&0xff;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (length>>24)&0xff;
|
|
|
|
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= op;
|
|
|
|
|
|
|
|
text->undo_buf[text->undo_pos+1]= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_undo_add_toop(Text *text, int op, unsigned int froml, unsigned short fromc, unsigned int tol, unsigned short toc)
|
|
|
|
{
|
2008-01-01 18:16:10 +00:00
|
|
|
//XXX MAX_UNDO_TEST(15);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
if (froml==tol && fromc==toc) return;
|
|
|
|
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= op;
|
|
|
|
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (fromc)&0xff;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (fromc>>8)&0xff;
|
|
|
|
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (froml)&0xff;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (froml>>8)&0xff;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (froml>>16)&0xff;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (froml>>24)&0xff;
|
|
|
|
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (toc)&0xff;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (toc>>8)&0xff;
|
|
|
|
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (tol)&0xff;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (tol>>8)&0xff;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (tol>>16)&0xff;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= (tol>>24)&0xff;
|
|
|
|
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= op;
|
|
|
|
|
|
|
|
text->undo_buf[text->undo_pos+1]= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void txt_undo_add_charop(Text *text, int op, char c)
|
|
|
|
{
|
2008-01-01 18:16:10 +00:00
|
|
|
//XXX MAX_UNDO_TEST(4);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= op;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= c;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_buf[text->undo_pos]= op;
|
|
|
|
text->undo_buf[text->undo_pos+1]= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_do_undo(Text *text)
|
|
|
|
{
|
2006-04-03 20:31:10 +00:00
|
|
|
int op= text->undo_buf[text->undo_pos];
|
|
|
|
unsigned int linep, i;
|
2002-10-12 11:37:38 +00:00
|
|
|
unsigned short charp;
|
|
|
|
TextLine *holdl;
|
|
|
|
int holdc, holdln;
|
|
|
|
char *buf;
|
|
|
|
|
|
|
|
if (text->undo_pos<0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
text->undo_pos--;
|
|
|
|
|
|
|
|
undoing= 1;
|
|
|
|
|
|
|
|
switch(op) {
|
|
|
|
case UNDO_CLEFT:
|
|
|
|
txt_move_right(text, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_CRIGHT:
|
|
|
|
txt_move_left(text, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_CUP:
|
|
|
|
txt_move_down(text, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_CDOWN:
|
|
|
|
txt_move_up(text, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_SLEFT:
|
|
|
|
txt_move_right(text, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_SRIGHT:
|
|
|
|
txt_move_left(text, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_SUP:
|
|
|
|
txt_move_down(text, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_SDOWN:
|
|
|
|
txt_move_up(text, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_CTO:
|
|
|
|
case UNDO_STO:
|
|
|
|
text->undo_pos--;
|
|
|
|
text->undo_pos--;
|
|
|
|
text->undo_pos--;
|
|
|
|
text->undo_pos--;
|
|
|
|
|
|
|
|
text->undo_pos--;
|
|
|
|
text->undo_pos--;
|
|
|
|
|
|
|
|
linep= text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep= (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep= (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep= (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
|
|
|
|
charp= text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
charp= (charp<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
|
|
|
|
if (op==UNDO_CTO) {
|
|
|
|
txt_move_toline(text, linep, 0);
|
|
|
|
text->curc= charp;
|
|
|
|
txt_pop_sel(text);
|
|
|
|
} else {
|
|
|
|
txt_move_toline(text, linep, 1);
|
|
|
|
text->selc= charp;
|
|
|
|
}
|
|
|
|
|
|
|
|
text->undo_pos--;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_INSERT:
|
|
|
|
txt_backspace_char(text);
|
|
|
|
text->undo_pos--;
|
|
|
|
text->undo_pos--;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_BS:
|
|
|
|
txt_add_char(text, text->undo_buf[text->undo_pos]);
|
|
|
|
text->undo_pos--;
|
|
|
|
text->undo_pos--;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_DEL:
|
|
|
|
txt_add_char(text, text->undo_buf[text->undo_pos]);
|
|
|
|
txt_move_left(text, 0);
|
|
|
|
text->undo_pos--;
|
|
|
|
text->undo_pos--;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_SWAP:
|
|
|
|
txt_curs_swap(text);
|
|
|
|
txt_do_undo(text); /* swaps should appear transparent */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_DBLOCK:
|
|
|
|
linep= text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep= (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep= (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep= (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
|
|
|
|
buf= MEM_mallocN(linep+1, "dblock buffer");
|
2006-04-03 20:31:10 +00:00
|
|
|
for (i=0; i < linep; i++){
|
2002-10-12 11:37:38 +00:00
|
|
|
buf[(linep-1)-i]= text->undo_buf[text->undo_pos];
|
|
|
|
text->undo_pos--;
|
|
|
|
}
|
|
|
|
buf[i]= 0;
|
|
|
|
|
|
|
|
txt_curs_first(text, &holdl, &holdc);
|
|
|
|
holdln= txt_get_span(text->lines.first, holdl);
|
|
|
|
|
|
|
|
txt_insert_buf(text, buf);
|
|
|
|
MEM_freeN(buf);
|
|
|
|
|
|
|
|
text->curl= text->lines.first;
|
|
|
|
while (holdln>0) {
|
|
|
|
if(text->curl->next)
|
|
|
|
text->curl= text->curl->next;
|
|
|
|
|
|
|
|
holdln--;
|
|
|
|
}
|
|
|
|
text->curc= holdc;
|
|
|
|
|
|
|
|
linep= text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep= (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep= (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep= (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
|
|
|
|
text->undo_pos--;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_IBLOCK:
|
|
|
|
linep= text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep= (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep= (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep= (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
|
|
|
|
txt_delete_sel(text);
|
|
|
|
while (linep>0) {
|
|
|
|
txt_backspace_char(text);
|
|
|
|
text->undo_pos--;
|
|
|
|
linep--;
|
|
|
|
}
|
|
|
|
|
|
|
|
text->undo_pos--;
|
|
|
|
text->undo_pos--;
|
|
|
|
text->undo_pos--;
|
|
|
|
text->undo_pos--;
|
|
|
|
|
|
|
|
text->undo_pos--;
|
|
|
|
|
|
|
|
break;
|
2005-12-12 18:35:15 +00:00
|
|
|
case UNDO_INDENT:
|
|
|
|
case UNDO_UNINDENT:
|
|
|
|
case UNDO_COMMENT:
|
|
|
|
case UNDO_UNCOMMENT:
|
|
|
|
linep= text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep = (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep = (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep = (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
//linep is now the end line of the selection
|
|
|
|
|
|
|
|
charp = text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
charp = (charp<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
//charp is the last char selected or text->line->len
|
|
|
|
//set the selcetion for this now
|
|
|
|
text->selc = charp;
|
|
|
|
text->sell = text->lines.first;
|
|
|
|
for (i= 0; i < linep; i++) {
|
|
|
|
text->sell = text->sell->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
linep= text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep = (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep = (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
linep = (linep<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
//first line to be selected
|
|
|
|
|
|
|
|
charp = text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
charp = (charp<<8)+text->undo_buf[text->undo_pos]; text->undo_pos--;
|
|
|
|
//first postion to be selected
|
|
|
|
text->curc = charp;
|
|
|
|
text->curl = text->lines.first;
|
|
|
|
for (i = 0; i < linep; i++) {
|
|
|
|
text->curl = text->curl->next;
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-12-12 18:35:15 +00:00
|
|
|
if (op==UNDO_INDENT) {
|
|
|
|
unindent(text);
|
|
|
|
} else if (op== UNDO_UNINDENT) {
|
|
|
|
indent(text);
|
|
|
|
} else if (op == UNDO_COMMENT) {
|
|
|
|
uncomment(text);
|
|
|
|
} else if (op == UNDO_UNCOMMENT) {
|
|
|
|
comment(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
text->undo_pos--;
|
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
default:
|
2008-01-01 18:16:10 +00:00
|
|
|
//XXX error("Undo buffer error - resetting");
|
2002-10-12 11:37:38 +00:00
|
|
|
text->undo_pos= -1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
undoing= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_do_redo(Text *text)
|
|
|
|
{
|
|
|
|
char op;
|
2006-04-03 20:31:10 +00:00
|
|
|
unsigned int linep, i;
|
2002-10-12 11:37:38 +00:00
|
|
|
unsigned short charp;
|
|
|
|
char *buf;
|
|
|
|
|
|
|
|
text->undo_pos++;
|
|
|
|
op= text->undo_buf[text->undo_pos];
|
|
|
|
|
|
|
|
if (!op) {
|
|
|
|
text->undo_pos--;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
undoing= 1;
|
2005-12-12 18:35:15 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
switch(op) {
|
|
|
|
case UNDO_CLEFT:
|
|
|
|
txt_move_left(text, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_CRIGHT:
|
|
|
|
txt_move_right(text, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_CUP:
|
|
|
|
txt_move_up(text, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_CDOWN:
|
|
|
|
txt_move_down(text, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_SLEFT:
|
|
|
|
txt_move_left(text, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_SRIGHT:
|
|
|
|
txt_move_right(text, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_SUP:
|
|
|
|
txt_move_up(text, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_SDOWN:
|
|
|
|
txt_move_down(text, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_INSERT:
|
|
|
|
text->undo_pos++;
|
|
|
|
txt_add_char(text, text->undo_buf[text->undo_pos]);
|
|
|
|
text->undo_pos++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_BS:
|
|
|
|
text->undo_pos++;
|
|
|
|
txt_backspace_char(text);
|
|
|
|
text->undo_pos++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_DEL:
|
|
|
|
text->undo_pos++;
|
|
|
|
txt_delete_char(text);
|
|
|
|
text->undo_pos++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_SWAP:
|
|
|
|
txt_curs_swap(text);
|
|
|
|
txt_do_undo(text); /* swaps should appear transparent a*/
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_CTO:
|
|
|
|
case UNDO_STO:
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_pos++;
|
|
|
|
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_pos++;
|
|
|
|
|
|
|
|
text->undo_pos++;
|
|
|
|
|
|
|
|
charp= text->undo_buf[text->undo_pos];
|
|
|
|
text->undo_pos++;
|
|
|
|
charp= charp+(text->undo_buf[text->undo_pos]<<8);
|
|
|
|
|
|
|
|
text->undo_pos++;
|
|
|
|
linep= text->undo_buf[text->undo_pos]; text->undo_pos++;
|
|
|
|
linep= linep+(text->undo_buf[text->undo_pos]<<8); text->undo_pos++;
|
|
|
|
linep= linep+(text->undo_buf[text->undo_pos]<<16); text->undo_pos++;
|
|
|
|
linep= linep+(text->undo_buf[text->undo_pos]<<24); text->undo_pos++;
|
|
|
|
|
|
|
|
if (op==UNDO_CTO) {
|
|
|
|
txt_move_toline(text, linep, 0);
|
|
|
|
text->curc= charp;
|
|
|
|
txt_pop_sel(text);
|
|
|
|
} else {
|
|
|
|
txt_move_toline(text, linep, 1);
|
|
|
|
text->selc= charp;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_DBLOCK:
|
|
|
|
text->undo_pos++;
|
|
|
|
linep= text->undo_buf[text->undo_pos]; text->undo_pos++;
|
|
|
|
linep= linep+(text->undo_buf[text->undo_pos]<<8); text->undo_pos++;
|
|
|
|
linep= linep+(text->undo_buf[text->undo_pos]<<16); text->undo_pos++;
|
|
|
|
linep= linep+(text->undo_buf[text->undo_pos]<<24); text->undo_pos++;
|
|
|
|
|
|
|
|
txt_delete_sel(text);
|
|
|
|
text->undo_pos+=linep;
|
|
|
|
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_pos++;
|
|
|
|
text->undo_pos++;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDO_IBLOCK:
|
|
|
|
text->undo_pos++;
|
|
|
|
linep= text->undo_buf[text->undo_pos]; text->undo_pos++;
|
|
|
|
linep= linep+(text->undo_buf[text->undo_pos]<<8); text->undo_pos++;
|
|
|
|
linep= linep+(text->undo_buf[text->undo_pos]<<16); text->undo_pos++;
|
|
|
|
linep= linep+(text->undo_buf[text->undo_pos]<<24); text->undo_pos++;
|
|
|
|
|
|
|
|
buf= MEM_mallocN(linep+1, "iblock buffer");
|
|
|
|
memcpy (buf, &text->undo_buf[text->undo_pos], linep);
|
|
|
|
text->undo_pos+= linep;
|
|
|
|
buf[linep]= 0;
|
|
|
|
|
|
|
|
txt_insert_buf(text, buf);
|
|
|
|
MEM_freeN(buf);
|
|
|
|
|
|
|
|
linep= text->undo_buf[text->undo_pos]; text->undo_pos++;
|
|
|
|
linep= linep+(text->undo_buf[text->undo_pos]<<8); text->undo_pos++;
|
|
|
|
linep= linep+(text->undo_buf[text->undo_pos]<<16); text->undo_pos++;
|
|
|
|
linep= linep+(text->undo_buf[text->undo_pos]<<24); text->undo_pos++;
|
|
|
|
|
|
|
|
break;
|
2005-12-12 18:35:15 +00:00
|
|
|
case UNDO_INDENT:
|
|
|
|
case UNDO_UNINDENT:
|
|
|
|
case UNDO_COMMENT:
|
|
|
|
case UNDO_UNCOMMENT:
|
|
|
|
text->undo_pos++;
|
|
|
|
charp = text->undo_buf[text->undo_pos]; text->undo_pos++;
|
|
|
|
charp = charp+(text->undo_buf[text->undo_pos]<<8); text->undo_pos++;
|
|
|
|
//charp is the first char selected or 0
|
|
|
|
|
|
|
|
linep= text->undo_buf[text->undo_pos]; text->undo_pos++;
|
|
|
|
linep = linep+(text->undo_buf[text->undo_pos]<<8); text->undo_pos++;
|
|
|
|
linep = linep+(text->undo_buf[text->undo_pos]<<16); text->undo_pos++;
|
|
|
|
linep = linep+(text->undo_buf[text->undo_pos]<<24); text->undo_pos++;
|
|
|
|
//linep is now the first line of the selection
|
|
|
|
//set the selcetion for this now
|
|
|
|
text->curc = charp;
|
|
|
|
text->curl = text->lines.first;
|
|
|
|
for (i= 0; i < linep; i++) {
|
|
|
|
text->curl = text->curl->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
charp = text->undo_buf[text->undo_pos]; text->undo_pos++;
|
|
|
|
charp = charp+(text->undo_buf[text->undo_pos]<<8); text->undo_pos++;
|
|
|
|
//last postion to be selected
|
|
|
|
linep= text->undo_buf[text->undo_pos]; text->undo_pos++;
|
|
|
|
linep = linep+(text->undo_buf[text->undo_pos]<<8); text->undo_pos++;
|
|
|
|
linep = linep+(text->undo_buf[text->undo_pos]<<16); text->undo_pos++;
|
|
|
|
linep = linep+(text->undo_buf[text->undo_pos]<<24); text->undo_pos++;
|
|
|
|
//Last line to be selected
|
|
|
|
|
|
|
|
text->selc = charp;
|
|
|
|
text->sell = text->lines.first;
|
|
|
|
for (i = 0; i < linep; i++) {
|
|
|
|
text->sell = text->sell->next;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-12-12 18:35:15 +00:00
|
|
|
if (op==UNDO_INDENT) {
|
|
|
|
indent(text);
|
|
|
|
} else if (op== UNDO_UNINDENT) {
|
|
|
|
unindent(text);
|
|
|
|
} else if (op == UNDO_COMMENT) {
|
|
|
|
comment(text);
|
|
|
|
} else if (op == UNDO_UNCOMMENT) {
|
|
|
|
uncomment(text);
|
|
|
|
}
|
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
default:
|
2008-01-01 18:16:10 +00:00
|
|
|
//XXX error("Undo buffer error - resetting");
|
2002-10-12 11:37:38 +00:00
|
|
|
text->undo_pos= -1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
undoing= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************/
|
|
|
|
/* Line editing functions */
|
|
|
|
/**************************/
|
|
|
|
|
2006-11-26 16:03:36 +00:00
|
|
|
void txt_split_curline (Text *text)
|
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
TextLine *ins;
|
2005-05-13 16:11:28 +00:00
|
|
|
char *left, *right, *fleft, *fright;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
if (!text->curl) return;
|
|
|
|
|
|
|
|
txt_delete_sel(text);
|
|
|
|
|
|
|
|
/* Make the two half strings */
|
|
|
|
|
|
|
|
left= MEM_mallocN(text->curc+1, "textline_string");
|
2005-05-13 16:11:28 +00:00
|
|
|
fleft= MEM_mallocN(text->curc+2, "Syntax_format");
|
2002-10-12 11:37:38 +00:00
|
|
|
if (text->curc) memcpy(left, text->curl->line, text->curc);
|
|
|
|
left[text->curc]=0;
|
|
|
|
|
|
|
|
right= MEM_mallocN(text->curl->len - text->curc+1, "textline_string");
|
2005-05-13 16:11:28 +00:00
|
|
|
fright= MEM_mallocN(text->curl->len - text->curc+2, "Syntax_format");
|
2002-10-12 11:37:38 +00:00
|
|
|
if (text->curl->len - text->curc) memcpy(right, text->curl->line+text->curc, text->curl->len-text->curc);
|
|
|
|
right[text->curl->len - text->curc]=0;
|
|
|
|
|
|
|
|
MEM_freeN(text->curl->line);
|
2005-05-19 03:15:49 +00:00
|
|
|
if (text->curl->format) MEM_freeN(text->curl->format);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/* Make the new TextLine */
|
|
|
|
|
|
|
|
ins= MEM_mallocN(sizeof(TextLine), "textline");
|
|
|
|
ins->line= left;
|
2005-05-13 16:11:28 +00:00
|
|
|
ins->format= fleft;
|
2002-10-12 11:37:38 +00:00
|
|
|
ins->len= text->curc;
|
|
|
|
|
|
|
|
text->curl->line= right;
|
2005-05-13 16:11:28 +00:00
|
|
|
text->curl->format= fright;
|
2002-10-12 11:37:38 +00:00
|
|
|
text->curl->len= text->curl->len - text->curc;
|
|
|
|
|
|
|
|
BLI_insertlinkbefore(&text->lines, text->curl, ins);
|
|
|
|
|
|
|
|
text->curc=0;
|
|
|
|
|
|
|
|
txt_make_dirty(text);
|
|
|
|
txt_clean_text(text);
|
|
|
|
|
|
|
|
txt_pop_sel(text);
|
|
|
|
if(!undoing) txt_undo_add_charop(text, UNDO_INSERT, '\n');
|
|
|
|
}
|
|
|
|
|
|
|
|
static void txt_delete_line (Text *text, TextLine *line)
|
|
|
|
{
|
|
|
|
if (!text) return;
|
|
|
|
if (!text->curl) return;
|
|
|
|
|
|
|
|
BLI_remlink (&text->lines, line);
|
|
|
|
|
|
|
|
if (line->line) MEM_freeN(line->line);
|
2005-05-13 16:11:28 +00:00
|
|
|
if (line->format) MEM_freeN(line->format);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
MEM_freeN(line);
|
|
|
|
|
|
|
|
txt_make_dirty(text);
|
|
|
|
txt_clean_text(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void txt_combine_lines (Text *text, TextLine *linea, TextLine *lineb)
|
|
|
|
{
|
2005-05-13 16:11:28 +00:00
|
|
|
char *tmp, *format;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
|
|
|
|
if(!linea || !lineb) return;
|
|
|
|
|
|
|
|
tmp= MEM_mallocN(linea->len+lineb->len+1, "textline_string");
|
2005-05-13 16:11:28 +00:00
|
|
|
format= MEM_mallocN(linea->len+lineb->len+1, "Syntax_format");
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
strcpy(tmp, linea->line);
|
|
|
|
strcat(tmp, lineb->line);
|
2005-05-13 16:11:28 +00:00
|
|
|
|
|
|
|
make_new_line(linea, tmp, format);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
txt_delete_line(text, lineb);
|
|
|
|
|
|
|
|
txt_make_dirty(text);
|
|
|
|
txt_clean_text(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
void txt_delete_char (Text *text)
|
|
|
|
{
|
|
|
|
char c='\n';
|
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
if (!text->curl) return;
|
|
|
|
|
2003-11-10 05:51:55 +00:00
|
|
|
if (txt_has_sel(text)) { /* deleting a selection */
|
|
|
|
txt_delete_sel(text);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2003-11-10 05:51:55 +00:00
|
|
|
else if (text->curc== text->curl->len) { /* Appending two lines */
|
2002-10-12 11:37:38 +00:00
|
|
|
if (text->curl->next) {
|
|
|
|
txt_combine_lines(text, text->curl, text->curl->next);
|
|
|
|
txt_pop_sel(text);
|
|
|
|
}
|
|
|
|
} else { /* Just deleting a char */
|
|
|
|
int i= text->curc;
|
|
|
|
|
|
|
|
c= text->curl->line[i];
|
|
|
|
while(i< text->curl->len) {
|
|
|
|
text->curl->line[i]= text->curl->line[i+1];
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
text->curl->len--;
|
|
|
|
|
|
|
|
txt_pop_sel(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
txt_make_dirty(text);
|
|
|
|
txt_clean_text(text);
|
|
|
|
|
|
|
|
if(!undoing) txt_undo_add_charop(text, UNDO_DEL, c);
|
|
|
|
}
|
|
|
|
|
2006-11-26 16:03:36 +00:00
|
|
|
void txt_backspace_char (Text *text)
|
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
char c='\n';
|
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
if (!text->curl) return;
|
|
|
|
|
2003-11-10 05:51:55 +00:00
|
|
|
if (txt_has_sel(text)) { /* deleting a selection */
|
|
|
|
txt_delete_sel(text);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2003-11-10 05:51:55 +00:00
|
|
|
else if (text->curc==0) { /* Appending two lines */
|
|
|
|
if (text->curl->prev) {
|
|
|
|
text->curl= text->curl->prev;
|
|
|
|
text->curc= text->curl->len;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-11-10 05:51:55 +00:00
|
|
|
txt_combine_lines(text, text->curl, text->curl->next);
|
|
|
|
txt_pop_sel(text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { /* Just backspacing a char */
|
|
|
|
int i= text->curc-1;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-11-10 05:51:55 +00:00
|
|
|
c= text->curl->line[i];
|
|
|
|
while(i< text->curl->len) {
|
|
|
|
text->curl->line[i]= text->curl->line[i+1];
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
text->curl->len--;
|
|
|
|
text->curc--;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-11-10 05:51:55 +00:00
|
|
|
txt_pop_sel(text);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
txt_make_dirty(text);
|
|
|
|
txt_clean_text(text);
|
|
|
|
|
|
|
|
if(!undoing) txt_undo_add_charop(text, UNDO_BS, c);
|
|
|
|
}
|
|
|
|
|
2006-11-26 16:03:36 +00:00
|
|
|
int txt_add_char (Text *text, char add)
|
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
int len;
|
2005-05-13 16:11:28 +00:00
|
|
|
char *tmp, *format;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
if (!text) return 0;
|
|
|
|
if (!text->curl) return 0;
|
|
|
|
|
|
|
|
if (add=='\n') {
|
|
|
|
txt_split_curline(text);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
txt_delete_sel(text);
|
|
|
|
|
|
|
|
tmp= MEM_mallocN(text->curl->len+2, "textline_string");
|
2005-05-13 16:11:28 +00:00
|
|
|
format= MEM_mallocN(text->curl->len+4, "Syntax_format");
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
if(text->curc) memcpy(tmp, text->curl->line, text->curc);
|
|
|
|
tmp[text->curc]= add;
|
|
|
|
|
|
|
|
len= text->curl->len - text->curc;
|
|
|
|
if(len>0) memcpy(tmp+text->curc+1, text->curl->line+text->curc, len);
|
|
|
|
tmp[text->curl->len+1]=0;
|
2005-05-13 16:11:28 +00:00
|
|
|
make_new_line(text->curl, tmp, format);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
text->curc++;
|
|
|
|
|
|
|
|
txt_pop_sel(text);
|
|
|
|
|
|
|
|
txt_make_dirty(text);
|
|
|
|
txt_clean_text(text);
|
|
|
|
|
|
|
|
if(!undoing) txt_undo_add_charop(text, UNDO_INSERT, add);
|
|
|
|
return 1;
|
|
|
|
}
|
2004-10-14 23:37:04 +00:00
|
|
|
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
void indent(Text *text)
|
2004-10-14 23:37:04 +00:00
|
|
|
{
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
int len, num;
|
2005-05-13 16:11:28 +00:00
|
|
|
char *tmp, *format;
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
char add = '\t';
|
|
|
|
|
2004-10-14 23:37:04 +00:00
|
|
|
if (!text) return;
|
|
|
|
if (!text->curl) return;
|
|
|
|
if (!text->sell) return;
|
2005-12-12 18:35:15 +00:00
|
|
|
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
num = 0;
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
tmp= MEM_mallocN(text->curl->len+2, "textline_string");
|
2005-05-13 16:11:28 +00:00
|
|
|
format= MEM_mallocN(text->curl->len+3, "Syntax_format");
|
|
|
|
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
text->curc = 0;
|
|
|
|
if(text->curc) memcpy(tmp, text->curl->line, text->curc);
|
|
|
|
tmp[text->curc]= add;
|
|
|
|
|
|
|
|
len= text->curl->len - text->curc;
|
|
|
|
if(len>0) memcpy(tmp+text->curc+1, text->curl->line+text->curc, len);
|
|
|
|
tmp[text->curl->len+1]=0;
|
2005-05-13 16:11:28 +00:00
|
|
|
|
|
|
|
make_new_line(text->curl, tmp, format);
|
2004-10-14 23:37:04 +00:00
|
|
|
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
text->curc++;
|
|
|
|
|
|
|
|
txt_make_dirty(text);
|
|
|
|
txt_clean_text(text);
|
|
|
|
|
|
|
|
if(text->curl == text->sell)
|
|
|
|
{
|
|
|
|
text->selc = text->sell->len;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
text->curl = text->curl->next;
|
|
|
|
num++;
|
2004-10-14 23:37:04 +00:00
|
|
|
}
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
}
|
|
|
|
text->curc = 0;
|
|
|
|
while( num > 0 )
|
|
|
|
{
|
|
|
|
text->curl = text->curl->prev;
|
|
|
|
num--;
|
2004-10-14 23:37:04 +00:00
|
|
|
}
|
2005-12-12 18:35:15 +00:00
|
|
|
|
|
|
|
if(!undoing)
|
|
|
|
{
|
|
|
|
txt_undo_add_toop(text, UNDO_INDENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc);
|
|
|
|
}
|
2004-10-14 23:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void unindent(Text *text)
|
|
|
|
{
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
int num = 0;
|
2005-12-12 18:35:15 +00:00
|
|
|
char remove = '\t';
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
|
2004-10-14 23:37:04 +00:00
|
|
|
if (!text) return;
|
|
|
|
if (!text->curl) return;
|
|
|
|
if (!text->sell) return;
|
2005-12-12 18:35:15 +00:00
|
|
|
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
while(TRUE)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
2005-12-12 18:35:15 +00:00
|
|
|
if (text->curl->line[i] == remove)
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
{
|
|
|
|
while(i< text->curl->len) {
|
|
|
|
text->curl->line[i]= text->curl->line[i+1];
|
2004-10-14 23:37:04 +00:00
|
|
|
i++;
|
|
|
|
}
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
text->curl->len--;
|
2004-10-14 23:37:04 +00:00
|
|
|
}
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
txt_make_dirty(text);
|
|
|
|
txt_clean_text(text);
|
|
|
|
|
|
|
|
if(text->curl == text->sell)
|
|
|
|
{
|
|
|
|
text->selc = text->sell->len;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
text->curl = text->curl->next;
|
|
|
|
num++;
|
2004-10-14 23:37:04 +00:00
|
|
|
}
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
|
|
|
|
}
|
2005-12-12 18:35:15 +00:00
|
|
|
text->curc = 0;
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
while( num > 0 )
|
|
|
|
{
|
|
|
|
text->curl = text->curl->prev;
|
|
|
|
num--;
|
2004-10-14 23:37:04 +00:00
|
|
|
}
|
2005-12-12 18:35:15 +00:00
|
|
|
|
|
|
|
if(!undoing)
|
|
|
|
{
|
|
|
|
txt_undo_add_toop(text, UNDO_UNINDENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc);
|
|
|
|
}
|
2004-10-14 23:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void comment(Text *text)
|
|
|
|
{
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
int len, num;
|
2005-05-13 16:11:28 +00:00
|
|
|
char *tmp, *format;
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
char add = '#';
|
|
|
|
|
|
|
|
if (!text) return;
|
|
|
|
if (!text->curl) return;
|
2005-12-12 18:35:15 +00:00
|
|
|
if (!text->sell) return;// Need to change this need to check if only one line is selected ot more then one
|
|
|
|
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
num = 0;
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
tmp= MEM_mallocN(text->curl->len+2, "textline_string");
|
2005-05-13 16:11:28 +00:00
|
|
|
format = MEM_mallocN(text->curl->len+3, "Syntax_format");
|
|
|
|
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
text->curc = 0;
|
|
|
|
if(text->curc) memcpy(tmp, text->curl->line, text->curc);
|
|
|
|
tmp[text->curc]= add;
|
|
|
|
|
|
|
|
len= text->curl->len - text->curc;
|
|
|
|
if(len>0) memcpy(tmp+text->curc+1, text->curl->line+text->curc, len);
|
|
|
|
tmp[text->curl->len+1]=0;
|
2005-05-13 16:11:28 +00:00
|
|
|
|
|
|
|
make_new_line(text->curl, tmp, format);
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
|
|
|
|
text->curc++;
|
|
|
|
|
|
|
|
txt_make_dirty(text);
|
|
|
|
txt_clean_text(text);
|
|
|
|
|
|
|
|
if(text->curl == text->sell)
|
|
|
|
{
|
|
|
|
text->selc = text->sell->len;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
text->curl = text->curl->next;
|
|
|
|
num++;
|
|
|
|
}
|
|
|
|
}
|
2005-12-12 18:35:15 +00:00
|
|
|
text->curc = 0;
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
while( num > 0 )
|
|
|
|
{
|
|
|
|
text->curl = text->curl->prev;
|
|
|
|
num--;
|
|
|
|
}
|
2005-12-12 18:35:15 +00:00
|
|
|
|
|
|
|
if(!undoing)
|
|
|
|
{
|
|
|
|
txt_undo_add_toop(text, UNDO_COMMENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc);
|
|
|
|
}
|
2004-10-14 23:37:04 +00:00
|
|
|
}
|
|
|
|
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
void uncomment(Text *text)
|
2004-10-14 23:37:04 +00:00
|
|
|
{
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
int num = 0;
|
2005-12-12 18:35:15 +00:00
|
|
|
char remove = '#';
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
|
2004-10-14 23:37:04 +00:00
|
|
|
if (!text) return;
|
|
|
|
if (!text->curl) return;
|
|
|
|
if (!text->sell) return;
|
2005-12-12 18:35:15 +00:00
|
|
|
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
while(TRUE)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
2005-12-12 18:35:15 +00:00
|
|
|
if (text->curl->line[i] == remove)
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
{
|
|
|
|
while(i< text->curl->len) {
|
|
|
|
text->curl->line[i]= text->curl->line[i+1];
|
2004-10-14 23:37:04 +00:00
|
|
|
i++;
|
|
|
|
}
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
text->curl->len--;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
txt_make_dirty(text);
|
|
|
|
txt_clean_text(text);
|
2004-10-14 23:37:04 +00:00
|
|
|
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
if(text->curl == text->sell)
|
|
|
|
{
|
|
|
|
text->selc = text->sell->len;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
text->curl = text->curl->next;
|
|
|
|
num++;
|
2004-10-14 23:37:04 +00:00
|
|
|
}
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
|
|
|
|
}
|
2005-12-12 18:35:15 +00:00
|
|
|
text->curc = 0;
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
while( num > 0 )
|
|
|
|
{
|
|
|
|
text->curl = text->curl->prev;
|
|
|
|
num--;
|
|
|
|
}
|
2005-12-12 18:35:15 +00:00
|
|
|
|
|
|
|
if(!undoing)
|
|
|
|
{
|
|
|
|
txt_undo_add_toop(text, UNDO_UNCOMMENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc);
|
|
|
|
}
|
2004-10-14 23:37:04 +00:00
|
|
|
}
|
|
|
|
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
int setcurr_tab (Text *text)
|
2004-10-14 23:37:04 +00:00
|
|
|
{
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
int i = 0;
|
|
|
|
int test = 0;
|
|
|
|
char *word = ":";
|
|
|
|
char *comm = "#";
|
|
|
|
char back_words[3][7] = {"return", "break", "pass"};
|
2005-04-28 14:37:15 +00:00
|
|
|
if (!text) return 0;
|
|
|
|
if (!text->curl) return 0;
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
|
|
|
|
while (text->curl->line[i] == '\t')
|
|
|
|
{
|
|
|
|
//we only count thos tabs that are before any text or before the curs;
|
|
|
|
if (i == text->curc)
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
} else {
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(strstr(text->curl->line, word))
|
|
|
|
{
|
|
|
|
//if we find a : then add a tab but not if it is in a comment
|
|
|
|
if(strcspn(text->curl->line, word) < strcspn(text->curl->line, comm))
|
|
|
|
{
|
|
|
|
i++;
|
2004-10-14 23:37:04 +00:00
|
|
|
|
2005-05-13 16:11:28 +00:00
|
|
|
}
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
}
|
2004-10-14 23:37:04 +00:00
|
|
|
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
while(test < 3)
|
|
|
|
{
|
|
|
|
//if there are these 3 key words then remove a tab because we are done with the block
|
|
|
|
if(strstr(text->curl->line, back_words[test]) && i > 0)
|
|
|
|
{
|
|
|
|
if(strcspn(text->curl->line, back_words[test]) < strcspn(text->curl->line, comm))
|
|
|
|
{
|
|
|
|
i--;
|
2004-10-14 23:37:04 +00:00
|
|
|
}
|
|
|
|
}
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
test++;
|
2004-10-14 23:37:04 +00:00
|
|
|
}
|
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
|
|
|
return i;
|
2004-10-14 23:37:04 +00:00
|
|
|
}
|
2005-04-28 14:37:15 +00:00
|
|
|
|