Re: Get and set terminal size

2014-04-20 Thread Denis Mezhov via Digitalmars-d-learn

On Saturday, 19 April 2014 at 12:06:58 UTC, FreeSlave wrote:

I use
ldc2 main.d -L-lcurses
or
dmd main.d -L-lcurses

and following source code:

import std.stdio;

extern(C) int tgetnum(const(char) *id);

int main()
{
writeln(tgetnum("li"));
return 0;
}

Note that you don't need to apply toStringz to string literals 
since they implicitly cast to const char*.


It's work) Thanks.


Re: Get and set terminal size

2014-04-19 Thread Denis Mezhov via Digitalmars-d-learn

On Saturday, 19 April 2014 at 10:39:43 UTC, Adam D. Ruppe wrote:

Blargh, I don't know teh ldc switch for it :(

Try adding pragma(lib, "curses"); (or ncurses) to your file 
with main in it, i think ldc supports that.






pragma(lib, "curses");

extern(C):
int tgetnum(const(char) *capname);

hmm segfault error :(
Segmentation fault: 11


Re: Get and set terminal size

2014-04-19 Thread Denis Mezhov via Digitalmars-d-learn

On Saturday, 19 April 2014 at 09:59:39 UTC, Adam D. Ruppe wrote:
Try adding -lncurses or -lcurses to the command line. tgetnum 
is found in the curses library which isn't linked in 
automatically by default.



Error: unrecognized switch '-lcurses'
Error: unrecognized switch '-lncurses'

:((



Get and set terminal size

2014-04-19 Thread Denis Mezhov via Digitalmars-d-learn

I want use tgetnum for get terminal size
http://www.mkssoftware.com/docs/man3/curs_termcap.3.asp

extern(C):
int tgetnum(const(char) *capname);

calling a method from main
writeln(tgetnum(toStringz("li")));


I receive an error message
Undefined symbols for architecture x86_64:
  "_tgetnum", referenced from:
  _main in RSConsole.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to 
see invocation)



Does anyone know what the problem is?
Maybe there are other methods to get and set sizes of the Mac OS 
X console?


Re: unicode console output

2014-04-02 Thread Denis Mezhov

Tnx, chcp 65001 and Lucida font out correct string.


Re: unicode console output

2014-04-02 Thread Denis Mezhov

On Wednesday, 2 April 2014 at 12:51:57 UTC, bearophile wrote:

Denis Mezhov:


How to out unicode cyrillic string to console?


Try this command on the command line:

chcp 65001

Bye,
bearophile


chcp 65001 dont'work


start.bat

mode con cols=150 lines=50
chcp 65001
%Path%\Minesweeper\Debug\Mi.exe

don't out correct string


unicode console output

2014-04-02 Thread Denis Mezhov

I'm trying out to windows console unicode latin string

writeln("aaabbb");
console out: aaabbb

trying out to console unicode cyrillic string
writeln("бббггг");
console out: ╨│╨│╨│╨▒╨▒╨▒

How to out unicode cyrillic string to console?


Re: How to get normal DLL method name

2014-02-15 Thread Denis Mezhov

On Sunday, 16 February 2014 at 07:17:48 UTC, Denis Mezhov wrote:

Don't work

DLL

module dllmain;

import std.c.windows.windows;
import core.sys.windows.dll;
import core.stdc.stdio;

__gshared HINSTANCE g_hInst;

export void dllprint()
{
printf("hello dll world\n");  
}

extern (Windows)
BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID 
pvReserved)

{
final switch (ulReason)
{
case DLL_PROCESS_ATTACH:
g_hInst = hInstance;
dll_process_attach( hInstance, true );
break;

case DLL_PROCESS_DETACH:
dll_process_detach( hInstance, true );
break;

case DLL_THREAD_ATTACH:
dll_thread_attach( true, true );
break;

case DLL_THREAD_DETACH:
dll_thread_detach( true, true );
break;
}
return true;
}




Main

import core.runtime;

import std.stdio;
import std.container;
import std.range;
import std.c.windows.windows;

alias void function() aaa;
aaa bbb;

extern (Windows)
void main(string[] args)
{
   HMODULE h;
   FARPROC fp;  
   h = cast(HMODULE) Runtime.loadLibrary("DynamicLib1.dll");  
   if (h is null)
  {
 printf("error loading mydll.dll\n");
  }
   fp = GetProcAddress(h, "dllprint");  //Don't work
  if (fp is null)
  {
  printf("error loading symbol()\n");
  }

  bbb = cast(aaa)fp;
  bbb();

  readln();
}


Oh, sorry

export extern (C) void dllprint()
{
   printf("hello dll world\n");   
}

It work


Re: How to get normal DLL method name

2014-02-15 Thread Denis Mezhov

Don't work

DLL

module dllmain;

import std.c.windows.windows;
import core.sys.windows.dll;
import core.stdc.stdio;

__gshared HINSTANCE g_hInst;

export void dllprint()
{
printf("hello dll world\n");  
}

extern (Windows)
BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID 
pvReserved)

