Skip to content

Commit

Permalink
Merge pull request #192 from RamonUnch/RamonUnch-patch-1
Browse files Browse the repository at this point in the history
Use a global dynamic arena alocator for al temporary stuff
  • Loading branch information
RamonUnch authored Dec 7, 2024
2 parents fc4043a + 87e752b commit 0a192ae
Show file tree
Hide file tree
Showing 30 changed files with 422 additions and 341 deletions.
2 changes: 1 addition & 1 deletion ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void SetFontSize(LOGFONT *font, HDC hDC, int fsiz, int fx);
//@}
//=========================================================================

class ConfigManager : public ki::Object
class ConfigManager
{
public:

Expand Down
117 changes: 57 additions & 60 deletions GpMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ void GreenPadWnd::on_pagesetup()
PAGESETUPDLG psd;
mem00(&psd, sizeof(psd));
psd.lStructSize = sizeof(psd);
// FIXME: use local units...
// FIXME: use local units.
psd.Flags = PSD_INTHOUSANDTHSOFINCHES|PSD_DISABLEORIENTATION|PSD_DISABLEPAPER|PSD_DISABLEPRINTER|PSD_MARGINS;
psd.hwndOwner = hwnd();
CopyRect(&psd.rtMargin, cfg_.PMargins());
Expand Down Expand Up @@ -914,12 +914,12 @@ void GreenPadWnd::on_drop( HDROP hd )
// Get length of the i string for array size.
UINT len = ::myDragQueryFile( hd, i, NULL, 0)+1;
len = Max(len, (UINT)MAX_PATH); // ^ the Above may fail on NT3.1
TCHAR *str = (TCHAR *)malloc( sizeof(TCHAR) * len );
TCHAR *str = (TCHAR *)TS.alloc( sizeof(TCHAR) * len );
if( str )
{
::myDragQueryFile( hd, i, str, len );
Open( str, AutoDetect );
free( str );
TS.freelast( str, sizeof(TCHAR) * len );
}
}
::DragFinish( hd );
Expand Down Expand Up @@ -1959,85 +1959,82 @@ int kmain()
{
// MsgBox(GetCommandLine(), TEXT("Command Line"), MB_OK);
LOGGER( "kmain() begin" );
GreenPadWnd wnd;
{
Argv arg;
ulong i;
int optL = -1;
int optC = 0;

Argv arg;
ulong i;
LOGGER( "argv processed" );

LOGGER( "argv processed" );
//-- まずオプションスイッチを処理

//-- まずオプションスイッチを処理
for( i=1; i<arg.size() && arg[i][0]==TEXT('-'); ++i )
switch( arg[i][1] )
{
case TEXT('c'):
optC = String::GetInt( arg[i]+2 );
break;
case TEXT('l'):
optL = String::GetInt( arg[i]+2 );
break;
}

int optL = -1;
int optC = 0;
LOGGER( "option processed" );

for( i=1; i<arg.size() && arg[i][0]==TEXT('-'); ++i )
switch( arg[i][1] )
//-- 次にファイル名
Path file;
if( i < arg.size() )
{
case TEXT('c'):
optC = String::GetInt( arg[i]+2 );
break;
case TEXT('l'):
optL = String::GetInt( arg[i]+2 );
break;
}
file = arg[i];
if( !file.isFile() )
{
ulong j; // ""無しで半スペ入りでもそれなりに対処
for( j=i+1; j<arg.size(); ++j )
{
file += ' ';
file += arg[j];
if( file.isFile() )
break;
}

LOGGER( "option processed" );
if( j==arg.size() )
file = arg[i];
else
i=j;
}
}

//-- 次にファイル名
LOGGER( "filename processed" );

Path file;
//-- 余ってる引数があれば、それで新規プロセス起動

if( i < arg.size() )
{
file = arg[i];
if( !file.isFile() )
if( ++i < arg.size() )
{
ulong j; // ""無しで半スペ入りでもそれなりに対処
for( j=i+1; j<arg.size(); ++j )
String cmd;
for( ; i<arg.size(); ++i )
{
file += ' ';
file += arg[j];
if( file.isFile() )
break;
cmd += TEXT('\"');
cmd += arg[i];
cmd += TEXT("\" ");
}

if( j==arg.size() )
file = arg[i];
else
i=j;
::BootNewProcess( cmd.c_str() );
}
}

LOGGER( "filename processed" );
LOGGER( "newprocess booted" );

//-- 余ってる引数があれば、それで新規プロセス起動
//-- メインウインドウ発進
if( !wnd.StartUp(file, optC, optL) )
return -1;

if( ++i < arg.size() )
{
String cmd;
for( ; i<arg.size(); ++i )
{
cmd += TEXT('\"');
cmd += arg[i];
cmd += TEXT("\" ");
}
::BootNewProcess( cmd.c_str() );
TS.reset();
}

LOGGER( "newprocess booted" );

//-- メインウインドウ発進

GreenPadWnd wnd;
if( !wnd.StartUp(file,optC,optL) )
return -1;
//-- メインループ

LOGGER( "kmain() startup ok" );

//-- メインループ

// wnd.ShowUp2();
// LOGGER( "showup!" );
wnd.MsgLoop();

LOGGER( "fin" );
Expand Down
2 changes: 1 addition & 1 deletion RSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ struct RegNode: public Object
//@}
//=========================================================================

class RegParser: public Object
class RegParser
{
public:
RegParser( const unicode* pat );
Expand Down
12 changes: 6 additions & 6 deletions Search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ void SearchManager::on_init()
#ifdef _UNICODE
SetItemText( IDC_FINDBOX, str.get() );
#else
char *ab = malloc( (len+1) * 3 * sizeof(TCHAR) );
char *ab = (char*)TS.alloc( (len+1) * 3 * sizeof(TCHAR) );
if( ab )
{
::WideCharToMultiByte( CP_ACP, 0, str.get(), -1,
ab, (len+1)*3, NULL, NULL );
SetItemText( IDC_FINDBOX, ab );
free( ab );
TS.freelast( ab, (len+1) * 3 * sizeof(TCHAR) );
}
#endif
}
Expand Down Expand Up @@ -226,21 +226,21 @@ void SearchManager::UpdateData()

TCHAR* str;
LRESULT n = SendMsgToItem( IDC_FINDBOX, WM_GETTEXTLENGTH );
str = (TCHAR*)malloc( sizeof(TCHAR) * (n+1) );
str = (TCHAR*)TS.alloc( sizeof(TCHAR) * (n+1) );
if( str )
{
GetItemText( IDC_FINDBOX, n+1, str );
findStr_ = str;
free( str );
TS.freelast( str, sizeof(TCHAR) * (n+1) );
}

n = SendMsgToItem( IDC_REPLACEBOX, WM_GETTEXTLENGTH );
str = (TCHAR*)malloc( sizeof(TCHAR) * (n+1) );
str = (TCHAR*)TS.alloc( sizeof(TCHAR) * (n+1) );
if( str )
{
GetItemText( IDC_REPLACEBOX, n+1, str );
replStr_ = str;
free( str );
TS.freelast( str, sizeof(TCHAR) * (n+1) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion Search.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//@}
//=========================================================================

class Searchable : public ki::Object
class Searchable
{
public:
//@{
Expand Down
4 changes: 2 additions & 2 deletions editwing/ewCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ inline bool isLowSurrogate(unicode ch)
//@}
//=========================================================================

struct DPos : public ki::Object
struct DPos
{
//@{ バッファ中のアドレス (0~ ) //@}
ulong ad;
Expand Down Expand Up @@ -134,7 +134,7 @@ enum WrapType
//@}
//=========================================================================

struct VConfig : public ki::Object
struct VConfig
{
//@{ フォント //@}
LOGFONT font;
Expand Down
2 changes: 1 addition & 1 deletion editwing/ewCtrl1.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _EDITWING_CTRL1_H_
#define _EDITWING_CTRL1_H_
#include "ewDoc.h"
#include "ewView.h"
#include "ip_view.h"
#include "ip_doc.h"
#ifndef __ccdoc__
namespace editwing {
Expand Down
56 changes: 2 additions & 54 deletions editwing/ewView.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,58 +14,6 @@ class Caret;
class OleDnDTarget;


//=========================================================================
//@{ @pkg editwing.View //@}
//@{
// 描画処理など
//
// このクラスでは、メッセージの分配を行うだけで、実装は
// Canvas/ViewImpl 等で行う。ので、詳しくはそちらを参照のこと。
//@}
//=========================================================================

class View A_FINAL: public ki::WndImpl, public doc::DocEvHandler
{
public:

//@{ 何もしないコンストラクタ //@}
View( doc::Document& d, HWND wnd );
~View();

//@{ 折り返し方式切替 //@}
void SetWrapType( int wt );

void SetWrapSmart( bool ws);

//@{ 行番号表示/非表示切替 //@}
void ShowLineNo( bool show );

//@{ 表示色・フォント切替 //@}
void SetFont( const VConfig& vc );

//@{ Set all canva stuff at once (faster) //@}
void SetWrapLNandFont( int wt, bool ws, bool showLN, const VConfig& vc );

//@{ カーソル //@}
Cursor& cur();

private:

doc::Document& doc_;
ViewImpl* impl_;
static ClsName className_;

private:

void on_create( CREATESTRUCT* cs ) override;
void on_destroy() override;
LRESULT on_message( UINT msg, WPARAM wp, LPARAM lp ) override;
void on_text_update( const DPos& s, const DPos& e, const DPos& e2, bool bAft, bool mCur ) override;
void on_keyword_change() override;
};



//=========================================================================
//@{
// イベントハンドラインターフェイス
Expand Down Expand Up @@ -173,7 +121,7 @@ struct VPos : public DPos
//-------------------------------------------------------------------------
// Caret制御用ラッパー
//-------------------------------------------------------------------------
class Caret : public ki::Object
class Caret
{
public:
Caret( HWND wnd )
Expand Down Expand Up @@ -220,7 +168,7 @@ class Caret : public ki::Object
// カーソル
//@}
//=========================================================================
class Cursor : public ki::Object
class Cursor
{
public:

Expand Down
9 changes: 5 additions & 4 deletions editwing/ip_cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,11 @@ void Cursor::InputUTF32( qbyte utf32 )

void Cursor::Input( const char* str, ulong len )
{
unicode* ustr = (unicode *)malloc( len * 4 * sizeof(unicode) );
unicode* ustr = (unicode *)TS.alloc( len * 4 * sizeof(unicode) );
if(!ustr) return;
len = ::MultiByteToWideChar( CP_ACP, 0, str, len, ustr, len*4 );
Input( ustr, len );
free( ustr );
TS.freelast( ustr, len * 4 * sizeof(unicode) );
}
void Cursor::InputAt( const unicode *str, ulong len, int x, int y )
{
Expand Down Expand Up @@ -585,11 +585,11 @@ void Cursor::InputAt( const unicode *str, ulong len, int x, int y )
}
void Cursor::InputAt( const char* str, ulong len, int x, int y )
{
unicode* ustr = (unicode *)malloc( len * 4 * sizeof(unicode) );
unicode* ustr = (unicode *)TS.alloc( len * 4 * sizeof(unicode) );
if(!ustr) return;
len = ::MultiByteToWideChar( CP_ACP, 0, str, len, ustr, len*4 );
InputAt( ustr, len, x, y );
free( ustr );
TS.freelast( ustr, len * 4 * sizeof(unicode) );
}

void Cursor::DelBack( bool wide )
Expand Down Expand Up @@ -960,6 +960,7 @@ void Cursor::ModSelection(ModProc mfunk)
}

free( p );

// // Useless for now...
// if( np < p || np > p+len+1 )
// delete np; // was allocated
Expand Down
Loading

0 comments on commit 0a192ae

Please sign in to comment.