[RFC]加入对于表情多行的支持

1 view
Skip to first unread message

Guanqun Lu

unread,
Apr 26, 2008, 3:45:30 AM4/26/08
to PCM...@googlegroups.com
Hi list,

我发觉PCManX的表情功能很实用,但是它默认的情况无法存放多行的数据。
所以我简单地添加了这样的功能。

有什么问题,欢迎指出。

谢谢!

--
Guanqun

0001-multiple-lines-of-emoticons-supported.patch
0002-add-a-multiline-text-entry.patch

pcma...@gmail.com

unread,
Apr 27, 2008, 5:35:33 AM4/27/08
to PCManX
事實上 PCManX 的 code 裡面有可以把 string escape 的 function
把換行轉成 \n,就可以以單行儲存了,不需要把檔案格式搞到這麼複雜
我記得預設應該有作這件事情,如果沒效那應該是 bug
> 0001-multiple-lines-of-emoticons-supported.patch
> 11K下載
>
> 0002-add-a-multiline-text-entry.patch
> 3K下載

Guanqun Lu

unread,
Apr 27, 2008, 9:17:34 AM4/27/08
to PCM...@googlegroups.com, pcma...@gmail.com
你好,

首先谢谢你的回复!

On Sun, 27 Apr 2008 02:35:33 -0700 (PDT)
pcma...@gmail.com wrote:

> 事實上 PCManX 的 code 裡面有可以把 string escape 的 function
> 把換行轉成 \n,就可以以單行儲存了,不需要把檔案格式搞到這麼複雜

确实,我把这个文件的档案格式搞复杂了。不过我对整个代码不是很熟悉,
能不能麻烦你指点下这个function是哪个?谢谢!

> 我記得預設應該有作這件事情,如果沒效那應該是 bug

你是说 Edit -> Preference 中本来应该有这样的选项?但是我仔细看了
下,好像没有。

>
> On 4月26日, 下午3時45分, Guanqun Lu <guanqun...@gmail.com> wrote:
> > Hi list,
> >
> > 我发觉PCManX的表情功能很实用,但是它默认的情况无法存放多行的数据。
> > 所以我简单地添加了这样的功能。
> >
> > 有什么问题,欢迎指出。
> >
> > 谢谢!
> >
> > --
> > Guanqun
> >
> > 0001-multiple-lines-of-emoticons-supported.patch
> > 11K下載
> >
> > 0002-add-a-multiline-text-entry.patch
> > 3K下載
> >


--
Guanqun

Guanqun Lu

unread,
Apr 28, 2008, 10:15:43 AM4/28/08
to PCManX
If anybody cares, there is a silly mistake...