{
final switch (ulReason)
{
case DLL_PROCESS_ATTACH:
g_hInst = hInstance;
dll_process_attach( hInstance, true );
break;

case DLL_PROCESS_DETACH:
dll_process_detach( hInstance, true );
break;

case DLL_THREAD_ATTACH:
dll_thread_attach( true, true );
break;

case DLL_THREAD_DETACH:
dll_thread_detach( true, true );
break;
}
return true;
}




Main

import core.runtime;

import std.stdio;
import std.container;
import std.range;
import std.c.windows.windows;

alias void function() aaa;
aaa bbb;

extern (Windows)
void main(string[] args)
{
   HMODULE h;
   FARPROC fp;  
   h = cast(HMODULE) Runtime.loadLibrary("DynamicLib1.dll");  
   if (h is null)
  {
 printf("error loading mydll.dll\n");
  }
   fp = GetProcAddress(h, "dllprint");  //Don't work
  if (fp is null)
  {
  printf("error loading symbol()\n");
  }

  bbb = cast(aaa)fp;
  bbb();

  readln();
}


Re: How to get normal DLL method name

2014-02-15 Thread Denis Mezhov

Sorry

// Not work
FARPROC fp = GetProcAddress(h, "dllprint");
if fp is null)
{
printf("error loading symbol()\n");
}

// It work
FARPROC fp = GetProcAddress(h, "D7dllmain8dllprintFZv");

if fp is null)
{
printf("error loading symbol()\n");
}


How to get normal DLL method name

2014-02-15 Thread Denis Mezhov

DLL

module dllmain;

import std.c.windows.windows;
import core.sys.windows.dll;
import core.stdc.stdio;

__gshared HINSTANCE g_hInst;

extern (Windows)
BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID 
pvReserved)

{
final switch (ulReason)
{
case DLL_PROCESS_ATTACH:
g_hInst = hInstance;
dll_process_attach( hInstance, true );
break;

case DLL_PROCESS_DETACH:
dll_process_detach( hInstance, true );
break;

case DLL_THREAD_ATTACH:
dll_thread_attach( true, true );
break;

case DLL_THREAD_DETACH:
dll_thread_detach( true, true );
break;
}
return true;
}

export void dllprint()
{
printf("hello dll world\n");  
}

In Main

FARPROC fp = GetProcAddress(h, "dllmain");  // Not work
if fp is null)
{
   printf("error loading symbol()\n");
}


FARPROC fp = GetProcAddress(h, "D7dllmain8dllprintFZv"); // It 
work

if fp is null)
{
   printf("error loading symbol()\n");
}

How i set/get normal name in DLL?







Re: How convert DList!string to string array

2014-02-15 Thread Denis Mezhov

On Saturday, 15 February 2014 at 16:38:42 UTC, Timon Gehr wrote:

On 02/15/2014 05:30 PM, Denis Mezhov wrote:

Please help. How to convert DList!string to string array?

auto a = DList!string();
a.insertFront("123");
a.insertFront("abc");

string[] b = a[];
Array!string c = a[];

Don't work.




auto b = a[].array;
Array!string c;
c.insertBack(a[]);


It works! Thanks for the quick reply.


How convert DList!string to string array

2014-02-15 Thread Denis Mezhov

Please help. How to convert DList!string to string array?

auto a = DList!string();
a.insertFront("123");
a.insertFront("abc");

string[] b = a[];
Array!string c = a[];

Don't work.