---
src/emoticondlg.cpp | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/emoticondlg.cpp b/src/emoticondlg.cpp
index d69d4d3..bf5cebd 100644
--- a/src/emoticondlg.cpp
+++ b/src/emoticondlg.cpp
@@ -208,7 +208,7 @@ void CEmoticonDlg::LoadEmoticons()
if( fi )
{
char line[1024];
- char offset;
+ int offset;
int i, num;
while (fgets( line, sizeof(line), fi )) {
if (sscanf( line, "%d\n", &num ) != 1)
--
> 0001-multiple-lines-of-emoticons-supported.patch
> 11KDownload
>
> 0002-add-a-multiline-text-entry.patch
> 3KDownload

Shih-Yuan Lee (FourDollars)

unread,
Apr 28, 2008, 10:49:44 AM4/28/08
to PCM...@googlegroups.com
Hi Guanqun,

Please check out the latest source code from Subversion repository.
I can not see this fragment.

2008/4/28 Guanqun Lu <Guanq...@gmail.com>:

Guanqun Lu

unread,
Apr 28, 2008, 11:03:48 AM4/28/08
to PCM...@googlegroups.com, fourd...@gmail.com
On Mon, 28 Apr 2008 22:49:44 +0800
"Shih-Yuan Lee (FourDollars)" <fourd...@gmail.com> wrote:

> Hi Guanqun,
>
> Please check out the latest source code from Subversion repository.
> I can not see this fragment.

Ah... I mean this silly mistake is in my second patch that I sent before.
It is NOT in the subversion repository.

So, don't worry too much... :-)


--
Guanqun

jserv

unread,
Jun 17, 2008, 2:43:33 PM6/17/08
to PCManX
On 4月28日, 下午11時03分, Guanqun Lu <guanqun...@gmail.com> wrote:
> Ah... I mean this silly mistake is in my second patch that I sent before.
> It is NOT in the subversion repository.
>
> So, don't worry too much... :-)
>

hi Guanqun,

I'm aware of your usage about git-svn for pcmanx. Could you please
provide new patch based on latest svn tree? Also, it would be great
if the patch reflects PCMan's advise for text manipulation.

Thanks,
-jserv

Guanqun Lu

unread,
Jun 18, 2008, 3:32:54 AM6/18/08
to PCM...@googlegroups.com, jser...@gmail.com

Hi,

Here are the two patches based on the latest svn tree.

The file format of emoticon does not need to change now.

>
> Thanks,
> -jserv
> >


--
Guanqun

0001-add-a-multiline-text-entry.patch
0002-multi-lines-support-in-emoticons.patch

pcma...@gmail.com

unread,
Jun 18, 2008, 11:46:29 AM6/18/08
to PCManX
Thank you. I've reviewed the patches.
Some opinions:

1. Thank you for g_strcompress. I don't know this functions before so
I coded my own in pcmanx.
Since you are using g_strcompress, maybe g_strescape can be used,
too. So the code will be
cleaner. Performance is not an issue when saving a config file like
this. So, using existing API
might be preferred.

2. Memory leaks are noted in bool CMultiInputDialog::OnOK().
m_Text = gtk_text_buffer_get_text(buffer, &beg, &end, FALSE);
You copied the allocated string returned by gtk to std::string
without freeing it.

3. Maybe this will be better than coding a new class like
CMultiInputDialog.
CInputDialog::CInputDialog( ...., multiline = false );
Since the only difference between those two classes is that entry
widget.
So, if I were you, I'll put them into the same class.
Although this might not be the optimal solution, personally I prefer
this way.
However, since I'm not good at C++, it's just my humble opinion...

On 6月18日, 下午3時32分, Guanqun Lu <guanqun...@gmail.com> wrote:
> On Tue, 17 Jun 2008 11:43:33 -0700 (PDT)
>
> 0001-add-a-multiline-text-entry.patch
> 3K下載
>
> 0002-multi-lines-support-in-emoticons.patch
> 1K下載

Guanqun Lu

unread,
Jun 20, 2008, 1:44:09 AM6/20/08
to PCM...@googlegroups.com, pcma...@gmail.com
Hi,

Thank you for your review.

On Wed, 18 Jun 2008 08:46:29 -0700 (PDT)
pcma...@gmail.com wrote:

>
> Thank you. I've reviewed the patches.
> Some opinions:
>
> 1. Thank you for g_strcompress. I don't know this functions before so
> I coded my own in pcmanx.
> Since you are using g_strcompress, maybe g_strescape can be used,
> too. So the code will be
> cleaner. Performance is not an issue when saving a config file like
> this. So, using existing API
> might be preferred.

I tried g_strescape once, but it escaped all the non-ASCII char.
Thus, the emoticons config file is full of \357\344... lots of non-readable
characters. So I manually code this function only to escape the '\n' character,
and other characters are not changed.

>
> 2. Memory leaks are noted in bool CMultiInputDialog::OnOK().
> m_Text = gtk_text_buffer_get_text(buffer, &beg, &end, FALSE);
> You copied the allocated string returned by gtk to std::string
> without freeing it.

Ah, yes, it leaks the memory... Thanks!

>
> 3. Maybe this will be better than coding a new class like
> CMultiInputDialog.
> CInputDialog::CInputDialog( ...., multiline = false );
> Since the only difference between those two classes is that entry
> widget.
> So, if I were you, I'll put them into the same class.
> Although this might not be the optimal solution, personally I prefer
> this way.

And here's the patch according to your suggestion.
The interface is simpler, since we don't need another similar class.
But the internal implementation is messier, I have to do a few
'if...else...' to handle the two different logic.

> However, since I'm not good at C++, it's just my humble opinion...
>
> On 6月18日, 下午3時32分, Guanqun Lu <guanqun...@gmail.com> wrote:
> > On Tue, 17 Jun 2008 11:43:33 -0700 (PDT)
> >
> > jserv <jserv...@gmail.com> wrote:
> >
> > > On 4月28日, 下午11時03分, Guanqun Lu <guanqun...@gmail.com> wrote:
> > > > Ah... I mean this silly mistake is in my second patch that I sent before.
> > > > It is NOT in the subversion repository.
> >
> > > > So, don't worry too much... :-)
> >
> > > hi Guanqun,
> >
> > > I'm aware of your usage about git-svn for pcmanx. Could you please
> > > provide new patch based on latest svn tree? Also, it would be great
> > > if the patch reflects PCMan's advise for text manipulation.
> >
> > Hi,
> >
> > Here are the two patches based on the latest svn tree.
> >
> > The file format of emoticon does not need to change now.
> >
> >
> >
> > > Thanks,
> > > -jserv
> >
> > --
> > Guanqun
> >
> > 0001-add-a-multiline-text-entry.patch
> > 3K下載
> >
> > 0002-multi-lines-support-in-emoticons.patch
> > 1K下載
> >


--
Guanqun

0001-multiline-support-in-emoticons.patch
Reply all
Reply to author
Forward
0 new messages